|
Technical Support Support Resources Product Information | RTX51: REENTRANT TASKS
Information in this article applies to:
QUESTIONI'm using RTX51 and I need to have 2 tasks call the same function. How do I protect that function from being called simultaneously? ANSWERThere 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 ALSOLast Reviewed: Wednesday, May 05, 2004
|
|