Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

Using xSemaphoreTake without vTaskDelayUntil

Posted by Craig on May 8, 2013
I am using FreeRTOS Ver 7.1.0.
Does xSemaphoreTake() allow other tasks to run if the task its being called from does not use vTaskDelayUntil()?
It doesnt appear to. No other tasks will run. I have a high priority task that needs to run and handle I2C traffic, this tasks needs to delay little as possible, < 2 msec. There are other, lower priority threads that need to run as well. I was hoping that these other threads would get a chance to run during xSemaphoreTake() but they dont unless I use vTaskDelayUntil().
Thanks

RE: Using xSemaphoreTake without vTaskDelayUntil

Posted by Dave on May 8, 2013
If you specify a block time in your call to xSemaphoreTake() and the semaphore is not available then the calling task will block and let lower priority tasks run just as if you had called vTaskDelayUntil(). If the semaphore is always there when you call xSemaphoreTake() then the the call to xSemaphoreTake() will always return immediately and the calling task will not block and starve lower priority tasks of CPU time.

RE: Using xSemaphoreTake without vTaskDelayUntil

Posted by Craig on May 8, 2013
There must be something I am missing then. I block indefinitely when I call xSemaphoreTake() with portMAX_DELAY.
I know there are 4 msec periods of time where other low priority tasks should run but they never get called unless I am using vTaskDelayUntil() in my high priority thread that calls xSemaphoreTake().
Right now I just have one other task that blinks an LED every 75 msec. It is easy to see this thread never gets called.
Is there anything else I should be doing?
Thanks.

RE: Using xSemaphoreTake without vTaskDelayUntil

Posted by Craig on May 8, 2013
Let me clarify. There are times where xSemaphoreTake() is called and there will not be an interrupt giving the semaphore back for 4 msec. This is when I expect my LED blink task to run.

RE: Using xSemaphoreTake without vTaskDelayUntil

Posted by Dave on May 8, 2013
If you are absolutely sure that the task taking the semaphore does block for up to 4ms at a time, then other tasks should run during those 4ms. You can verify that what you think is happening is actually happening by using the FreeRTOS+Trace tool. As a quick and dirty you can call xTaskGetTickCount() before calling xSemaphoreTake(), and then again after calling xSemaphoreTake(), and check that the difference between the two readings is sometimes greater than 1 (indicating that it was blocked for at least one tick period).

What is configTICK_RATE_HZ set to?
Are you sure your other tasks are running as you expect when the task that calls xSemaphoreTake() is not created?
Is the timing of your system about what would be expected for your configuration - so if you only create the LED blink task does the LED blink at the rate you specify?

RE: Using xSemaphoreTake without vTaskDelayUntil

Posted by Craig on May 8, 2013
You are correct, xSemaphoreTake() would get the semaphore right away due the fact I was enabling the I2C interrupt right before this call and never clearing the interrupt so it would fire right away.
Thanks for the help.


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


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

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

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner