Functions of an Operating System


An operating system is software that manages the operations on a computer. Operating system

Primary functions of an Operating system

  • Memory management
  • Interrupt service routines
  • Processor scheduling
  • Backing store management
  • Management of all inputs and outputs
  • File management

Memory management

Memory management in an operating system allows for memory to be allocated efficiently

Paging

In order for the operating system to effectively manage the memory, the memory needs to be first divided into fixed size blocks. These blocks are called pages.

Virtual memory

Virtual memory is a memory management technique that allows for the execution of processes that may not be completely in memory. Virtual memory is a combination of RAM and disk space.

Interrupts

An interrupt is a signal from software or hardware that can trigger a function.

Types of interrupts

There are three main types of interrupts:

  • Hardware interrupts - These are generated by hardware devices.
  • Software interrupts - These are generated by the software or the operating system itself.
  • Trap - These are generated programs (E.G an error in a program)

The interrupt process

  1. The interrupt request (IRQ)
    • The interrupt is generated by hardware or software
    • The interrupt controller passes the interrupt onto the interrupt handler
  2. Interrupt acknowledge
    • The interrupt handler decides if the interrupt should be serviced now or later
    • If it should be serviced now then the current contents of the registers are saved into memory.
  3. Interrupt Service Routine (IRQ) Lookup
    • The processor fetches the corresponding interrupt service routine
    • The processor transfers control to the ISR and executes the routine ti handle the interrupt.
  4. ISR Execution
    • The processor transfers control to the ISR and executes the routine to handle the interrupt.
  5. Interrupt Exit
    • After the interrupt has been handled the processor restores the registers and continues executing the program.z

Processor scheduling

In order for computers to run multiple tasks at once there needs to be scheduling. Scheduling allows for the CPU to allocate processing time to each process. There are different types of scheduling algorithms:

Preemptive

Preemptive scheduling is when jobs are activity made to start and stop the operating system.

Examples:

  • First come first serve
  • Round robin

Non-preemptive

Non-preemptive scheduling is when jobs is started it is left alone until it is completed.

Examples:

  • Shortest job first
  • Priority scheduling

Round robin

In a round robin system process are on a first in first out basis. Each process takes its turn.

First come first serve

In a first come first serve, jobs are processed in the order that that are executed. There is no priority in place.

Shortest job first

The smallest processes are ran first before running larger jobs.