2.2. Writing reentrant and thread-safe code

The ARM C libraries support multithreading, for example, where you are using a Real Time Operating System (RTOS). When describing multithreading in the rest of this section, the following definitions are used:

Threads

Mean multiple streams of execution sharing global data between them.

Process

Means a collection of all the threads that share a particular set of global data.

If there are multiple processes on a machine, they can be entirely separate and do not share any data (except under unusual circumstances). Similarly, each process might be a single-threaded process or might be divided into multiple threads.

Where you have single-threaded processes, there is only one flow of control. In multithreaded applications, however, several flows of control might try to access the same functions, and the same resources, concurrently. To protect the integrity of resources, any code you write for multithreaded applications must be reentrant and thread-safe.

Copyright © 2007 ARM Limited. All rights reserved.ARM DUI 0349A
Non-Confidential