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] [September 2007 Threads] 2 sources that 'give' the same interruptPosted by biker126 on September 28, 2007 hey guys
does anyone know if it is possible to have a semaphore taken by 1 task and given back by 2 different sources?
in the demo's semaphores are used for synchronisation between 1 task and 1 ISR. but i'd like to synchronize a task with TWO ISR's.
so my idea was that the task does a xSemaphoreTake( xSemaphore, WAIT_TIME);
and ISR1 and ISR2 both do: xSemaphoreGiveFromISR( xEMACSemaphore, pdFALSE );
but i dont know what happens if the semaphore is currently 'free' and the function above is called... (would be nice if there's a function to check wether the semaphore is in use or not. but afaik there aint such a function).
if there would be event-flags available in freeRTOS i would use that but since there are none i need something different... ;-)
greets D. Holzwarth
RE: 2 sources that 'give' the same interruptPosted by Richard on September 28, 2007 There is no problem in giving from two different locations in this manner.
The xSemaphoreGiveFromISR() would have been better constructed if its return told you whether or not the give was successful.
Binary semaphores are just queues with a length of 1. You could therefore easily write a function/macro to see if the semaphore is currently taken or not - something like the uxQueueMessageWaiting() function, but without the critical section so it can be used from an ISR. For example (untested code):
unsigned portBASE_TYPE uxGetSemaphoreStatusFromISR( xSemaphoreHandle pxSemaphore ) { return pxSemaphore->uxMessagesWaiting; }
If this returns 0 then the semaphore can be given, but not taken, and visa versa.
Regards.
RE: 2 sources that 'give' the same interruptPosted by biker126 on September 30, 2007 its good to know that you can release a semaphore twice :-)
I solved my current synchronizing problem with a queue tho (instead the semaphore) which is filled by the 2 sources.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|