The Players

   

There was a time when the process was the smallest schedulable entity of concern to the kernel; today, however, that honor belongs to the thread. Before we discuss HP-UX kernel structures in depth, we must define the relationship between programs, processes, and threads.

The Program

The term program refers to a file that stores an executable image. A program file contains a header record defining the architecture for which it was compiled, magic numbers, and a list of system resources it will require access to during its execution life cycle.

The first HP series 800 computers were based on the then newly developed 32-bit HP Precision Architecture (PA-RISC 1.x) chip set. This product line was called the Spectrum computing platform. The linking-loader for this architecture used a proprietary header format called the Spectrum Object Module, or SOM. With the advent of the 64-bit HP Precision Architecture (PA-RISC 2.0), the loader format adopted was the POSIX Executable Linking Format (ELF) definition. For compatibility reasons, all 32-bit executables on HP PA-RISC platforms continue to use the SOM format, and 64-bit executables use ELF.

The memory management portion of the kernel also refers to program files as the front store. Since the program file contains static images of the program's text (or code) pages, the kernel paging system makes use of these if it needs to page-out any of the program's text once it has been loaded into physical memory. This negates the need to allocate a storage location from the system's swap space (a.k.a. back store) for a program's text pages. As the paging system relies on access to these page images as long as the process is active, the program file must be held in an open state for as long as the program is in use. Paging and swapping are discussed in greater detail in Chapter 6, "Managing Memory."

The Process

In the world of HP-UX, the term process is used to define all the parts that make up an active program on the system that is, one that is currently being allowed to utilize system resources and perform work on the behalf of a user. Think of a process as a type of container used to organize and manage a task. It keeps track of what is being used, what is required to perform the task at hand, priority and scheduling information, and what permissions and authorizations have been granted to the process. In addition, the process keeps tally of processor time used, the amount of I/O performed at the request of the process, the state of pending signals sent to the process, and many other related operational parameters.

A process exists once there is a valid entry in the kernel process table (or proc table, as we call it in this book; see Figure 4-1). This table entry ties the process to all of its allocated system resources and is truly the nexus of the process's view of the kernel throughout its life cycle.

Figure 4-1. Static versus Dynamic proc Tables

graphics/04fig01.gif


Prior to the release of HP-UX 11.i, the proc table was a static table, and its size was defined by the system-tunable parameter nproc. The table was an array of data structures of type proc whose starting point was accessed through the kernel pointer proc*. When the table was full, no additional programs could be launched on the system. Increasing the number of allowable processes required a rebuild of the kernel. The current trend is to make many kernel structures dynamic in order to reduce the need to rebuild the kernel (and the number of reboots).

Starting with HP-UX 11.i, the proc table became a dynamic linked list (see Figure 4-1). This arrangement allows for proc table entries to be created on demand and dynamically linked into the list of active processes on the system. Access to the first proc table entry is now made by following the kernel pointer proc_list*. Each table structure is still defined as a proc (note that this structure definition has changed significantly since previous releases), which now contains the linkage pointer p_next* to the next proc table entry.

The kernel-tunable parameter nproc is still used, but its purpose has changed somewhat: it is now used to define a maximum number of allowable proc table entries that may be created on the system. The kernel contains many static lists, which need to be sized large enough to handle the kernel's worst-case needs. The nproc parameter has been used to help in this task during kernel initialization. Until these tables also become dynamic structures, a parameter like nproc will be required.

The process has long been the workhorse of the HP-UX runtime environment. With the release of HP-UX 10.0 came the introduction of the thread as the schedulable entity.

The Thread

A thread is an instance of execution of a process's code and is scheduled by the kernel. A single process may employ a single thread or several threads depending on its programming. A thread is running either in kernel thread or user thread mode depending on whether it is executing code from the process's text or from privileged areas of the kernel code known as system calls.

Each thread requires an active entry in the kernel thread table. Thread table entries are created on demand and are defined by the structure kthread. All the threads spawned for a process are said to be siblings, and their individual thread table entries are formed into a linked list using entries in their respective kthread structures. The parent process has linkage pointers in its proc structure to the first and last kthread elements in this list (see Figure 4-2). The parent proc table entry also contains a count of threads it has created, p_threads_created; this counter is set to 0 with the creation of the process's initial thread and incremented for each additional sibling spawned.

Figure 4-2. Linking Threads to Their Process

graphics/04fig02.gif


In addition to the proc-to-kthread linkages, all the active threads on the system are linked together to form an active thread list.

As was the case with the proc table, in HP-UX 10.x releases the thread table was also a static table. The kernel pointer to the first kthread was kthread*, and the number of entries in the thread table was stored in kthreadNKTHREAD, which was set equal to nproc. As with the proc table at HP-UX 11.i the thread table has also been converted to a dynamic list.



HP-UX 11i Internals
HP-UX 11i Internals
ISBN: 0130328618
EAN: 2147483647
Year: 2006
Pages: 167

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net