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] [April 2008 Threads] RTOS V3.22 Semaphore does not work properly??Posted by Narayan on April 29, 2008 Dear all, I have a situation which I am trying to undertand. The scenario is something like below.
I have two tasks task_A and task_B A binary semaphore ABC is created.
task_A( ) { A(); delay 100ticks }
task_B( ) { B(); delay 100ticks }
A( ) { if(xSemaphoreTake( ABC, portMAX_DELAY ) == pdTRUE ) { // do something xSemaphoreGive( ABC ); taskdelay (25 ms; //Note delay here } else { printf("Task A Error"); } }
B( ) { if(xSemaphoreTake( ABC, portMAX_DELAY ) == pdTRUE ) { // do something xSemaphoreGive( ABC ); //Note NO delay here } else { printf("Task B Error"); } }
My setup is configured as 32bits, thereofre portMAX_DELAY will be large. However I see that I get errors "Task B Error".(and Task A error sometimes) Is it possible that the sempahore is timing out even with portMAX_DELAY or am I doing sonmething wrong here? Any insight will be appreciated. At he moment my workaround is while ((xSemaphoreTake( ABC, portMAX_DELAY ) != pdTRUE ), but I wnat to know what is wrong. -regards Narayan
RE: RTOS V3.22 Semaphore does not work properly??Posted by Richard on April 29, 2008 Its difficult to say, as you are using a rather old version (there have been 23 updates since V3.2.2!). There were some situation where a premature unblock was possible, and under certain circumstances the outer == TRUE was required, but I think this was to do with multiple tasks and interrupts accessing the same queue/semaphore. Do you have anything else accessing the semaphore, or just these tasks?
Can you update to a newer version?
Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|