What is an operating system, and why is it required?

  • An operating system is the glue layer between hardware and software applications.
    • It enables software to run on many different types of machine
    • It enables complexity to be hidden
      • E.g. mass storage could be handled by a network server, a hard disk, or a USB drive. The OS allows for generic access to these devices and files and folders allowing operations like load, save, rename and delete. The OS talks directly to the necessary drivers.
    • Without an OS, the programmer needs to know how to communicate with every specific device/component
      • What if you then wanted to run two programs simultaneously

Computer Resources

  • CPU
  • Memory
  • Screen
  • Keyboard
  • Mouse
  • Touchscreen
  • Sound card
  • Hard disk
  • USB ports
  • Network

Operating System

  • The OS’s name comes from the fact that it operates the computer system:
    • Allowing the hardware resources to be shared
    • Handling interrupts generated by the I/O controllers
    • Handling interrupts generated by software application and utilities
    • Sharing the CPU time amongst running programs (task scheduling)
    • Sharing of I/O between many programs using the CPU (e.g. keyboard, mouse, printers, hard disk, USB ports)
    • Allocation of computer memory
    • Provide common API (application programming interface)
    • Hiding the complexities of hardware from the user

API

  • An important part of the OS is to provide an API
    • Application Programming Interface
  • For example, a Windows program does not talk directly to the hardware but to the operating system (the kernel). Programs communicate via an API
  • The reason for this is that the program doesn’t need to know how to handle low level details like managing memory, controlling the graphics card, etc.
    • The OS will take care of that, which is why we need an OS

OS Kernel

  • The kernel is a computer program that constitutes the central core of a computer’s operating system
  • It has complete control over everything that occurs in the system
    • As such, it is the first program loaded (into protected memory) on startup, and then manages the remainder
    • It is the only part of the OS that has direct access to the hardware
  • It is also responsible for:
    • Managing memory
    • Managing and communicating with computing peripherals (e.g. printers, etc.)

Application, Program and Process

  • Application
    • Consists of one or more coordinating program instances to solve a user’s purpose
  • Program
    • A set of static instructions saved on secondary, tertiary memory waiting to be run
  • Process
    • An instances of a computer program that is being executing. It is dynamic once in memory
      • Processes can consist of multiple threads. That is, the programs instructions can be simultaneously executed by different cores

Process Control Block (PCB)

  • Each process on a modern CPU has a PCB

  • The PCB holds a lots of data about a given process

    • Process state: State may enter into new, ready, running, blocked (waiting), terminated depending on CPU scheduling.
    • Unique Process number
    • Program counter: a pointer to the address of the next instruction to be executed for this process.
    • CPU registers: indicates various register set of CPU where process need to be stored for execution for running state.
    • Memory management information: includes the information of page table, memory limits, Segment table depending on memory used by the operating system.
  • Ready

    • Ready processes are waiting to have the processor allocated to them by the operating system so that they can run. A process may come into this state after Start state or while running but interrupted by the scheduler to assign CPU to some other process.
  • Running

    • Once the process has been assigned to a processor by the OS scheduler, the process state is set to running and the processor executes its instructions.
  • Blocked (aka Waiting)

    • Process moves into the waiting state if it needs to wait for a resource, such as waiting for user input, or waiting for a file to become available.  Note that a process is unable to run until some external event happens.  Page faults (where blocks of memory are stored on secondary storage) can also cause a blocked state.  Once the block has been resolved, the process can move back to ‘ready’ awaiting scheduling to run.