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

Side-effects of using semaphore without creating

Posted by gpathak on April 6, 2017

Hello Experts, I am using FreeRTOS version 8.1.2 on Realtek Ameba board. I have written a code where I am using xSemaphoreGive() and xSemaphoreTake() without creating the semaphore. I want to know what can be the issue of calling these functions without creating a semaphore.


Side-effects of using semaphore without creating

Posted by heinbali01 on April 6, 2017

Very often you will find out that FreeRTOS is lean: in many cases it assumes that parameters have been checked by you. The functions xSemaphoreGive() and xSemaphoreTake() must be called with a valid semaphore handle. If you want to let a task just block, you can use e.g. vTaskDelay().


Side-effects of using semaphore without creating

Posted by gpathak on April 6, 2017

Thanks for your reply @Hein Tibosch. I am not looking for Delaying and blocking a task.

I just want to know the pitfalls, can it cause a hardfalut or crash if xSemaphoreGive() and xSemaphoreTake() is called without creating a semaphore?


Side-effects of using semaphore without creating

Posted by richard_damon on April 6, 2017

Yes, calling any FreeRTOS function with an uninitialize handle has put your proogram into an undefined state and virtually anything can happen. If you are lucky, the call will fault and crash.

My general policy is to create ALL of my Queue, Semaphore and Mutexes that the program will need prior to starting the scheduler, so that it makes it much harder to have that problem.

An alternative is to make sure the handles are zeroed at startup and check the handle prior to making the call, skipping the call or creating the item if it is zero.


Side-effects of using semaphore without creating

Posted by rtel on April 6, 2017

Very often you will find out that FreeRTOS is lean: in many cases it assumes that parameters have been checked by you.

FreeRTOS is designed to keep the code size down. While you are developing checking is performed using configASSERT() (although it assumes things are zero'ed out), then when your code is ready for production, you define configASSERT() away and get smaller faster code - at which point you should make sure all your tests are still working.

SafeRTOS on the other hand has explicit validity checks in C, so everything is checked, all the time.


[ 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