Keil Logo

Thread-Safe Features of Keil RTOS and Middleware

All Keil RTOS and large parts of the Middleware libraries are thread-safe. This ensures all library code will run correctly during simultaneous execution by multiple threads. All processes can access shared data and multiple instances of library functions without the risk of undefined behaviour.

Thread-Safe Operation
Multiple tasks can safely call multiple library functions simultaneously.

Thread-safety in the middleware libraries is implemented by using a combination of methods:

Mutual exclusion control mechanisms such as semaphores ensure that deadlocks and race-conditions are avoided by limiting access to shared data. A new task may have to wait for a previous process to complete operation before it is allowed to use the shared resource.

Thread specific storage of variables means that there is no possible corruption of data across thread or sub-routine boundaries and ensures consistent RTX kernel operation.

Reentrant implementations of library routines allow a function that is partially completed in a stalled task to be safely called and re-entered from another task. Every instance of a re-entrant function is capable of saving and restoring its own execution status to ensure all instances will complete as expected regardless of interruptions. Standard library functions are not re-entrant by default.

Example of Reentrant Operation
Multiple threads may call the same function simultaneously (click for larger diagram).

Thread-safe operation is a key factor in providing a robust and versatile operating system such as RTX.

  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.