0% found this document useful (0 votes)
48 views20 pages

Computer System Structures: Printer Disk Tape Drive

1. A computer system consists of a CPU, device controllers connected via a shared bus to memory. 2. Each device controller handles a specific device type. The memory controller synchronizes access to shared memory. 3. When powered on, a bootstrap program initializes the system and loads the operating system kernel.

Uploaded by

Red Streak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views20 pages

Computer System Structures: Printer Disk Tape Drive

1. A computer system consists of a CPU, device controllers connected via a shared bus to memory. 2. Each device controller handles a specific device type. The memory controller synchronizes access to shared memory. 3. When powered on, a bootstrap program initializes the system and loads the operating system kernel.

Uploaded by

Red Streak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

COMPUTER SYSTEM STRUCTURES

COMPUTER SYSTEM OPERATION

 A modern, general-purpose computer system consists


of a CPU and a number of device controllers that are
connected through a common bus that provides access
to shared memory.

Printer Tape Drive

Disk

Disk Printer Tape Drive


CPU
Controller Controller Controller
System
Bus
Memory
Controller

Memory

 Each device controller is in charge of a specific type


of device.

 The CPU and the device controllers can execute


concurrently, competing for memory cycles. To
ensure orderly access to the shared memory, a
memory controller is provided whose function is to
synchronize access to the memory.

Computer System Structures 1


 When a computer is powered up or rebooted, the
bootstrap program is first loaded. Typically, it is
stored in ROM/EEPROM within the computer
hardware. This program initializes all aspects of the
system, from CPU registers to device controllers to
memory contents. It then locates and loads the
operating system kernel. From then on, the operating
system takes over the computer system.

 Modern operating systems are interrupt driven. If


there are no processes (programs) to execute, no I/O
devices to service, and no users to whom to respond,
an operating system will sit quietly, waiting for
something to happen. If a process, device, or user
needs service from the operating system, it sends an
interrupt signal.

Events are almost always signalled by the occurrence


of an interrupt or a trap. A trap (or an exception) is a
software-generated interrupt caused either by an error
(for example, division by zero or invalid memory
access) or by a specific request from a user program
that an operating-system service be performed.

 The interrupt-driven nature of an operating system


defines that system’s general structure. For each type
of interrupt, separate segments of code, called
interrupt-service routines, in the operating system
determine what action should be taken.

Computer System Structures 2


I/O INTERRUPTS

 A general-purpose computer system consists of a CPU


and multiple device controllers.

 Each device controller is in charge of a specific type


of device. Depending on the type of controller, there
may be more than one attached device.

 Once an I/O operation is started, two courses of action


are possible. In the simplest case, the I/O is started;
then, at I/O completion, control is returned to the user
process. This case is known as synchronous I/O.

The other possibility, called asynchronous I/O,


returns control to the user program without waiting for
the I/O to complete. The I/O then can continue while
other system operations occur.

 If the CPU waits for I/O completion, at most one I/O


request is outstanding at a time. So this approach
excludes concurrent I/O operations to several devices,
and also excludes the possibility of overlapping useful
computation with I/O.

A better alternative is to start the I/O and then


continue processing other operating-system or user
program code. Once the I/O process has completed
or if it needs additional service, it will send an
interrupt signal. In this manner, several I/O requests
can be entertained at any one time.

Computer System Structures 3


 The operating system must keep track of many I/O
requests occurring at any instant. For this purpose, it
uses a table containing an entry for each I/O device:
the device-status table.

device: keyboard
status : idle
request for printer
device: printer
address : 38546
status : busy
length : 1372
device: disk 1
status : idle
request for disk 2 request for disk 2
device: disk 2
status : busy
file : xxx file : yyy
. operation : read operation : write
. address : 43046 address : 03458
. length : 20000 length : 500

Each table entry indicates the device type, address,


and state (not functioning, idle, or busy). If the device
is busy with a request, the type of request and other
parameters will be stored in the table entry for that
device.

Since it is possible for other processes to issue


requests to the same device, the operating system will
also maintain a wait queue – a list of waiting requests
– for each I/O device.

Computer System Structures 4


 An I/O device interrupts when it needs service. When
an interrupt occurs, the operating system first
determines which I/O device caused the interrupt. It
then indexes into the I/O device table to determine the
status of that device and modifies the table entry to
reflect the occurrence of the interrupt.

For most devices, an interrupt signals completion of


an I/O request. If there are additional requests waiting
in the queue for this device, the operating system
starts processing the next request.

Finally, control is returned from the I/O interrupt. If a


process was waiting for this request to complete (as
recorded in the device-status table), the system can
now return control to it. Otherwise, the system will
return to whatever it was doing before the I/O
interrupt. In a time-sharing system, the operating
system could switch to another ready-to-run process.

 The main advantage of asynchronous I/O is increased


system efficiency. While I/O is taking place, the
system CPU can be used for processing or starting
I/Os to other devices. Because I/O can be slow
compared to processor speed, the system makes
efficient use of its facilities.

Computer System Structures 5


DMA STRUCTURE

 Consider the following scenario:

1. A computer terminal transmitting data to a


computer (via a terminal controller) at a speed of
9,600 bps. This translates to 960 characters per
second assuming 10 bits per character. In effect,
the terminal takes 1,000 µs to transmit a
character.

2. Each character received by the terminal


controller generates an interrupt to the CPU.
This causes an interrupt-service routine to
execute that will transfer the character from the
controller to the CPU.

3. Assume that it takes 2 µs for the interrupt service


routine to execute.

4. This leaves 998 µs for every 1,000 µs for CPU


computation (and for servicing of other
interrupts).

Given this disparity, asynchronous I/O (such as a


terminal) is usually assigned a low interrupt priority,
allowing other, more important interrupts to be
processed first.

Computer System Structures 6


 However, a high-speed device such as a disk or a
communications network may be able to transmit
information close to memory speeds; if the CPU needs
2 µs to respond to each interrupt and interrupts occur
every 4 µs, for example, that does not leave much
time for process execution.

 To solve this problem, direct memory access (DMA)


is used for high-speed I/O devices. DMA allows
devices to transfer blocks of data directly to or from
the memory, with no intervention by the CPU.

In this way, only one interrupt is generated per block,


rather than one interrupt per byte (or word) generated
by low-speed devices.

 While the DMA controller is performing the data


transfer, the CPU is free to perform other tasks. The
DMA controller interrupts the CPU when the transfer
has been completed.

Computer System Structures 7


STORAGE STRUCTURE

 Computer programs must be in main memory (also


called random-access memory or RAM) to be
executed.

 Main memory is the only large storage area (millions


to billions of bytes) that the processor can access
directly.

 Main memory is composed of an array of memory


words. Each word has its own address. Interaction is
achieved through a sequence of load or store
instructions to specific memory addresses. The load
instruction moves a word from main memory to an
internal register within the CPU, whereas the store
instruction moves the contents of a register to main
memory.

 Ideally, programs and data should reside in main


memory permanently. However, this arrangement is
not possible for the following two reasons:

1. Main memory is usually too small to store all


needed programs and data permanently.

2. Main memory is a volatile storage device that


loses its contents when power is turned off or
otherwise lost.

Computer System Structures 8


 Thus most computer systems provide secondary
storage as an extension of main memory. The main
requirement for secondary storage is that it is able to
hold large quantities of data permanently.

 The most common secondary storage device is the


magnetic disk. Most programs are stored on a disk
until they are loaded into memory. Any instructions
in execution, and any data being used by the
instructions, must be in main memory.

 A magnetic disk system has several disk platters.


Each disk platter has a flat circular shape, like a CD.
A magnetic material, similar to that of a magnetic tape
or floppy diskette, covers its two surfaces.
Information is recorded on the surfaces.

READ/WRITE HEAD

DISK

ROTATING SHAFT

Computer System Structures 9


 The disk surface is logically divided into circular
tracks, which are subdivided into sectors. The system
stores information by recording it magnetically on the
sector under the read-write head.

Computer System Structures 10


 The set of tracks that are at one arm position forms a
cylinder.

There may be hundreds of concentric cylinders on a


disk surface, containing thousands of sectors. The
platter itself may be between 1.8 inches and 5.25
inches wide. The storage capacity of common disk
drives is measured in gigabytes.

 When the disk is in use, a drive motor spins it at a


high speed (for example, 60 to 200 revolutions per
second). There is a read-write head positioned just
above the surface of the platter.

 The time it takes to access a sector depends on three


parameters, the seek time, rotational latency, and
transfer time.

Seek time (also called positioning time) is the time it


takes to move the read-write head to the correct
cylinder while the rotational latency is the time it
takes for the desired sector to rotate under the head.
Transfer time is the time it takes to actually transfer
data between disk and main memory.

 The head does not actually touch the surface of a disk.


Instead, it floats or flies only microns from the disk
surface, supported by a cushion of air.

Computer System Structures 11


 Head crashes can be problem. If the head contacts the
disk surface (due to power failure, for example), the
head will scrape the recording medium off the disk,
destroying data that had been there.

Usually, the head touching the surface causes the


removed medium to become airborne and to come
between the other heads and their platters, causing
more crashes. Under normal circumstances, a head
crash results in the entire disk failing and needing to
be replaced.

 Floppy disks take a different approach. The disks are


coated with a hard surface, so the read-write head
scans it directly on the disk surface without destroying
the data. The coating (and the read-write head) will
wear with use, however, and need to be replaced over
time.

 Magnetic tapes were used as an early secondary-


storage medium. Although it is relatively permanent
and can hold large quantities of data, its access time is
slow in comparison to that of main memory and
magnetic disks.

Tapes are used mainly for backup, for storage of


infrequently used information, and as medium for
transferring information from one system to another.

Computer System Structures 12


STORAGE HIERARCHY

 The wide variety of storage systems in a computer


system can be organized in a hierarchy according to
speed and cost.

registers

cache

main memory

electronic disk

magnetic disk

optical disk

magnetic tapes

The higher levels are expensive, but they are fast.

 The top three levels of memory (registers, cache, and


main memory) may be constructed using
semiconductor memory. They are also volatile (they
lose their contents when power to the device is
removed).

Computer System Structures 13


 An electronic disk can be designed to be either
volatile or non-volatile. During normal operation, the
electronic disk stores data in a large DRAM array
(dynamic RAM), which is volatile. But many
electronic-disk devices contain a hidden magnetic
hard disk and a battery for backup power.

If external power is interrupted, the electronic-disk


controller copies the data from RAM to the magnetic
disk. When external power is restored, the controller
copies the data back into the RAM.

 The design of a complete memory system must


balance all these factors: It uses only as much
expensive memory as necessary, while providing as
much inexpensive, non-volatile memory as possible.

 Caches can be installed to improve performance


where a large access-time or transfer rate disparity
exists between two components.

Caching is an important principle of computer


systems. Information is normally kept in main
memory. As it is used, it is copied into a faster
storage system – the cache – on a temporary basis.

Computer System Structures 14


HARDWARE PROTECTION

 Recall that multiprogramming allows the operating


system and two or more user programs to reside in the
main memory at the same time.
Operating
System
Job 1

Job 2

Job 3

Job 4

 One potential problem in this is that an erroneous


program might modify the program or data of another
program or even the operating system itself.

 A properly designed operating system must ensure


that an incorrect (or malicious) program cannot cause
other programs to execute incorrectly.

 To ensure proper operation, there must be hardware


support that allows various modes of execution:

1. User Mode. The CPU enters this mode if it is


executing a user program.

2. Monitor Mode. The CPU is in this mode if it is


executing a task on behalf of the operating
system. Also called the supervisor mode, system
mode, or privileged mode.

Computer System Structures 15


 Machine instructions that may cause harm to other
programs (such as a memory write instruction) are
designated as privileged instructions. The hardware
allows privileged instructions to be executed only in
monitor mode. If an attempt is made to execute a
privileged instruction in user mode, the hardware does
not execute the instruction.

 Through this, there is a means for the user to interact


with the operating system by asking the system to
perform some designated tasks that only the operating
system should do. Such a request is known as a
system call (also called a monitor call or an operating
system function call).

 The lack of a hardware-supported dual mode can


cause serious shortcomings in an operating system.

For instance, MS-DOS was written for the Intel 8088


architecture, which does not have dual mode of
execution. A user program running awry can wipe out
the operating system by writing over it with data, and
multiple programs are able to write to a device at the
same time.

More recent and advanced versions of the Intel CPU,


such as the Pentium, do provide dual-mode operation.
As a result, more recent operating systems take
advantage of this feature and provide greater
protection for the operating system.

Computer System Structures 16


I/O PROTECTION

 A user program may disrupt the normal operation of


the system by issuing illegal I/O instructions (such as
an attempt to use an I/O device while it is being used
by another program).

 To prevent users from performing illegal I/O, all I/O


instructions are defined to be privileged instructions.
Therefore, users cannot issue I/O instructions directly;
they must do it through the operating system.

 To make I/O protection complete, it must be ensured


that a user program can never gain control of the
computer in monitor mode.

 To do I/O, a user program executes a system call to


request that the operating system perform I/O on its
behalf. The operating system, executing in monitor
mode, checks that the request is valid, and (if the
request is valid) does the I/O requested. The
operating system then returns to the user.

Computer System Structures 17


MEMORY PROTECTION

 In general, it is necessary to protect the operating


system from access by user programs, and in addition,
to protect user programs from one another. This
protection must be provided by hardware.

 To separate each program’s memory space, there is a


need for the ability to determine the range of legal
addresses that the program may access, and to protect
the memory outside that space.

 This hardware protection can be provided by using


two registers, usually a base register and a limit
register.

0
Operating
System
256000 base register
Job 1
300040 300040
Job 2 limit register
420940 120900
Job 3
880000
Job 4
1024000

The base register holds the smallest legal physical


memory address; the limit register contains the size of
the range.

Computer System Structures 18


 This protection is accomplished by the CPU hardware
comparing every address generated in user mode with
the registers. Any attempt by a program executing in
user mode to access operating system memory or
other users’ memory results in a trap to the operating
system, which treats the attempt as a fatal error.

The address issued by a certain program must be


between its base and base + limit.

base base + limit

yes yes
CPU >= < to MM
address

no no

trap to operating system trap to operating system


monitor -- monitor --
addressing error addressing error

This prevents the user program from (accidentally or


deliberately) modifying the code or data structures of
either the operating system or other users.

The base and limit registers can be loaded by only the


operating system which uses a special privileged
instruction.

Computer System Structures 19


CPU PROTECTION

 In addition to protecting I/O and memory, it must be


ensured that the operating system maintains control.
User programs must be prevented from getting stuck
in an infinite loop and never returning control to the
operating system.

 To accomplish this goal, a timer is used. A timer can


set to interrupt the computer after a specified period.

Before turning over control to the user, the operating


system ensures that the timer is set to interrupt. If the
timer interrupts, control transfers automatically to the
operating system, which may treat the interrupt as a
fatal error or may give the program more time.

Clearly, instructions that modify the operation of the


timer are privileged.

 A more common use of a timer is to implement time


sharing. In the most straightforward case, the timer
could be set to interrupt every N milliseconds, where
N is the time slice that each user is allowed to execute
before the user gets control of the CPU.

Computer System Structures 20

You might also like