2.1 Processes P.85
Processes are programs in execution, with their physical manifestation including memory pages containing data and instructions, hardware register values, program counter value, and more. Processes are in three states: running, ready, or blocked. Processes can be created by duplicating an existing process, except for the init process which is started directly by the kernel. In UNIX, a child process is created every time a command is typed at the shell. Processes can create child processes, which often work in conjunction with the parent process. A running process can be running in user mode or running in kernel mode. When a process dies, UNIX reassigns the parent PID of each of its children to the init process. The OS contains a virtual potpourri of data structures, one of which is the Process Table. The service routine is responsible for noticing which processes were blocked because a new event had been unavailable, and processes which were waiting for only that particular event would then have their state changed from 'sleeping' to 'ready'.
Open
2.21 Thread Basics P 97
Threads are closely-cooperating entities that share the same memory space. When multiple threads are created, they share a common address space but have their own program counter, register values, and stack for the called procedures. Threads must be written carefully to ensure they do not harm other threads. Using several threads of execution on a multi-processor system may commandeer several CPUs simultaneously while on a single-CPU system, it may not speed things up. However, in some situations, threads may still provide a win, especially when programming a task that first requires a lot of number-crunching and then searching through a huge file to apply the results to that file. Creating threads is less expensive than forking a process since a thread mostly shares existing resources. The issue of whether to implement threads in user space or kernel space has various arguments for and against.
Open