Operating Systems

What is an Operating system

 A program that acts as an intermediary between a user of a computer and the computer hardware.

A systems program which controls all the computer's resources and provides a base upon which application programs can be written.

Operating system goals:

  1.      Execute user programs and make solving user problems easier.
  2.      Make the computer system convenient to use.
  3.      Use the computer hardware in an efficient manner.

System services

The OS often acts as an intermediary between user programs and hardware. For example, to print a message on the screen, a user program could manipulate the hardware directly, but it is easier to call an operating system function to do this for you. When you use printf in a C program this is what you are really doing. If the operating system is the only program that manipulates hardware then there will be less chance of a user program using hardware badly. Calls to the operating system are usually called system calls.

Hardware controlled by the OS fits into three categories

  1. CPU
  2. Memory
  3. Input/Output
Efficient use of the CPU is called Process Management.
Efficient use of the Memory is Memory Management
Input Output covers many things, we will look at File Management.

Process Management

How can we efficiently use the CPU? This question only makes sense if there is more than one program running. An OS that supports running more than one program at once is called a multitasking OS.


Multitasking lets each process think that it has complete control of the CPU. There are two types of multitasking, pre-emptive and non pre-emptive.

Non pre-emptive multitasking.

The CPU is allocated to a process until the process performs a system call. This is simple to implement but is not always fair and allows a process monopolise the CPU. If a process enters an infinite loop, no other processes will ever get control of the CPU. This system is used by Windows 3.1 and MacOS.

Pre-emptive multitasking.

Before the CPU is allocated to a process, a hardware timer is set up to interrupt the process after a set time (called the time quantum). No process will ever be allowed to take over control of the  CPU. The system may run slightly slower than a non pre-emptive system because of the overhead of extra process switches. As long as the time quantum is large compared to the process switch time this effect will be negligible. This type of multitasking is used by Windows 95/98/NT, UNIX, and many other OS's.

Multiuser OS's

Windows 95/98/NT are multitasking but they are really only single user Operating Systems. Some OS's allow more than one user at the same time, obviously each user must have a different screen and keyboard but the CPU and disk space is shared.


A multitasking OS must decide which of a number of waiting process to run next. This is called CPU scheduling. A CPU scheduling algorithm must minimise the average time a process has to wait for the CPU and maximise the utilisation of the CPU. A simple scheduling algorithm called round-robin, executes processes in a fixed order.