Quality RTOS & Embedded Software

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


Loading

xSemaphore scope question SAM7_EMAC

Posted by Chris Strahm on November 25, 2008
In the lwIP 1.30 port with SAM7X, there are files:

"SAM7_EMAC.c"
"SAM7_EMAC_ISR.c"

There is the same variable defined local in both files: xSemaphore

/* The semaphore used by the EMAC ISR to wake the EMAC task. */
static xSemaphoreHandle xSemaphore = NULL;

It seems like this variable is suppose to handle the communication between the ISR and regular code. But since the variable is called out local in both, I don't quite see how that could happen. Code from either module is going to access different variables.

Is this actually correct? If so I would recommend naming the two variables different to avoid confusion.

Chris.




RE: xSemaphore scope question SAM7_EMAC

Posted by Dave on November 26, 2008
The semaphore is created in one file, then its value is passed into the other file during the initialization. Although there are two variables, they both hold the same value which is just a pointer to the semaphore structure.

RE: xSemaphore scope question SAM7_EMAC

Posted by Chris Strahm on November 26, 2008
Thanks for the explanation. Seems like an odd way of doing things. In my port I think I will change this to declare the var global in emac.c, then extern in emac_isr.c, and eliminate the copy function. It wastes RAM to save 2 copies of the same var, and it wastes ROM on the copy function.

RE: xSemaphore scope question SAM7_EMAC

Posted by Dave on November 26, 2008
I'm with you there. I think this code results from an anal aversion to using global variables.


[ 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