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 2007 Threads] Passing Status and Info between TasksPosted by PBXNewbie on July 19, 2007 If multiple tasks are trying to write to the same queue, do I need to do anything differently to protect these queue writes from context switches?
For example, say I have an application with multiple tasks, each gathering information from different sources. One additional task is responsible for reporting this information through a communications pipe. Can I create one queue that each of the producer tasks writes to and the consumer task reads from, or do I need to have multiple queues, one for each producer task?
If I also want to have a status variable that is accessed by each of these tasks, can I merely create a global variable and surround any reads and writes to this variable with: portENTER_CRITICAL(); // write to or read from global variable portEXIT_CRITICAL();
Thanks
RE: Passing Status and Info between TasksPosted by Richard on July 19, 2007 You can have multiple readers and multiple writers to a single queue with no problem. Tasks will block on queue reads and writes in their priority order. The kernel takes care of the multiple access issues for you.
Regarding the status variable. You can use the critical sections as you note in your post. This is only necessary if there are multiple writers to the variable, or if the data type of the variable is larger than the natural type of the machine (meaning accesses to the variable are not atomic). A task that just reads a variable of the natural type or smaller does not need the critical section
Regards.
RE: Passing Status and Info between TasksPosted by PBXNewbie on July 20, 2007 Thanks.
That makes life easy!
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|