Functions of an Operating System

Cards (20)

  • The boot loader in ROM loads the operating system into RAM when the computer is switched on. The OS manages the hardware and provides an interface for the user and the application software.
  • OS functions
    User Interface
    Memory Management
    Interrupt Handling
    Processor Scheduling
  • User Interface
    The Operating System hides the complexity of the hardware from the user by providing a user interface.
  • Memory Management:
    • Programs and their data need to be loaded into RAM
    • The operating system must manage the allocation of RAM to the different programs
    • There may not be sufficient RAM for all desired processes to be completely loaded into RAM at once
    • So allocate RAM to different programs and ensure each process gets a share
    • This ensures the efficient use of the finite resource of RAM
  • Paging
    Available memory is divided into fixed size chunks called pages. Each page has an address. A process loaded in RAM is allocated sufficient pages, but those pages may not be contiguous (next to each other) in physical terms
  • Paging Example
    Process A requires 2 pages in RAM, process B requires 3 pages.
    Process A ends.
    Process C is started, but it needs 3 pages of RAM so it is allocated non-contiguous pages.
  • A page table maps between the logical memory locations and the physical memory locations.
  • Segmentation
    Memory is divided into segments which can be of different lengths. Segments can relate to parts of a program, for example a particular function or subroutine may occupy a segment. Segmentation is the logical division of address space which is dependent on the program structure.
  • Virtual Memory
    A computer has a fixed amount of RAM. An area of the hard disk is designated to virtual memory. Some of the pages of the current process are stored in virtual memory until they are needed, at which point they are swapped into RAM.
  • Disk Thrashing
    If many processes are running and the computer has insufficient RAM, lots of time is spent swapping pages in and out of virtual memory. Repeatedly swapping pages can noticeably slow down the computer as swapping itself uses resources. This is known as disk thrashing.
  • Interrupts
    Interrupts can be sent to the CPU by software, hardware device or the CPUs internal clock.
    Examples of interrupts are:
    • An I/O device sends an interrupt signal
    • The print runs out of paper
    • An error occurs in a program
    • A scheduled interrupt from the internal clock
    • Power failure
  • The CPU checks at the end of each clock cycle whether there are any interrupts to be processed. When an interrupt is detected, the processor stops fetching instructions and instead pushes the current contents of its registers onto a stack. The CPU uses an interrupt service routine to process the interrupt. When processing has finished, the values can be popped from the stack and reloaded into the CPU.
  • Interrupt Priority
    If a higher priority interrupt occurs whilst an interrupt is being processed, the original interrupt's registers will be pushed onto the stack as well.
  • Processor Scheduling
    A single CPU can only process instructions one application at a time. The OS must schedule when each application can use the CPU. This gives the illusion of multi-tasking (multiple applications appear to be running simultaneously).
  • Scheduling aims to provide an acceptable response time to all users, maximise the time the CPU is usefully engaged and to ensure fairness on a multi-user system.
  • Round Robin
    Each job is allocated a time slice during which it can use the CPU's resources. If the job has not completed by the end of its time slice, the next job is allocated a time slice.
  • First come first served
    The first job to arrive is executed until it completes.
  • Shortest remaining time
    The time to completion is estimated as each new job arrives. The job with the shortest remaining time to completion is executed, meaning that a shorter new job can take over from the current process.
  • Shortest Job First
    The total execution time of each job is estimated by the user. The waiting job with the smallest total execution time is executed when the current job completes.
  • Multi-level feedback queues
    Multiple queues are created with different priority levels. If a job uses too much CPU time it is moved to a lower priority queue. Processes can also be moved to a higher priority queue if they have waited a long time.