FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [July 2012 Threads] Event LoopPosted 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 LoopPosted 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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|