Quality RTOS & Embedded Software

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


Pointer to a semaphore handle?

Posted by Scott Nortman on January 19, 2007
Will the following work:

/*------- start of c file ----------*/

static xSemaphoreHandle *localSemPtr;

void init_peripheral( xSemaphoreHandle *semPtr ){

____localSemPtr = semPtr;

____vSemaphoreCreateBinary( *localSemPtr );


ISR( INT0_vect ){

____xSemaphoreGiveFromISR( *localSemPtr );


RE: Pointer to a semaphore handle?

Posted by Richard on January 20, 2007
If I can interpret what it is you are trying to do.

You have a peripheral that uses a semaphore, presumably for synchronisation. The semaphore is created externally from the peripheral driver and a reference to it is passed into the peripheral driver.

I think this should work, but you can pass semaphore handles by copy. You don't need to pass them by pointer.

static xSemaphoreHandle xLocalSem;

void init_peripheral( xSemaphoreHandle xSem )
____xLocalSem = xSem;

ISR( INT0_vect )
____xSemaphoreGiveFromISR( xLocalSem );


This is because the semaphore handle is only a reference to the semaphore. It is not the entire semaphore structure.

Take a look at the files serial.c and serialISR.c in the FreeRTOS\Demo\ARM7_STR75x_GCC\serial\serial.c file for an example that uses queue handles (same thing really). The function vConfigureQueues() is used to pass the handles to queues created in the serial.c file into the serialISR.c file. The latter file contains the ISR function in which the queues are used.


[ 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.

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.


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


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