REENTRANT TASKS
Applies to: RTX51 Real-time Kernel
Answer
Information in this article applies to:
QUESTION
I'm using RTX51 and I need to have 2 tasks call the same function.
How do I protect that function from being called simultaneously?
ANSWER
There are several solutions to this problem.
-
Duplicate the common code for each task and define 2 functions:
one for task 1 and one for task 2. While this is the best method
from a performance perspective, it is a maintenance nightmare. If
you use this method, be sure to document what you have done very
well. Another drawback is that your code size will increase by
double the size of the function.
-
Declare the function as "compact reentrant" and setup a compact
reentrant stack. Specifically, you must modify the STARTUP.A51 file
and setup the reentrant stack management. Then, modify the common
function as outlined in the C51 manual under "Specifying the memory
Model for a Function" and "Reentrant Functions". This method slows
down the execution time of the function as it must now manage the
reentrant stack with each function call. However, program
maintenance is now no more difficult than any other function.
SEE ALSO
Article last edited on: 2004-05-05 20:22:31
Rate this article
Disagree? Move your mouse over the bar and click