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] [January 2005 Threads] C18 ReentrancyPosted by Nobody/Anonymous on January 11, 2005 Since C18 isn't reentrant, won't the rtos cause problems if the same function is called in two different tasks?
Do I have to take care of this myself?
I'm particularly thinking about things like sprintf and the math library. I don't think the C standard guarantees reentrancy.
RE: C18 ReentrancyPosted by Nobody/Anonymous on January 11, 2005 I have been investigating C18 re-entrancy, and I'm getting more confused by the minute :-)
From the manual: "MPLAB C18 supports parameters and local variables allocated either on the software stack or directly from global memory. The static keyword places a local variable or a function parameter in global memory instead of on the software stack.1 In general, stack-based local variables and function parameters require more code to access than static local variables and function parameters (see Section 2.3.2 static Function Arguments). Functions that use stack-based variables are more flexible in that they can be reentrant and/or recursive."
Still searching........
RE: C18 ReentrancyPosted by Richard on January 11, 2005 The areas of global memory used by the compiler are saved as part of the task context so you need not worry about these directly - only to ensure that the correct number of bytes are stored as per the WEB documentation.
There are some library functions that are very rarely reentrant. malloc(), free(), strtok() for example. Also anything that uses errno if that is of concern to you. You always need to take care when using these. If in doubt you can suspend and resume the scheduler around a function call - this will allow interrupts to be processed but guarantee that a context switch does not occur.
sprintf may struggle on a PIC as it normally uses a fair amount of stack.
The section from the manual you quote seems to refer to your own function parameters and the C standard use of the static modifier. The problem with the C18 is it's use of memory when performing simple routines like adding two integers.
I am going to get the latest C18 version and see how things are different.
Regards.
RE: C18 ReentrancyPosted by Richard on January 11, 2005 Just for completion - from the other thread:
"With the new version, the MATH_DATA and .tmpdata sections are the same size, suggesting they are used in the same way. Having just compiled and run the first and third FreeRTOS.org demo applications they appear to execute correctly with V2.4."
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|