7.1. Processes: From Early UNIX to Mac OS XThe process abstraction has long been used to represent various activities in a computer system. In early UNIX, a process could be running a user program, or it could represent one or more flows of control in the kernelfor example, process 0 ran sched(), the process scheduler. The only way to create a new process in traditional UNIX was through the fork() system call, and the only way to run a new program within a process was through the exec() system call.
As compared to modern operating systems, early UNIX had a vastly simpler process abstraction. In fact, it wasn't until UNIX was rewritten in Cand ran on a PDP-11 with an MMUthat the UNIX kernel could have more than one process in memory at a time. Consider the proc structurea kernel-memory-resident process bookkeeping data structurefrom Third Edition Research UNIX (circa early 1973): struct proc { char p_stat; /* (SSLEEP, SWAIT, SRUN, SIDL, SZOMB) */ char p_flag; /* (SLOAD, SSYS, SLOCK, SSWAP) */ char p_pri; /* current process priority */ char p_sig; /* most recent interrupt outstanding */ char p_ndis; /* index into priority "cookie" array */ char p_cook; /* cookie value */ int p_ttyp; /* controlling terminal */ int p_pid; /* process ID */ int p_ppid; /* parent process ID */ int p_addr; /* address of data segment, memory/disk */ int p_size; /* size of data segment in blocks */ int p_wchan; /* reason for sleeping */ int *p_textp; /* text segment statistics */ } proc[NPROC]; The value of NPROC, the number of entries in the process table, was set at compile timea typical value was 50. Besides program text and data, each process had kernel-mode stack and a data areathe user structure or the u-area. There could be only one current process. 7.1.1. Mac OS X Process LimitsAs is the case with modern operating systems, the Mac OS X kernel has soft and hard limits on the number of processes allowed. The hard limit is either more than or equal to the soft limit. The hard limit is set at compile time and cannot be varied. The soft limit can be varied through the sysctl interface by setting the value of the kern.maxproc variable. $ sysctl -a | grep proc kern.maxproc = 532 kern.maxfilesperproc = 10240 kern.maxprocperuid = 100 kern.aioprocmax = 16 kern.proc_low_pri_io = 0 ... The hard limit is computed at compile time using the following formula: // bsd/conf/param.c #define NPROC (20 + 16 * MAXUSERS) #define HNPROC (20 + 64 * MAXUSERS) int maxproc = NPROC; __private_extern__ int hard_maxproc = HNPROC; /* hardcoded limit */ The MAXUSERS value is defined per Table 71 in a configuration file in the BSD portion of the kernel. The standard Mac OS X kernel is compiled in a medium configuration, with MAXUSERS being 32. The corresponding values of NPROC and HNPROC are 532 and 2068, respectively.
However, the difference in the number of maximum processes allowed between early UNIX and Mac OS X is insignificant compared to the differences in the respective compositions of their process subsystems. Even though modern systems are expected to be considerably more complicated, it would not be much of an exaggeration to say that the term process has more connotations in Mac OS X than there were fields in the Third Edition UNIX process structure! 7.1.2. Mac OS X Execution FlavorsCode can execute in Mac OS X in several environments, where environments are differentiated based on one or more of the following: machine architecture, executable format, system mode (user or kernel), miscellaneous policies,[4] and so on. Each environment has its own flavor of execution. Here are examples of such environments:
Figure 71 shows a conceptual view of the process subsystem's composition in Mac OS X. Despite the presence of numerous process-like entities on Mac OS X, exactly one abstraction executes on a processor: the Mach thread. All other process-like entities are eventually layered atop Mach threads. Figure 71. An overview of the Mac OS X process subsystem |