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] [March 2009 Threads] Binary Semaphore runs on task initialisingPosted by phil on March 31, 2009 Hi,
I have created a binary semaphore in my module initialization code:
vSemaphoreCreateBinary( xBinarySemaphoreRxMsg );
It initializes ok, I then create a new task to run:
xTaskCreate( vRX_MsgHandlerTask, "RX", MSG_TASK_STACK_SIZE, NULL, xTask_Priority, NULL );
All ok, here is the basic task code:
void vRX_MsgHandlerTask( void *pvParameters ) { unsigned portSHORT i; //unsigned portSHORT usFrameIndex;
ulMsgCounter = 0;
for( ;; ) { //blocking for RX event to happen xSemaphoreTake( xBinarySemaphoreRxMsg , portMAX_DELAY );
TRACE_sprintf("Processing the Data\r\n"); } }
Now when the vRX_MsgHandlerTask starts for the first time the TRACE_sprintf("Processing the Data\r\n"); is called and outputs to the console. I am pretty sure there has been no call to xSemaphoreGive( xBinarySemaphoreRxMsg ); it is as if the binary semaphore thinks it can take the semaphore, the code runs as expected after this has happened.
Is this a school boy error, hope you can help.
Phil
RE: Binary Semaphore runs on task initialisingPosted by David Hawks on March 31, 2009 The semaphore starts out available to be taken (check out the definition of "vSemaphoreCreateBinary" in "semphr.h"). You must take it first outside of your task's loop if you don't want it to be available when your loop first runs.
RE: Binary Semaphore runs on task initialisingPosted by phil on March 31, 2009 Thanks for the quick response that fixed the problem. :)
Phil
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|