Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

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


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists