Memory Management

If an OS is running more than one process, then memory must be allocated to each process. Most OS's have some form of memory protection scheme whereby a process has no access to the memory of any other processes.

The real layout of the memory is called the physical memory. The memory 'seen' by a particular process is called the logical memory.

Most modern CPU's incorporate a device called a Memory Management Unit that translates from logical to physical addresses.

File Management

A file is an abstraction used to name data in secondary storage (a hard disk). The hard disk can be thought of as a large, slow, memory; organisation of files on the hard disk is called the file system. A very simple file system is called contiguous allocation - just fill up the disk with files from start to finish. For example, after the creation of five files the disk may look like this:


A major problem with this system is that files cannot grow in size unless other files are moved.

Another problem with contiguous allocation is that if files are deleted, the disk will have gaps between files.

If file2 and file4 are now deleted, the disk will look like:


When a file is created, the operating system must look through a list of the gaps to see if there is one large enough. The disk may have enough space left on it for the file, but if the space is scattered over many gaps then file creation will fail.

A better system is called indexed allocation.

The hard disk is divided into small chunks called blocks or clusters. Block sizes vary between 512 bytes and 64K bytes.

At a fixed position on the disk, is a table that keeps track of which block is allocated to which file. The following diagram shows how file6 is stored at two different places on the disk. Indexed allocation allows files to grow in size and makes good use of disk space if the block size is small. If the block size is large then space will be wasted in partially filled blocks.

A Comparison of three operating systems:

Windows 98

Has pre-emptive multitasking, memory protection for some applications and a simple form of indexed allocation.

MacOS

Uses non pre-emptive multitasking, simple memory protection and indexed allocation.

UNIX

Has pre-emptive mutitasking, memory protection and indexed allocation.