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] [December 2008 Threads] take & give semaphorePosted by Martin Velek on December 11, 2008 Hello,
is there a simple way, how to achieve this functionality?
void interrupt_handler_timer_A(void) { xSemaphoreGiveFromISROnlyIfSemaphoreWasTakenBefore(xSemaphore); }
void TaskA(...) { startTimerA(); stopTimerA(); xSemaphoreTake(xSemaphore); exit(1); // we should never get here
}
I mean that the interrupt handler can give semaphore only if was taken before. In other cases it skips it.
Thank you for help
Martin
RE: take & give semaphorePosted by Richard on December 12, 2008 You could do something like this:
if( xQueueIsQueueEmptyFromISR( (xQueueHandle) xSemaphore ) { ____xSemaphoreGiveFromISR( xSemaphore ); }
be careful of race conditions though.
I don't understand the comment "// we should never get here" in your sample task code. It looks like you would get there as soon as the semaphore was available.
Regards.
RE: take & give semaphorePosted by Martin Velek on December 12, 2008 Hi Richard,
thank you for answer. The comment "// we should never get here" means, that by function stopTimerA() disables generating Timer interrupt.
Amazing function xQueueIsQueueEmptyFromISR. Exactly what I need. I didn't find it in documentation :( ... I would be glad if something like MicroC/OS-II was written about FRT.
BR Martin
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|