Processes and Threads Flashcards
the process model
Allows the OS to simplify:
- Resource allocation
- Resource accounting
- Resource limiting
OS maintains information on the resources and the internal state of every single process in the system
processes in the process model
- single process counter
- each process in unique location
- CPU switches back and forth from process to process
- Each process has own flow of control (own logical program counter)
- Each time we switch processes, we save the program counter of first process and restore the program counter of the
second - all processes make progress, but only one is active at any given time
concurrent processes
- The CPU can be allocated in turns to different processes
- OS normally offers no timing or ordering guarantees
process hierarchies
- 1 init process
- parent can create many child processes
- tree structure with process groups
- child can have some or all resources from the parent
parent -> child (address space)
- the child is a duplicate of the parent ⇒ it has the same data as the parent
- the child has a new program loaded into it
Four principal events that cause processes to be created
- System initialisation
- Execution of a process creation system call by a running process
- A user request to create a new process
- Initiation of a batch job
process termination
all the resources are deallocated after termination
a parent may terminate its child because
- the child has exceeded its usage of the resources it has allocated
- parent needs to know the state of the children → uses some mechanism
- the task is no longer required
- the parent is terminated itself (in some os)
typical conditions which terminate a process:
- Normal exit (voluntary)
- Error exit (voluntary)
- Fatal error (involuntary)
- Killed by another process (involuntary)
- only parent can kill the child process
information associated with a process
ID (PID), User (UID), Group (GID)
memory address space
hardware registers (e.g. pc)
open files
signals
Where is information associated with a process stored?
in the operating system’s Process Table
PCB
process control block, consist of:
- process ID
- process state
- process number
- program counter
- registers (CPU registers)
- CPU scheduling information
- memory limits - memory management information
- list of open file
- accounting information
- I/O information
process states
- Running (actually using the CPU at that instant)
- Ready (runnable; temporarily stopped to let another
process run) - Blocked (unable to run until some external event
happens)
process blocks for input
running -> blocked
scheduler picks another process
running -> ready
scheduler picks this process
ready -> running
input becomes available
blocked -> running
Which layer handles interrupts and scheduling
the lowest layer of a process-structured operating system
scheduling queues
- job queue: all processes in the system
- ready queue: processes in the main memory and waiting for the CPU
job -> ready ->CPU
context switches
state save
state restore
Why is context switch time pure overhead?
because the system does no useful work while switching
Interrupt vector
- Associated with each I/O device and interrupt line
- Part of the interrupt descriptor table (IDT)
- Contains the start address of an OS-provided internal procedure (interrupt handler)
Who continues process execution after interrupts?
interrupt handler
interrupt types
sw, hw, device (async), exceptions