Processor Manager Flashcards
Processor Manager
Decides how to allocate the CPU to waiting processes/Decides which process gets on the CPU first to be decoded and executed.
- Creates processes when a program is executed.
- Initialises memory and stacks for new processes.
- Keeps track of status of processes.
- Context switch.
- Changes process states
- Handles termination of processes on completetion/abort.
- Allows communication between processes.
- Manages process queues and prioritisation.
Multiprogramming
Put process on CPU, and doesn’t come off until it either it terminates or blocks if the process is waiting for an I/O, in which there is no point keeping it on the CPU, creating difference between process phase or I/O phase. Problem arise with compute-bound and I/O bound processes. This is balanced with multitasking.
Multitasking (time-sharing)
Gives each process a fixed time on the CPU, interrupting it if it takes too long. When it is interrupted, the OS gets a clock interrupt and puts itself (the OS scheduler) onto the CPU, operating what they need to do (tidying up etc). Since this is so fast, it looks like it is multitasking.
Interrupt Handling
multitasking relies upon the fact it can interrupt the CPU. An interrupt request (IRQ) is a hardware signal that occurs when something happens outside normal program execution, which can happen at anytime regardless on what the CPU is doing. This tells the CPU to stop and load an interrupt handler (known as interrupt service routines, or ISR).
Interrupt Vector
The CPU also has a interrupt vector, which stores the memory address of handler for each type of interrupt, populated by OS when it first boots up. So essentially, the OS is responsible for handling and managing each interrupt.
CPU Interrupt
When the CPU receives an interrupt, the interrupt will have a number in which the CPU uses to find the correct address in the interrupt vector to find the correct address for the code to handle the interrupt.
Context Switch with OS
The clock interrupt is triggered at the end of each time slice, which results in the OS running its scheduling algorithm to choose next processes, known as context switch. The current state of the CPUs are stored in a data structure called process control block. This overall wastes a few FDE cycles but gives maximum CPU usage with multitasking without the original problems of multiprogramming.
Process Control Block
What the kernel maintains for every process, which can also be represented as a file. This contains things such as:
- Unique process ID
- User ID of process owner
- Process state
- Memory address of process
- Statistics
- Resources allocated to process (files, devices etc)
- Register values from context switch
States of Processes
- Running -> currently being executed.
- Ready -> ready to be executed/ waiting for CPU to become free.
- Blocked -> waiting for I/O to be complete.
Creation and Termination
- Creation -> reverse memory for the process and its stack, setup process control block, initialise I/O channels, place process into the ready state.
- Termination -> close I/O channels, remove process control block, deallocate memory.