1.2 Hardware Here we list the main hardware concepts.
1.2.1 The CPU The CPU, or central processor unit is the heart and soul of every computer. This is the part which does the work of executing machine instructions. Traditionally, it is just one microprocessor with lots of pins to connect is to memory and devices - usually identifiable by being the largest chip.
On modern machines, there may be several CPUs which can work in parallel. Also VLSI or very large scale integration technology has made it possible to put very many separate processors and memory into a single package, so the physical distinction between the CPU and its support chips is getting blurred.
Nevertheless, the CPU is still logically separate from the memory and devices. The CPU is driven by a `clock' or pulse generator. Each instruction completes in a certain number of `clock cycles'. Traditionally CPUs are based on CISC (Complex Instruction Set Computing) architecture, where a single instruction takes one or more clock cycles to complete. A new trend is to build RISC (Reduced Instruction Set Computing) processors which aim to be more efficient for a subset of instructions by using redundancy.
These have simpler instructions but can execute much more quickly, sometimes with several instructions per clock cycle.
1.2.2 Memory The primary memory is the most important resource a computer has. Since CPUs are only made with instructions for reading and writing to memory, no programs would be able to run without it. There are two types of memory: RAM - random access memory, or read/write memory, which loses its contents when the machine is switched off, and ROM - read only memory, which never loses its contents unless destroyed. ROM is normally used for storing those most fundamental parts of the operating system which are required the instant a computer is switched on, before it knows about disks etc.
1.2.3 Devices The concepts of a device really has two parts. There is the hardware unit which is connected to the machine, and there is the logical device which is a name given by the OS to a legal entry point for talking to a hardware-device. When a user writes to a logical device, the OS invokes a device driver which performs the physical operations of controlling the hardware.
For example, when writing to a disk, the OS must control the movement of the read-write heads.
When writing to a printer, the OS places the information in a queue and services the request when the printer becomes free. Some common logical devices are: the system disks, the keyboard, the screen, the printer and the audio device. Disks and tapes are often called secondary memory or secondary storage.
1.2.4 Interrupts, traps, exceptions Interrupts are hardware signals which are sent to the CPU by the devices it is connected to. These signals literally interrupt the CPU from what it is doing and demand that it spend a few clock cycles servicing a request.
For example, interrupts may come from the keyboard because a user pressed a key. Then the CPU must stop what it is doing and read the keyboard, place the key value into a buffer for later reading, and return to what it was doing. Other `events' generate interrupts: the system clock sends interrupts at periodic intervals, disk devices generate interrupts when they have finished an I/O task and interrupts can be used to allow computers to monitor sensors and detectors. User programs can also generate `software interrupts' in order to handle special situations like a `division by zero' error.
These are often called traps or exceptions on some systems. Interrupts are graded in levels. Low level interrupts have a low priority, whereas high level interrupts have a high priority.
A high level interrupt can interrupt a low level interrupt, so that the CPU must be able to recover from several `layers' of interruption and end up doing what it was originally doing. This is accomplished by means of a stack or heap1.4. Moreover, programs can often choose whether or not they wish to be interrupted by setting an interrupt mask which masks out the interrupts it does not want to hear about. Masking interrupts can be dangerous, since data can be lost. All systems therefore have non-maskable interrupts for the most crucial operations.
1.3 Software
1.3.1 Resource management In order to keep track of how the system resources are being used, an OS must keep tables or lists telling it what is free an what is not. For example, data cannot be stored neatly on a disk. As files become deleted, holes appear and the data become scattered randomly over the disk surface.
1.3.2 Spooling Spooling is a way of processing data serially. Print jobs are spooled to the printer, because they must be printed in the right order (it would not help the user if the lines of his/her file were liberally mixed together with parts of someone elses file).
During a spooling operation, only one job is performed at a time and other jobs wait in a queue to be processed. Spooling is a form of batch processing. Spooling comes from the need to copy data onto a spool of tape for storage.
It has since been dubbed Simultaneous Peripheral Operation On-Line, which is a pretty lousy attempt to make something more meaningful out of the word `spool'!
1.3.3 System calls An important task of an operating system is to provide black-box functions for the most frequently needed operations, so that users do not have to waste their time programming very low level code which is irrelevant to their purpose.
These ready-made functions comprise frequently used code and are called system calls.
For example, controlling devices requires very careful and complex programming. Users should not have to write code to position the head of the disk drive at the right place just to save a file to the disk.
This is a very basic operation which everyone requires and thus it becomes the responsibility of the OS.
Another example is mathematical functions or graphics primitives. System calls can be thought of as a very simple protocol - an agreed way of asking the OS to perform a service. Some typical OS calls are: read, write (to screen, disk, printer etc), stat (get the status of a file: its size and type) and malloc (request for memory allocation). On older microcomputers, where high level languages are uncommon, system calls are often available only through assembler or machine code. On modern systems and integrated systems like UNIX, they are available as functions in a high level language like C.
1.3.4 Basic command language Commands like dir; list files (DOS)ls ; list files (UNIX)cd; change directorycopy file prn; copy file to printermyprog; execute program `myprog'constitute a basic command language.
Every computer must have such a language (except perhaps the Macintosh - yawn!).
In microcomputer operating systems the command language is often built into the system code, whereas on larger systems (UNIX) the commands are just executable programs like the last example above. The command language deals typically with: file management, process management and text editing.
1.3.5 Filesystem In creating a system to store files we must answer some basic questions. 13 Should the filesystem distinguish between types of files e.g. executable files, text files, scripts. If so how?
One way is to use file extensions, or a naming convention to identify files, like myprog.exe, SCRIPT.BAT, file.txt.
The problem with this is that the names can be abused by users. If one tries to execute a file which is not meant to be executed, the result would be nonsense and might even be dangerous to the point of crashing the system.
One way around this problem is to introduce a protocol or standard format for executable files, so that when the OS opens a file for execution it first checks to see whether the file obeys the protocol.
This method is used for binary files in UNIX, for instance. 13 Protection. If several users will be storing files together on the same disk, should each user's files be exclusive to him or her? 13 Is a mechanism required for sharing files between several users? 13 A hierarchical filesystem is a good starting point for organizing files, but it can be too restrictive. Sometimes it is useful to have a file appear in several places at one time. This can be accomplished with links. A link is not a copy of a file, but a pointer to where a file really is.
By making links to other places in a hierarchical filesystem, its flexibility is increased considerably. |
|