08 - Processes (1)OutlineRecapConcurrencyProcess MemoryAnnouncementsReading: MOS 2.1RecapConcurrencyProcess MemoryA program is an executable file.A process represents a running program.One program can be instantiated as many programsConcurrency allows multiple processes to executewhile sharing a single CPU.Advantages:Process are distinguished by Process ID (PID)Note: processes using 0% CPU -> suspendedRequires CPU context switchGiven 4 processes on 1 CPUProcesses switch, sharing the CPU, while appearinglike multiple programs are running simultaneously.Each process has a context (state)Kernel needs to keep track of process context foreach process (Memory + CPU context).Virtual address spaces are exclusive.Kernel also runs in a virtual address spaceEach process has its own virtual memory> Address space:> Execution context:> OS resources (in kernel):Kernel has a scheduler to decide the next processto continue fromA running process (usually) has no awareness ofother running processes.Note: order of process execution is not fixed.- binary executable (or script, kind of)- process != program- an OS abstraction/container- contains all relevant memory and state- each with its own state- also called multiprogramming in the book- CPU runs one process at a time- kernel facilitates switching between processesIncrease CPU utilizationReduces Latency (response time)-----------------------No prepared statements.1)2)3)1)2)allows other processes to run while onewaits for I/O operations.short processes not blocked by long onespauses execution of one process, startsanotherusually a few milliseconds at a timescheduler runs at every chance kernel getsprogrammer should not make assumptions abouthow long processes take to execute- interleavings are generally not reproducible.we'll cover the scheduler later in the courseruntimes are difficult to measure empirically,requiring statistical approximation, carefulbenchmarking conditions, etc.Executable (code and data)Program counter (PC)Stack pointer (SP)CPU RegistersOpen filesNetwork connectionsHeap (dynamically allocated)Stack (local variables, args)no access to other process memoryvalue at an address in one process is differentat the same address in another processnot necessarily implemented in every OSit can still access other program memory spacesrelies on hardware MMU for some translationisolation for security/reliability/abstractionproc 1proc 1proc 1proc 1proc 2proc 2proc 1proc 1proc 2proc 2proc 1proc 1proc 2kernelproc 2proc 1proc 2proc 2proc 2wait for input...80s20s20s70s10svs.1 done1 done2 done2 doneLinux:ps -elfps -elfWindows:MacOS:Process SwitchingMental ModelsorProcess ExplorerActivity Monitorperformed by kernel and hardwareproc 1 suspendedkernel performs switchproc 2 resumesororetc.MOS Figure 2-1stackheapbssdatatextProgram Memory0xFFFFFFFF0x00000000Address space contains:Reality:Viewing memory map:- Text: program code- Data: initialized global vars- BSS: uninitialized global vars- Heap: dynamically allocated vars- Stack: local vars- Libraries shared- ASLR (layout randomization)Section order not preservedSysinternals VMMapvmmap <pid>Windows:MacOS: