| United States-English |
|
|
|
![]() |
DCE for the HP e3000: HP e3000 MPE/iX Computer Systems > Chapter 3 Threads Architecture on MPE/iXThreads 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). 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. 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: 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:
From a process management point of view, thread creation is just an abbreviated form of process creation. All threads are created as siblings. The threads of a task all have the same father task; namely, the father of the initial thread. If a thread creates a child using creatprocess, that child is the child of the task, not of the thread. From the tasks child-point-of-view, its father is the initial thread. When a thread exits, the children and the threads it created are not terminated. Threads do not "own" the child processes they create. However, threads may find it necessary to wait for the termination of the offspring that they created. Therefore, a thread is permitted to wait for a specific child to terminate and is permitted to wait on the termination of any child. Refer to the suspend and activate intrinsics for more explanation. While threads are implemented with multiple processes, to the end user threads should appear to coexist within a single process. Process management hides the MPE/iX implementation of threads from the programmer. The process handling intrinsics work on a task basis. This section discusses the development, debugging, and execution of applications that use threads on MPE/iX. It should be read before attempting to create or run an application that uses threads. Debug has the following features to facilitate debugging in a threaded environment: There are three types of breakpoints available when debugging a threaded program:
The syntax for the address and pin parameters to breakpoint commands includes the specification: logaddr [:pin|:@] and the following for threads: logaddr [:[[init_thread_pin].tin |.@][:@]] where tin is the thread number returned by pthread_create. The pin number of the initial thread can be obtained using SHOWPROC. The syntax [init_thread_pin].tin specifies a thread, [init_thread_pin].@ specifies a task-wide breakpoint, and :@ following a [init_thread_pin].tin specification specifies a stop-all-threads breakpoint option. For example:
The following commands aid in debugging threaded applications.
There are two environment variables that simplify debugging applications:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||