斗★ ★长 Chapter 2: Process/Thread ★★ Instructor. HengmingZou, Ph. D n Pursuit of absolute Simplicity求于至简,归于永恒
1 Chapter 2: Process/Thread Instructor: Hengming Zou, Ph.D. In Pursuit of Absolute Simplicity 求于至简,归于永恒
★ Content ¥ 斗 ★★ ≈ Processes s Threads o Inter-process communication o Classical IPC problems o Scheduling
2 Content Processes Threads Inter-process communication Classical IPC problems Scheduling
★ Definition of a process ¥ 斗 ★★ s Informal A prog amin execution A runningpiece of codealongwith all the things the progam can read/write ≈Foma One or more threadsin their own addressspace o Note that process!= program
3 Definition of A Process Informal – A program in execution – A running piece of code along with all the things the program can read/write Formal – One or more threads in their own address space Note that process != program
★ The need for process ¥ 斗 ★★ o What is the priniple motivation for inventing process Tosupportmultiprogamming
4 The Need for Process What is the principle motivation for inventing process? – To support multiprogramming
★ The Process model ¥ 斗 ★★ o Conceptual viewing of the processes o Concurrency Multiple processesseemto run conaumently But in reality only one activeatany instant s Progress Every processmakes progress
5 The Process Model Conceptual viewing of the processes Concurrency – Multiple processes seem to run concurrently – But in reality only one active at any instant Progress – Every process makes progress
★ Multiprogrammingof 4 programs ¥ ★ One program counter Four program counters AProcess switch B A B D B D Time Programs in memory Conceptual view Time line view
6 Programs in memory Conceptual view Time line view Multiprogramming of 4 programs
★ Process Creation ¥ 斗 ★★ Principal events that cause process creation 1. System initialization 2. Execution of a process creation system 3. User request to create a new process
7 Process Creation Principal events that cause process creation 1. System initialization 2. Execution of a process creation system 3. User request to create a new process
★ Process Temination ¥ 斗 ★★ Conditionswhich teminate processes 1. Nomal exit(voluntary) 2. Error exit(voluntary) 3. Fatal error(involuntary) 4. Killed by another process (involuntary)
8 Process Termination Conditions which terminate processes 1. Normal exit (voluntary) 2. Error exit (voluntary) 3. Fatal error (involuntary) 4. Killed by another process (involuntary)
★ Process hierarchies ¥ 斗 ★★ o Parent creates a child process o Child processes can create its own process o Processes creation foms a hierarchy UNdX callsthis a"processgroup Windowshasno concept of such hierarchy, i.e. all processesare createdequal
9 Process Hierarchies Parent creates a child process Child processes can create its own process Processes creation forms a hierarchy – UNIX calls this a "process group" – Windows has no concept of such hierarchy, i.e. all processes are created equal
★ Process states ¥ 斗 ★★ o Possible process states running blocked read Running Process blocks Scheduler picks for input another process Scheduler picks this process Blocked Ready Input becomes available
10 Process States Running Blocked Ready Possible process states – running, blocked, ready Process blocks for input Scheduler picks another process Input becomes available Scheduler picks this process