DCE for the HP e3000 (B3821-90002)
Programming Notes
Threads Architecture
Chapter 4
42
Threads Architecture
This section describes the architecture of threads on MPE/iX.
The following terminology is adopted throughout the remainder of this document. The
term process refers to the MPE/iX operating system notion of process. The term task is
defined as a multi-threaded application (depending on the implementation, a task can
consist of a single process or multiple processes).
Threads on MPE/iX
A multi-threaded task on MPE/iX is implemented with multiple processes (one per
thread). A task’s threads are a cooperative processes in that they share some resources
that are normally private to a process. All threads within a task share the same SR 5
space as the initial thread (a process created using run or createprocess). The heap and
global variables are shared by all threads, along with loader information and system
information regarding open files and sockets.
All other process resources are private to the thread. Each thread has its own NM stack,
CM stack, pin number, PIB, PIBX, TCB, PCB, PCBX, process port, and so on. Fields
within these data structures that are shared among threads (such as, file system
information) are kept in a common location.
Process Management and Threads
An initial thread is a process created using run or createprocess (or fork and exec for
POSIX). The threads of a task cannot exist independently of the initial thread. If the
initial thread terminates or is killed, all of the task’s threads are terminated. A
secondary thread cannot be adopted by another task.
Each thread begins execution at an entry point specified at creation time. The entry
point is an MPE/iX procedure with one parameter. This procedure resides in either the
program file or the linked libraries of the task.
When a thread is created, the following attributes can be specified:
Stack size: NM stack size for the thread
Inherit scheduling: inherit the scheduling policies of the creating thread
Priority: priority of the thread
Scheduling policy: round robin, FIFO,...
Scheduling scope: priority is global/local
These attributes are required in order to be POSIX compliant. POSIX also permits each
implementation to add its own thread creation attributes. The following attribute was
added for MPE/iX:
Debug: enter debug before starting the thread
NOTE PH capability is required to create a thread.
From a process management point of view, thread creation is just an abbreviated form of
process creation.