Operating Systems
Introduction
If we turn on a computer in order to do some word processing, we notice that there can be up to a one minute interval between us actually supplying power to the machine and the time that we can actually tell it to run Microsoft Word. We also notice that the disk drive is very active during this interval. Why this delay?
The answer is that the computer is loading the operating system from the hard drive. Because we rarely interact directly with the operating system, as beginners, we can be even unaware of its existence. However without the operating system our computers would not be able to run. So what exactly is the operating system and what does it do?
The operating system is a suite or a large number of programmes that control the running of the computer. Some of the functions of the operating system include controlling the following:
- keyboard and mouse input
- screen display
- hard disk drives
- Access to printers
- Access to CPU
We shall look at each of those aspects of the operating system.
Keyboard Input
We shall first look at keyboard input. When using a computer to do word processing we are so accustomed to seeing every key that we press appearing on our screen that we take it for granted. However the apparently instantaneous appearance of the characters on the screen is very deceptive. The data goes through a lot of processing from the time we press a keyboard key with our finger until the fraction of a second later when we see that character on the screen.
One part of the operating system is devoted exclusively to controlling input from the keyboard. This would be called the keyboard driver. This driver first reserves a portion of the main memory for storing the data received from the keyboard. This is known as the keyboard buffer. Any data entered by the keyboard is stored in this buffer. The driver periodically checks this buffer – perhaps 20 times every second – and if any data has been entered transfers that data to the programme that is waiting for input.
Occasionally if you are typing quickly into a word processor, the system appears to hang up and nothing appears or the screen. Suddenly all the last 30 characters or so that you have typed appears on the screen together. The reason for this delay is that other programmes may have been running in the background which prevented the keyboard driver from running. As soon as it gets a chance to run it collects all of the data in the keyboard buffer and transfers it all together to the programme that had been waiting for the input.
Go to topMouse Input
The movements of the mouse on the mouse pad is monitored by the portion of the operating system called the mouse driver. Again data relating to the mouse’s movement is stored in a buffer – the mouse buffer. The mouse driver uses this data to position the mouse pointer on the screen. This same information is passed to GUI based programmes who need to know where the mouse is positioned over them. As an example of this Word will need to know where over its text the mouse is positioned so that when the user clicks the mouse Word can place the cursor at that point in the text..
As well as the position of the mouse, other data that stored in the mouse buffer is:
- Is one of the mouse buttons pressed
- The time the button was pressed
- If a button is pressed which one
- Has a mouse button been released.
- The time the mouse button was released.
The press and release times are needed so that the mouse driver can determine if a double click was made.
Go to topScreen Display
Modern screens are made up of pixels. Each pixel has its position on the screen as well as its own colour data attached to it. In computers a colour is defined as a combination of the three colours Red, Green and Blue. The value of each colour can vary from 0 to 255. Thus if a colour is defined as 255,0,0 it means that it is pure red, while 0, 0, 255 means that it is pure blue. An average screen would be 1440 pixels long and 900 pixels high. This means that it would contain 1,296,000 pixels. Each pixel would also require three bytes of data attached to it to indicate the colour of the pixel.
To control the screen display, the screen driver reserves a block of memory large enough to accommodate information on all of the pixels that will be used to make up the display. In the case of a 1440 X 900 screen the amount of memory required would be 3,888,000 bytes. This area is referred to as the screen buffer. When a word processor wishes to display part of a document’s text on the screen it passes to the screen driver the text as well as the font, size etc of that text and the magnification of the screen that is required. The screen driver then builds up a screenful of this data pixel by pixel and finally the programme that actually controls the screen uses this data to paint a picture on the screen. This may sound a lot of processing but it occurs each time you press a key on the keyboard to enter a letter into the document you are processing or whenever you move the display using the scroll bar.
Go to topDisks
Disks are used for permanent storage of data. That means that data can be written to them and read from them. As you might expect by now each disk will have a disk buffer where data written to it will be stored before being transferred to the disk and data read from it will be stored before being transferred to the programme that wants it. This transfer of data in both ways is controlled by the disk drivers. Some of the functions of the disk drivers are:
- Signal the disk to start spinning
- Detect when the disk is spinning at the correct speed
- Control the positioning of the read/write heads
- If the disk is reading data, transfer the data read to the buffer
- If the disk is writing data, transfer the data from the buffer to the disk.
- When the reading/writing is finished, signal the disk to stop spinning.
Access to Printers
Just about all application programmes at one time or another wish to print their data. The biggest user of printers would be word processors. Normally when you purchase a printer, a CD or DVD will accompany it that will include drivers for that printer for the most common operating system. Before you can use that printer you must install the driver software into your computer.
When your word processor wishes to print to that printer it passes the data it wishes to print to that printer’s driver. The driver then formats that data and places it in the buffer for the printer. When the printer is ready to start printing another portion of the operating system controls that data from the buffer to the actual printer.
Go to topAccess to CPU
So far in this chapter we have discussed word processors, spreadsheets, keyboard drivers, mouse drivers, screen drivers, disk drivers and printer drivers all running on the one computer. All of those are dedicated programmes that either control the production of written documents or else control the hardware items they are designed to control. There is, however, only one CPU in the computer, so how does the system know to transfer control from one programme to another. This is done by a special programme called the scheduler, which controls all of the other programmes that are waiting in memory to run.
There are a number of different ways that a scheduler can control access to the computer. We shall describe the simplest method known as the round robin.
A scheduler using the Round Robin method simply creates a list of the programmes in memory that are supposed to be running. These programmes include the scheduler itself. Each programme is allocated an amount of time on the CPU. Once this time is up, the programme is suspended and the next programme in line gets access to the CPU. In this way all programmes in memory get an opportunity to use the CPU.
The amount of time allocated to each programme may be as small as 1 millisecond, but since control passes back to each programme so quickly each one thinks that it has sole access to the CPU.
Go to topExercise
- List four of the functions of the operating system.
- What is the name of the part of the operating system that controls the entry of data using a keyboard?
- What is a keyboard buffer?
- Describe some of the functions of the mouse driver.
- Name and describe some of the data that is stored in the mouse buffer.
- Describe the workings of the screen buffer.
- List some of the functions of the disk driver
- Drivers for the keyboard, mouse and screen are automatically part of the operating system. Another computer peripheral must have its drivers loaded into the computer before the peripheral is capable of working. Which peripheral device is this?
- Part of the operating system is a scheduler called the Round Robin.
- What is a scheduler and what is its main function
- Explain how the Round Robin scheduler works.