ARM Development Tools
ULINK™ Debug Adapters
Development Tools by ARM
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.
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.
Thread-safe operation is a key factor in providing a robust and versatile operating system such as RTX.
of your data.