But even if you have a multi-processor (SMP) system, there will always be more tasks than processors on your system, so switching is still required.
A thread is &os2;'s unit for administrating task switches. A program can contain several threads, but per definition, it will have at least one. But since a program can have more than one thread, switching can take place even between threads in the same program. This is called multithreading. As opposed to many other operating systems, &os2; fully supports this, and it even does so in a very fancy and reliable way.
The part of the &os2; kernel which switches between threads is called the "scheduler".
The term "thread" was chosen because within one thread program instructions are executed sequentially, while between threads you may never be sure which instruction of one thread will be executed before or after an instruction of another thread. It is only &os2; which keeps switching between threads without the thread even knowing about it (or, on SMP systems, threads might actually run concurrently on several processors).
Well-programmed software uses several threads to ensure that the user gets a quick response to his input and mouse actions. For example, if you execute a command in a program which will take a long time, a program should start a secondary thread for this task. While this new thread is working in the background, the user interface (on the main thread of the program) is ready again for new input.
Not-so-well-programmed software uses only one thread for both the user interface and executing tasks. As a result, while executing a task, the user interface is blocked.
Threads can have different priorities. See "Thread priorities" for details.
On the other hand side, a process is the &os2; term for an application which has been loaded into memory. Each process must have at least one thread.
Each process contains common data as well as controls access to system resources. Processes are protected against each other in that &os2; prohibits access to memory which does not belong to the process attempting to access it ("memory protection").
By contrast, several threads within a process may all access the process's memory, because memory is administered on a per-process basis. The same applies to other system resources such as open files.
To summarize: A thread is the &os2; kernel concept for managing CPU ownership. By contrast, a process is the concept for owning everything else: files, devices, and memory.
For more information, select from the following list: