index.md (2126B)
1 +++ 2 title = 'Process model' 3 +++ 4 # Process model 5 **process:** program in execution (amount of processes depends on the program) 6 7 it’s an abstraction that allows OS to simplify resource allocation, accounting, and limiting. 8 9 ## Process table 10 OS maintains info on resources and internal state of every process 11 12 information in Process Table: ID (PID), User (UID), Group (GID), memory address space, hw registers, open files, signals, etc. 13 14 process control blocks: 15 16 ![screenshot.png](23974f8c561b0cddc2bc33aca9f237de.png) 17 18 ## Concurrent processes 19 20 in principle, multiple processes are mutually independent (they have nothing at all in common). need explicit means to interact with each other. 21 22 the CPU gets allocated to each process in turn 23 24 - on OS level: save context of process A (program counter, registers, etc.), switch to B. to go back to process A, simply restore context. 25 26 OS (normally) offers *no timing or ordering guarantees* 27 28 ![](f6c6156909b358184921daccb51cdf1c.png) 29 30 ## Process hierarchies 31 OS creates only 1 init process (usually) 32 parent process can create a child process 33 results in a tree-like structure and process groups 34 35 ## Process management 36 fork: create new process 37 38 - child is 'private' clone of parent 39 - shares *some* resources with parent 40 41 exec: execute new process image 42 43 - used in combination with fork 44 - replaces the current command 45 46 exit: cause voluntary process termination 47 48 - exist status returned to parent process 49 50 kill: send signal to process (or group) 51 52 - can cause involuntary process termination 53 54 ## Process states 55 OS allocates resources to processes 56 three process states: 57 58 - running: process is currently executed by CPU 59 - blocked: process is waiting for available resources 60 - ready: process is ready to be selected 61 62 ![](6e8f99942767b51c636065cbe3df0d53.png) 63 64 scheduler allocates/deallocates the CPU. there is no immediate transition between states because process has to wait for scheduler 65 66 ## Scheduler vs processes 67 68 - scheduler periodically switches processes 69 - sequential processes lie on the layer above 70 - leads to simple process organisation 71 72 ![](9ce90ac9631400010ab118e5c8100a8c.png)