FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [November 2008 Threads] xSemaphore scope question SAM7_EMACPosted 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_EMACPosted 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_EMACPosted 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_EMACPosted by Dave on November 26, 2008 I'm with you there. I think this code results from an anal aversion to using global variables.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|