10 - Processes (3)OutlineProcess TerminationKernel Data StructuresProcess Switching (again)Modeling MultiprogrammingAnnouncementsReading: MOS 2.1Process TerminationProcesses can terminate in 2 ways:Killing ProcessesUNIX: Child processes do not die with parent.Process Control Block (PCB)Typical PCB fields:We'll take a look at Linux PCB in the next lectureIn short:Timing:A little bit of math to calculate CPU utilization.CPU utilization information helps business makedecisions about how many machines to purchase,quality of service, etc.Big assumptions:How to increase utilization?Oversimplified Example:Remember:Process TableHuge struct that holds all information about aprocessArray of PCBs maintained in kernel memorykernel called (interrupt or syscall)PIDs are indices into process tablekernel saves state to PCBkernel handles interrupt/does syscallscheduler runs and selects processkernel restores selected process from PCBKernel switching should be as fast as possible!Single-core CPURun more processes (increase n)All processes identical characteristicsMinimize I/O-bound tasks in programhardware support is necessary to savethe program counter.Multiple cores => less process switchingaka. "Process Table Entry"Aside:Modeling MultiprogrammingKernel Data StructuresProcess SwitchingWorking on autograder still, sit tight.Planning to release PA3 late next week.1)2)3)4)------------------->>>>Voluntary: using exit syscallChild processes must be killed separately(or via process groups)Orphan processes are adopted by initInvoluntary: signals using kill syscallWindows has some equivalent syscalls.Signals are integer codes that are delivered to a process by thekernel for basic inter-process communication.Process can register handlers for some of these, but mostautomatically kill the process.- Kernel should run for microseconds, user process for milliseconds.- Maximize the amount of useful work (kernel only manages).- Kernel fast enough that people don't notice delaysUser program calls exit to voluntarily terminate execution.Normal exit (status code zero)(return 0 from main automatically calls exit)Fatal errors (e.g. segfault, invalid instruction) cause trap tokernel, kernel sends signal that kills processRequires ownership by same user, or admin privilegesKernel sends signalError exit (status code non-zero)Process sends signalman signalUNIX-based:Zombie process is a dead child that hasn'tbeen acknowledged by parent.(parent must call wait() to receive status)see MOS Figure 2-4Process ManagementMemory ManagementFile Management- Registers- Program Counter- Stack pointer- Program status word- Process state- Priority- Scheduling params- Process ID- Parent process- Process group- Signals- Start time- CPU time- Child CPU time- Next alarmSegment info pointers:- Text info pointer- Data info pointer- Stack info pointer- Root directory- Working directory- File descriptors- User ID- Group IDsave state to PCB 0save state to PCB 1load state from PCB 1load state from PCB 0P0KernelP1handle interrupt/do syscall;scheduler runshandle interrupt/do syscall;scheduler runsinterruptor syscallinterruptor syscallrunningrunningrunningreadyreadyready or blockedready or blockedCPU Utilization:% CPU time spent doing usefulwork.probability that a process is waiting onI/O at any give point in timedegree of multiprogramming (number of userprocesses simultaneously alive)- OS requires 128 MB memory- Processes also require 128 MB memory- Processes have 80% I/O wait time- 512 MB RAM => 3 processes => 48.8%- 1024 MB RAM => 7 processes => 79.0%- 2048 MB RAM => 15 processes => 96.5%- 4096 MB RAM => ...For a machine with:- Machine has 4 GB RAM- OS requires 512 MB memory- Identical processes require 256 MB memory- Target: 99% CPU utilizationWhat is the maximum tolerable I/O wait timefor a process?approximated as measured percent of time waiting on I/Oin practice, a lot of statistics need to be collected to geta good estimate of p and nthis hurts performance of individual processes -> QoS issuefundamental limitations based on the nature of the processapproximated from probability that the CPU is doing useful workat any given point in time.MOS Figure 2-6pPollEvExercisenassume:- processes act the same- single core cpuexit(status)wait(&status)return value