|
I tried to give answers to the following questions in this section : |
What is Device Management and what is it good for? |
|
Devices are all pieces of equipment for a computer that perform
Input/Output (short: I/O) operations but that the computer
does not neccessarily need to work. In some way all parts of a computer perform I/O operations, but without CPU or memory a computer would not work at all. Therefore CPU and memory are no devices whereas hard disk drives, mouse, keyboard, scanner, sound card and so on all are devices. |
|
Devices are sometimes referred to as peripheral devices to emphasize
the point that they are "additional" to the core hardware system. In this section
the main effort is put on storage devices, that are devices that store data
permanently. |
|
Device Management is needed for offering a uniform and consistent
approach to all I/O operations. There are considerable differences between
all the system's devices; their speed, how data are transferred and represented,
how to prevent and detect errors and how they are handled. The user is not interested in that differences, s/he just wants them to work properly. Application programs cannot know on which devices data may be saved on a special computer. They need a simple method to hand over their data to the OS which then has to cope with the special properties of the appropriate device. To handle and control the different devices and to speed up I/O operations is the device manager's work. |
What kinds of storage devices are there and how do they work? |
|
On every storage medium the available space is divided into records.
In most cases they are of equal size. That makes it easier to unify the
process of reading and writing for the different devices. Storage devices are being distinguished by the way they access the records on the medium; they do that either sequentially or direct. |
|
Sequential Access Storage Media have no strategy to access data records
directly. The records that belong to a file are situated one after another,
and if the OS issues a request to read a certain file, a medium that
works sequentially (for instance a tape drive) has to read all previous records
from the magnetic band until the desired ones come along. Accordingly, if a record is to be saved it can only be done at the end of the band - after the last record already present. |
|
Because of this simple access strategy tapes are very slow accessing data
records. Once the beginning of the requested data area is reached, though,
data transfer rates are not that bad. The speed of a tape only depends on how fast it winds and how dense the data may be saved. |
|
Sequential access storage media are best used for backups because here there is
normally an enormous amount of data to be saved that (if the system works fine)
never has to be accessed again. |
Direct Access Storage Media all are constructed in a way that there is
a way of determining in beforehand where a certain data record approximately is
situated. Direct access storage devices are for instance:
|
|
They all consist of one platter (or up to 8 in case of a HDD) that is separated
into many tracks which accommodate the data records. While the platter is
spinning in the drive it cannot be predicted where a special record exacly is
on a certain track, but the OS can (and does) maintain a list on which
track it is found. Thus, always a special record shall be accessed the read/write head can already be positioned on the right track and only has to wait until the desired record passes. That's why they are so fast. |
| The speed of disk drives depends on three things: how fast the head can be moved to the right track, how fast the platter is spinning, and how dense the data are stored. |
Access Time |
| For every storage device there is a characteristic approximate time that it takes to access a piece of data. That time period is called access time. It begins when the CPU (in modern computer systems most often an extra I/O-processor) issues the request and it ends when the data is delivered. |
| Access time for tapes |
When an I/O request is issued to a tape it has first to wind the medium to the
right place (search) and second to transfer the data. So
The search time can be very long (up to 5 minutes) for a sequential access storage
medium whereas the transfer is done rather fast.
|
|
Calculation example
|
| Access time for disks |
|
When an I/O request is issued to a disk it has first to move the head to the right
track (seek), second to wait until the right sector comes
along (search), and third to transfer the data. The distinction between seek- and search time is a convention that makes it easier to determine what actually happens if a disk drive is to access data.
As mentioned above we cannot know the exact search time. It could be that in the
moment the head is on the right track the required record has just passed and
that the disk must wait an entire revolution of the platter until it comes along
again. It could also be that the record is just in place when the head arrives.In average it takes half a revolution until the right sector passes the head. That amount of time is called rotational delay. |
| If the rotational delay of a hard disk is given, the amount of revolutions per minute (rpm) it performs can be calculated, and vice versa. |
|
Calculation example 1 Calculation example 2
|
|
Calculating the access time for disks is a bit complicating because the data
does not always occupy subsequent sectors on the same track. It rather is
distributed over many sectors, in worst case it is spread all over the disk. So the head is not justified only once but probably each time after reading some records. In this case the file containing the data is called fragmented. |
|
Calculation example
|
Improvement Possibilities |
|
There are several techniques to make I/O operations more effective for the
computer. All of them try to get rid of the problem that even the fastest
device is still many thousand times slower than the processor,
through which the data must go during every I/O operation. Of course one cannot simply speed the devices up. Their mechanical properties normally do not allow any tuning. So the main performance question is: How can the CPU be prevented from waiting for slow devices?
|
| Virtual Devices |
|
One of the possibilities to improve the cooperation of the devices with the CPU
is setting up virtual devices. Virtual devices are devices that are not physically
in the computer - instead they are portions of main memory
that are allocated to the operating system and may be accessed by programs
and/or users as if they were devices. |
|
Because access time for main memory is very small, virtual devices are fast.
They share, however, also the disadvantages of memory: they are only transient
storage media (data is lost if the computer is switched off) and they are
expensive (because memory is).
If the computer is short of memory anyway then there will be no space
therein to create virtual devices.
|
| Buffers |
|
Buffers are sort of a virtual device. Buffers are small containers of data that
are used to store the input/output of storage media and other devices temporarily.
They are portions of main memory as well but neither programs nor users can
access them; they are only accessable by the I/O-processor on one side and
devices on the other. |
|
Simple Buffering works like that: Alsways when a process issues
an I/O request to a device the device is searching for the place the data
is/will be stored. If the search process is finished the device starts to
transmit data. From that time on the CPU must be ready to receive data from
that device, that is: no other process can be in the CPU anymore.
However, the CPU can receive and process (mostly: store in main memory)
these pieces of data much faster than any device can send -it is idle in between;
CPU time is wasted. With buffering the data from the device do not reach the CPU directly. The I/O processor is bypassing them to a small portion (usually up to a few KBytes big) of main memory, the buffer, and only when the buffer is nearly full, a request to empty it is sent to the CPU. It can then process the data at once, saving much time for not being forced to wait for data from the device. |
|
Double Buffering is a more advanced buffering technique: The problem with
simple buffers is that at a time the buffer is nearly full the CPU must be ready
to empty it, no matter what it is busy doing at the moment. Otherwise,
buffer overflow could happen, that is data loss because of overwriting
data in the buffer that has not yet been processed by the CPU. Double buffering offers two buffers for every device, and the request to empty one of them is issued the time one buffer is full. The CPU has now time to process the data until the second buffer is filled up. This method is a bit more flexible than simple buffering, and not so many processes have to be preempted because of nearly full buffers.
|
| Direct Memory Access (DMA) |
| For relatively fast devices (hard disks) buffering is not sufficient: In everyday use, a floppy disk drive or a CD-ROM is hardly ever used, whereas a harddisk is busy very often. So if a harddisk were buffered, the CPU would frequently be to empty its buffers. |
|
That's not what a CPU is good for; we would like the central processor mainly to
spend its time on calculation rather then on I/O-overhead. With Direct Memory Access (DMA) fast devices get dedicated connections to main memory along with the access rights to use it. So the CPU only has to send a request to the hard disk. All other work is done by the hdd and the I/O processor in cooperation. After the requested data has arrived completely in main memory the CPU gets a message indicating that. It can then immediately use the data. |
| DMA is a hardware solution: A computer that is not physically equipped with DMA channels cannot make use of it because it lacks the direct line from the I/O processor to memory. |