Keil Logo

RTX51: Reentrant Tasks


Information in this article applies to:

  • RTX51 Version 5

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.

  1. 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.
  2. 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


Last Reviewed: Thursday, February 25, 2021


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.