Advanced OS Chapter 3p2 Sections 3.4 / 3.5
Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed in response to each type of interrupt -> interrupt handler. trap -> program interrupt, usually an interrupt caused by some exceptional situation in a user program – OS performs some action returns control to program
Interrupts Cont’d Synchronous interrupts occur when a process attempts to perform an illegal action, dividing by zero. They may also be caused by some event that is unrelated to a process’s current instruction. Hardware devices issue asynchronous interrupts to communicate a status change to the processor.
Interrupts Cont’d They provide a low overhead means of gaining the attention of a processor. Alternative is polling increases overhead.
Interrupt Processing Read page 125 – typical interrupt process Interrupt controller may be present to prioritize the interrupts interrupt becomes active - > processor pauses execution - > it must first save information so present process may be returned to - > PSW or PCB - > processor passes control to appropriate interrupt handler - > assigned a unique value - > interrupt handler performs actions - > completes - > state of interrupted process is restored - > executes
Linux Case Study describe structure of Unix processes using a Linux box Each process must store its code, data and stack in memory during execution. Unix implements virtual memory – all unix processes are provided with a set of memory addresses – virtual address space.
Virtual address space contains process information text region data region stack region
Kernel - Linux it maintains a process’s PCB in a protected region of memory – out of reach of user processes In Unix, a PCB stores information including the contents of processor registers, PID – program counter and system stack. All these are listed in a process table
Unix cont’d Unix process’s interact with the OS via system calls. fork - > Spawns a child process – allocates to that process a copy of its parents resources exec - > loads a process’s instructions and data into its address space from a file wait - > causes the calling process to block until its child process has terminated signal - > allows a process to specify a signal handler for a particular signal type exit - > terminates the calling process nice - > modifies a process’s scheduling priority
Child Process Unix A process can spawn a child process with fork ( ) – creates a copy of the parent child process rec’s the copy and any other resources. text segment – contains th parent’s read- only instructions, is shared with its child.
More process system calls process can call exec ( ) to load a new program from a file parent can issue a wait( ) – blocks the parent until specified child process is complete exit () – tells kernel process has finished