Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

Event Loop

Posted by Gerhard Kreuzer on July 10, 2012
Hi,
I have to inform some tasks about significant changes very async, like somebody has entered some command using a console task.
So I want to have a task (high priority) which takes up some thing lets call event and than check out all tasks which have subscribed to this event during initialization.
Now the tasks loops throogh all the callBacks and execute them.
Works fine, as long tzhere is no need to pass parameters, even if this parameters were of different datatypes, like int and string.
Has anybody some idea or is something like this almost around?

Thanks for helping.

With best regards

Gerhard

RE: Event Loop

Posted by Richard Damon on July 11, 2012
I am a bit confused on which of two structures you are using.

One method is to have the high priority task accept the notification of the event, and then walk a list of subscribers queues and relay that message to all those event queues. Then the various tasks take the events off their lists and process the notifications. This does require that all the tasks involved use similarly formatted messages. In this case, you just need to make sure that your message format has room for the various options/parameters, perhaps in a union in the event structure. Alternatively, it might have a pointer to a structure which holds the various parameters.

A second method is that the various tasks register a callback function that is called in the context of the notifying task, and that callback function does what is needed to notify the task of the event. All of these functions for a given notification list should have the same signature. The notification task will need to pass all the information that any task might need to this function. If you really need to have differing signatures, then in addition to saving the address of the function to call, you need to also save information about what parameter list this function needs. This can either be a number that you put into a switch statement, or a pointer to a second function that is what the notification task actually calls, and in addition to the event info, it is also passed the real callback function, and the converter function extracts the information, and makes the needed call.

Note that in C, it is allowed to cast a void (*)(int) to void(*)() and then back to void (*)(int) again, so the registration table can use a generic function signature, and then the conversion function converts it back to the original signature to make the call.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists