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] [January 2009 Threads] Question on xSemaphoreTake()Posted by Siheng Huang on January 7, 2009 I have a question on freeRTOS semaphore function:
xSemaphoreTake( xSemaphoreHandle xSemaphore, portTickType xBlockTime )
freeRTOS document says: "A block time of zero can be used to poll the semaphore". My question is what does the block time means and what happens after block time expires. There are two understandings:
1. The block time means the time period for task to poll the semaphore state. So after block time expires, the task continue to check if semaphore is available. If not, then task will check again after next block time expires.
2. The block is the max time task being block if the semaphore is not available. After block time expires, task will start to execute next instruction even if semaphore is not available.
Which understanding is correct?
if first understanding is correct, when using xSemaphoreTake( xSemaphore, ( portTickType ) 0 ) in one of my task and the semaphore/mutex is not available for a long time, I guess the task being block continue to run trying to poll semaphore state? If so, will lower priority task be block? This seems to defeat the purpose of using semaphore.
Thanks, Siheng
RE: Question on xSemaphoreTake()Posted by MEdwards on January 7, 2009 The block time is the maximum time the task will spend in the blocked state to wait for the semaphore. It does not execute at all when in the blocked state.
Take a look at the new book http://www.freertos.org/Documentation/FreeRTOS-documentation-and-book.html
RE: Question on xSemaphoreTake()Posted by Siheng Huang on January 8, 2009 Thanks, MEdwards, that answers my question.
Siheng
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|