1.2.1 Operating systems

An operating system (OS) is software that controls the computer. It manages the computer's hardware and the programs running on it.

Operating systems have many roles, such as:

Memory management is one of the key function of an OS. It is necessary to:

An OS may use two processes to manage memory:

Both paging and segmentation:

When there isn't enough RAM to store all the running programs, the system will use an area of the secondary storage as virtual memory as an extension of the computer's RAM. Sections of programs which are not currently in use are moved into the virtual memory by paging or segmentation, freeing up space in the RAM for other programs. These sections are swapped back to the main memory when/if they are needed.

Virtual memory is used because RAM is more significantly more expensive than secondary storage, so a system would have far more secondary storage than RAM. However, if sections are swapped back and forth too frequently, the computer slows down. This is called dish thrashing and it gets progressively worse as the virtual memory fills up.

An interrupt is a signal which can be sent to the CPU to request immediate attention. Computers use interrupts for multiple reasons:

There are a number of sources of interrupts:

At the end of each FDE cycle, the CPU checks for any interrupts. If there are, it compares the priority of the interrupt and of the current task. If the interrupt is of a higher priority than the current task:

If multiple interrupts occur at the same time, the higher priority interrupt will be serviced first. If a higher priority interrupt is raised while an interrupt is being serviced, the interrupt currently being processed will be added to a stack while the new, higher priority interrupt is serviced.

Scheduling is the method used by the OS to manage the amount of processing time given to different processes. It is necessary for many reasons:

Scheduling algorithms may be preemptive or non-preemptive:

The different scheduling algorithms work in different ways, and each has benefits and drawbacks for tasks with specific characteristics:

There are a number of different types of operating systems:

Exam questions may require a type of operating system to be recommended for a specific scenario, with justification required for the choice made.

The Basic Input Output System (BIOS) is the first program that runs when a computer is first turned on.

A device driver is software that controls a piece of hardware and allows the operating system to communicate with the hardware device. The driver is needed as it allows the operating system to communicate with the hardware device without knowing the details of the hardware device (there are many different hardware devices and the OS cannot possibly know the details of each one).

Drivers are specific to a computer's architecture and to the operating system.

A virtual machine (VM) is a theoretical computer on which programs can run. They have the same functionality as a physical computer. They have many advantages:

VMs can be used to execute intermediate code which is run on the VM using a translator:

VMs can also be used to run an operating system within another: