Cards (13)

  • Standard operation of an OS
    Divide processing time between the processes that are running
  • Factors that determine how processing time is divided
    • When the task was requested
    • The importance of the task
    • The length of the task
  • More processes a computer is running

    Longer it may take for a process to be allocated processing time
  • This method of allocation is unsuitable for processes that must perform tasks almost immediately
  • The character should appear on the computer's display almost immediately
  • If this process could not run until all of the other processes had finished running, the user might notice the delay and it would become uncomfortable to type
  • Allocating time to urgent processes
    1. Devices use interrupts
    2. Interrupt is a signal sent to processor to request immediate attention
    3. Processor suspends what it is doing and runs the process associated with the interrupt
  • Reasons the processor can be interrupted
    • Hardware device has signalled it has data to process
    • Hardware device has completed a task it was asked to do
    • Software process needs a service to be provided or an OS function to be performed
    • Allotted amount of time has expired and an action needs to be performed
    • Hardware failure has occurred and needs to be addressed
  • The operating system will have interrupt service routines (ISRs) (or interrupt handlers) designed to process each interrupt. An ISR is a mini program designed to respond to an interrupt’s request. ISRs can be built into an operating system or provided via device drivers.
    In the example of a key being pressed, the ISR will determine which key this was by polling the keyboard, then it will store the relevant character in the keyboard buffer. A process that is waiting for keyboard input can later check the keyboard buffer to find out which key was pressed.
  • Fetch-decode-execute cycle
    1. Processor repeats the cycle continuously if there are no interrupts
    2. Processor executes the instructions of a running process one after the other
  • Interrupt
    Causes the processor to suspend what it is executing so that it can run the ISR
  • Interrupt handling
    1. Processor completes the fetch-decode-execute cycle of the instruction it was running when it received the interrupt
    2. Current contents of the processor registers (including the program counter) are saved to memory
    3. Origin of the interrupt is identified so that the appropriate ISR is called
    4. Lower-priority interrupts are put on hold to allow the ISR to finish running
    5. Program counter is updated with the address of the first instruction of the ISR
    6. ISR completes its execution
    7. Processor registers are reloaded with the values that were saved to memory
    8. Lower-priority interrupts that were put on hold are re-established
    9. Program counter is set to point to the address of the next instruction that needs to be executed in the program that the processor was running when it received the interrupt
  • Once the ISR has finished executing, the OS must return to the instruction that it was executing before it received the interrupt and continue from where it left off