OCR Computing A-Level Revision

Function of Operating Systems

Features & Components (3.1.a, 3.1.f)

There are several different types of operating systems. Obviously, different operating systems have different features, however all operating systems have some key features:

Error reporting - functionality for storing details of errors which occurred in the operating system other software, so that developers can fix the causes of these errors ("bugs").
Memory management - the allocation of memory for use my various programs, as well as the storage and retrieval of data from memory.
Resource management - the management of limited resources, including CPU time, memory, hard disk space, electrical power, external devices, and I/O operations.
I/O management - the management of I/O devices.
Device management - the management of all devices, such as storage devices and graphics cards (including I/O devices).
Interrupt management - the management of interrupts.
User interface(s) - the management of user interfaces - for example a GUI for the end user and a command line interface for a technician to diagnose faults.
File Allocation Table (FAT) - a map of where files are stored. Also contains various metadata, such as file names, access rights, and file sizes. It is used by the operating system when files are saved, deleted and accessed.
Boot File - used while the operating system is loading, when the computer is switched on, after POST (Power On Self Test - a form of self-diagnostics), to provide personal settings.

Interrupts (3.1.b)

Some tasks are more important than others. For example, consider a school computer rendering a video file. If the user moves the mouse, then the screen has to be updated, to move the mouse pointer. However, the processor can only work on one task at a time (the screen cannot be redrawn with the new mouse position at the same time as rendering video). Therefore, interrupts are used - to tell the processor to stop what it is doing because there is something more important which needs dealing with.

Before the Fetch Decode Execute cycle, the CPU checks the contents of the interrupt register. This contains the details of any pending interrupts. If the interrupt in the interrupt register has a higher priority than the current task (which could be another interrupt), then the interrupt is processed, otherwise the current task continues processing. Note: the current task could have a higher priority than the interrupt, especially if the current task is another interrupt!

When servicing an interrupt, the data from the registers is pushed to the stack. It then loads the program counter with the address of the start of the Interrupt Service Routine, and the FDE cycle continues. The last instruction of the Interrupt Service Routine is an Interrupt return instruction that brings the original data back into the registers.

Scheduling & Job Queues (3.1.c)

A scheduling algorithm has 4 "goals":

A scheduling algorithm should also ensure all tasks are processed, by changing the priorities if necessary.

There are a number of popular scheduling algorithms:

Memory Management (3.1.d)

All operating systems need memory management software.

Segmentation & Paging

There are two ways to divide memory (for swapping between RAM and virtual memory) - segmentation and paging. Segmentation is where each task has a whole "segment". The whole segment has to be moved to and from virtual memory, however segmentation avoids the need to split up a program. Paging is where a program is split into pages, which all have the same size. Individual pages can be swapped in and out of virtual memory, which can lead to more efficient use of RAM. However, programs have to be split into individual pages.

Virtual Memory

A computer will only have a limited amount of RAM. When the RAM is full, virtual memory has to be used, based on secondary storage (such as the hard disk). This allows programs to run that need more memory than is available. However, if virtual memory is overused, then the processor could end up spending more time moving segments or pages between RAM and virtual memory. This is known as disk threshing, and can result in the computer performing sluggishly, or "hanging".

Spooling (3.1.e)

Spooling is used when the rate the processor can send data is faster than the rate a peripheral device can output it. For example, consider a printer. It might be able to print 20 pages per minute, a third of a page per second. However, the processor is cable of sending pages much faster than this. This is known as speed mismatch.

To prevent the processor from being "held up" by the printer (or another peripheral), the print data is saved to secondary storage. It is then retrieved and sent to the printer when the printer is ready - in the mean time the processor can work on higher priority tasks.