Department of Applied Physics & Electronic Engineering: Course: APEE (R) - 208 Operating System and Programming
Department of Applied Physics & Electronic Engineering: Course: APEE (R) - 208 Operating System and Programming
Department of Applied Physics & Electronic Engineering: Course: APEE (R) - 208 Operating System and Programming
Permanent
Storage
All computer systems, no matter how small or large, have the same fundamental capabilities:
processing, storage, input and output. Input unit includes devices like keyboard and mouse,
which are used by the user to give some data to the computer. Processing unit is where these
data are processed and turned into meaningful information. Processing unit also includes
temporary storage (RAM) in which the data currently being processed are stored
temporarily. To show the result of processes, to the user, output devices like monitors and
printers are used. The output on a monitor is usually called softcopy and the output on a
printer is usually called hardcopy. Sometimes we may want to store our data and information
permanently so that we can refer to them again, later. For this purpose, interchangeable
devices like floppy disk drives and CD-ROM drives, or permanently installed devices like
hard disks are used as permanent storage mediums.
The following are the hardware components that exist almost in all PCs.
CPU: It is the brain of a computer system. It is the component, which controls what’s going
on in the system at any moment. Other components act according to the orders of the CPU.
All the current inputs and any previously stored data are processed by the CPU to obtain
meaningful information.
RAM: It is the primary memory of a PC. Anything in a secondary storage device (permanent
storage) that has to be processed by the CPU, must first be loaded to RAM, because there are
no machine instructions to directly access and use any data which is stored in a secondary
storage medium. RAM is a volatile memory, therefore if an electricity cut or a reset should
occur, all the data in RAM are lost.
Harddisk: It is one of the most popular secondary storage devices. It is a magnetic medium
that stores its contents permanently, even in the absence of electricity power. You store your
documents, pictures, photos, songs, etc in Harddisks.
Floppy Disk Drive: It is a device into which you insert interchangeable floppy disks. Floppy
disks are also magnetic storage mediums. FDDs works much slower than Harddisks and
floppy disks have much smaller storage capacities. Floppy disks are usually used to copy
some files from your PC to another PC, vice versa.
Graphics Card: This circuit board is responsible from the visual outputs that will be
displayed on the monitor. Nowadays, graphics cards have their own memory modules and
processor chips, by which they lessen the load of CPU and RAM, hence enabling us to see
very detailed graphics and high quality animations and video.
PCs are general-purpose devices that can be used in many areas of interest, and of course
there exists many other hardware components that can be added to them to increase their
functionalities. These include CD-ROM drives, sound cards, radio cards, TV cards, modem
cards, etc…
A very simple model of a computer is shown in Figure 2.1. At its simplest, the Central
Processing Unit (CPU) is a glorified calculator, the memory stores the results of calculations
– it is a set of labeled cells – the label is called the address, each cell contains a number –
data. The bus is simply a pipeline along which data and addresses can flow.
Both data and addresses are stored as numbers, though data numbers may be interpreted
otherwise, e.g. as text characters. As well as containing data, the memory also contains the
program – in the form of numeric instructions. Ultimately, everything is reduced to numbers.
In a programming language, cells are called variables, variable names are easy to remember
names for memory cells: e.g. x at memory cell 0, y at 1, z at 2; therefore in Figure 2.1 the
value in x is 22, in y, 33, and in z, 0. Note the difference between address (for y, it is 1) and
data or value (for y it is 33). Note: the terms memory cell, location, address are often used
interchangeably.
2.2.1 Introduction
The ALU is the calculator part. The ALU takes the contents of ALU input buses A and B and
combines them in some way (add, subtract, logical OR, etc.) and passes the result onto a C
data bus. Let us assume that this is a 16-bit machine, i.e. the buses and ALU take 16-bit
numbers – they are 16-bits wide.
A simple ALU is shown in Figure 2.4. It has a number of functions which are selected by
function selection control lines F; the control lines are equivalent to selecting the operation on
3
a calculator, e.g. add, subtract. Two condition flags are output: N, set to 1 if last operation
caused a negative result; Z, last operation, if a zero result; result flags are important for
constructing conditional instructions (if, else).
Figure 2.3 gives a view of a simplified CPU – but not so simplified that we cannot describe
how an actual program might operate in it; with few additions figure 2.3 would actually work.
The major thing we have left out is control.
In addition to the buses – both internal and system – the system bus is one on the far left), and
ALU, all mentioned before, we have just three new items: the memory address register
(MAR), the memory buffer register (MBR), and the accumulator register(AC).
Conceptually, registers are no different from main memory cells.
The MAR and MBR are used for communicating with memory: when the CPU needs to read
load from memory, it puts the address of the required item into MAR, asserts read on the
control part of the system bus, some time later, the system bus will transfer the relevant data
item into the MBR; for write store, it puts the address in MAR, the data in MBR, and asserts
write, the data are then copied into the relevant memory location. The AC is used as a general
holding register for operand (input) data and results. All will become clear if we return to the
example program statement:
z = x + y;
As in the introduction, assume that z corresponds to location 2, x to 0, and y to 1. The
program, as it would appear in machine instructions, is:
4
P1. Load contents of location 0 (x, 22) into AC.
P2. Add contents of 1 (y, 33) to AC, with result going to AC.
P3. Store contents of AC in location 2 (z).
2.5 Software
Without software, the system in Figure 2.1 just sits there quietly, doing nothing! It must be
programmed with appropriate software. Roughly, software can be divided into two categories:
The divide, between system and application, can be somewhat blurred. In general, the more
general purpose and ordinary the function performed – like copying or deleting files, or
compiling or assembling programs – the closer to system software; the more special purpose –
like a database management system – the closer to application category.
Originally, the system software was likely to be developed by the computer hardware
manufacturer; however, since the 1980s, the PC revolution has turned this on its head.
The most important item of system software is the operating system.
A computer program is a set of instructions for a computer. The instructions must be correct –
to the finest detail; computers know nothing other than what is in their programs. (That is
where the cookery recipe analogy can fail a little – in a cookery recipe, we assume that the
cook needs instructions only to a certain level; for example, we don’t see instructions on how
to boil water, or how to crack an egg.)
At present, we will assume that the computer knows how to add, subtract, read/load from
memory, store/write to memory, but little more.
A dictionary definition of abstraction (the verb) is: the process of considering (extracting)
certain essential properties of objects while omitting other properties that are not relevant
(usually inessential details); the act of abstraction or abstracting produces an abstraction
(noun) which collectively refers to the set of chosen properties.
From our point of view abstraction does have two important facets which are related but
different, namely, extraction (of the essential from the inessential) and idealisation (i.e. the
irrelevant details are deviations from the ideal). Often, somewhat loosely, an abstraction may
be called a model.
The key concept here is probably that of a black-box abstraction; a black-box model simplifies
a system down to:
5
*what it expects as inputs;
*what it produces as outputs; and,
*the relationship between the inputs and the outputs.
A computer can be viewed as a hierarchy of levels as shown below. At any one time you
make up your mind what level concerns you.
Level 5 Application Level Here the computer is viewed as a machine which performs a
specific function, e.g. a spreadsheet, a word-processor; the user at this level shouldn’t have to
be concerned with any details of computer science or engineering, just as the average car
driver need not be concerned with the internal details of car engines.
Level 4 High-level Language Level Here the computer is viewed as a (virtual) machine
which obeys the instructions or understands the statements of a high-level language such as C,
C++, Java, COBOL, etc. A compiler or interpreter converts these instructions into lower level
machine or assembly code.
Level 3 Operating System Machine Level At this level, we have operating system software
in charge of executing the machine language (see level 2). In some contexts, this level is
absent.
Level 2 Machine Language Level Here are the same sort of instructions that we described
for the previous level: major difference, they are now coded as numbers, rather than
alphanumeric symbols
(e.g. 2501 instead of (say) ADDD x). Two points: (a) they are ready for execution in the
processor
– the Level 1 machine ‘understands’ them; and, (b) human programmers have great difficulty
in understanding them!
Level 1 Microprogram Level This level is concerned with the (underlying) engine that
implements individual Level 2 instructions by appropriately directing the the components and
their interconnections at that level. In some (mostly earlier, but also some modern RISC
machines) machines this level does not exist and machine instructions are implemented
directly by digital logic.
Level 0 Digital Logic Level Here we are at the level of gates and memory cells. The
language is made up of 1s and 0s or, at best, binary numbers.
There are certainly levels below level 0 – transistors, p-n junctions, molecules, atoms, . . . !),
but the six above should be enough for us except for brief mention of how to make digital
logic components out of transistors.
At each level, the user, programmer, engineer, or physicist must pay attention to different
sorts of object or quantity. At level 4 (high-level language,), the programmer deals with the
data types provided by the language. At level 2 you are forced to deal with physical storage
6
locations, registers and the like. And so on, until at level 0 you are concerned with bits (1s and
0s).
The major point is that, the higher the level of abstraction, the more powerful the machine
becomes. For example, you want to type a letter on a word-processor. At level 5 you just do
it. At level 4 you first have to write a word-processor program – allocate a few years or so for
that!
And so on. Down to level 0, where you first have to make a computer from thousands of
chips, then write the microcode, . . . , then write the compiler, the write the word-processor, . .
. , then type the letter.
The difference between working at level 4 (say) and level 2 is like discovering that you can
take 100 metre strides, instead of the 1.5 meters of ordinary mortals.
The Operating System Executes all the Time — well, sort of I am tempted to say that,
from then on, the operating system (program) runs all the time until the the computer is
switched off. However, we all know that only one program can be running on a single
processor at any time; and most computers operate with just one processor. What about the
applications we want to run — our word processor, or spreadsheet, our games . . .
The Operating System is in charge of the computer We can revise that statement to say
that the operating system is in charge of the computer all of the time. To show how a simple
program (the operating system) can be in charge, or manages, the computer, yet relinquish the
processor to other programs, is one of the major objectives of this course. Note: I use the term
in charge because I want to reserve the term control; when we say transfer of control (to a
program), we mean that the instructions of this program beging to execute on the processor –
and the operating system (and other programs), for the moment, slide into the background.
The Operating System as a platform for executing software Another useful way of
thinking about the operating system is that it provides a platform or environment (a virtual
machine) upon which to run your application software and provides an interface with which
you the user interact with the machine. In this view, the operating system provides a layer that
separates the application software and the user from the hardware.
The Operating System provides services When an operating system is viewed as a platform
for executing software (and for interfacing with humans), we can see that it provides services.
For example: reading from, and saving to disks; sending data to a printer, etc.
7
operating system service. Since accessing hardware directly is difficult and some application
programs are written by less skilled programmers, directly accessing hardware was a common
source of errors and frequently resulted in the systems crashing.
Operating systems that adopt this more modern approach are therefore more reliable — there
are fewer occurrences of the blue screen of death!
In this sense, the operating system can be seen as a police force or government. And just like
governments require you to pay taxes (for the services they claim to provide) the operating
system demands a certain amount of CPU time for itself.
8
Introduction
The purpose of these lectures is to relate our views on this type of course, to describe how we
offer the course at our institution, and to assess the effectiveness of our course. Key aspects of
our approach include:
Figure 1 shows a block diagram for Von Neumann computer model. The major parts of this
model are the central processing unit (CPU), memory, and the Input and output circuitry or
l/O. Connecting these parts are three sets of parallel lines called buses. The three buses are the
address bus, the data bus, and the control bus. Let’s take a brief look at each of these parts.
Data Bus
Control Bus
Address Bus
Input/Output
The input/output or I/O section allows the computer to take in data from the outside world or
send data to the outside world. Peripherals such as keyboards, video display terminals,
printers, and modems are connected to the I/O section. These allow the user and the computer
to communicate with each other. The actual physical devices used to interface the computer
buses to external systems are often called ports. Ports in a computer function Just as shipping
ports do for a count. An input port allows data from a keyboard, an A/D converter, or some
other source to be read into the computer under control of the CPU. An output port is used to
send data from the computer to some peripheral, such as a video display terminal, a printer, or
a D/A converter. Physically, the simplest type of input or output port is just a set of parallel D
flip-flops. If they are being used as an input port, the D inputs are connected to the external
device, and the Q outputs are connected to the data bus which runs to the CPU. Data will then
be transferred through the latches when they are enabled by a control signal from the CPU. In
a system where they are being used as an output port, the D inputs of the latches are
connected to the data bus, and the Q outputs are connected to some external device. Data sent
out on the data bus by the CPU will be transferred to the external device when the latches are
enabled by a control signal from the CPU.
Data Bus
The data bus consists of 8, 16, or 32 parallel signal lines. As indicated by the double-ended
arrows on the data bus line in Figure 1, the data bus lines are bidirectional. This means that
the CPU can read data in from memory or from a port on these lines, or it can send data out to
memory or to a port on these lines. Many devices in a system will have their outputs
connected to the data bus, but only one device at a time will have its outputs enabled. Any
device connected on the data bus must have three-state outputs so that its outputs can be
disabled when it is not being used to put data on the bus.
Address Bus
The address bus consists of 16, 20, 24, or 32 parallel signal lines. On these lines the CPU
sends out the address of the memory location that is to be written to or read from. The number
of memory locations that the CPU can address is determined by the number of address lines.
If the CPU has N address lines, then it can directly address 2N memory locations. For example,
a CPU with 16 address lines can address 216 or 65,536 memory locations, a CPU with 20
address lines can address 220 or 1,048,576 locations, and a CPU with 24 address lines can
address 224 or 16,777,216 locations. When the CPU reads data from or writes data to a port, it
sends the port address out on the address bus.
Control Bus
The control bus consists of 4 to 10 parallel signal lines. The CPU sends out signals on the
control bus to enable the outputs of addressed memory devices or port devices. Typical
control bus signals are Memory Read, Memory Write, I/O Read, and l/O Write. To read a
byte of data from a memory location, for example, the CPU sends out the memory address of
the desired byte on the address bus and then sends out a Memory Read signal on the control
bus. The Memory Read signal enables the addressed memory device to output a data word
onto the data bus. The data word from memory travels along the data bus to the CPU.
• Analogue/Digital Interface
To interface two peripherals one of them is digital and the other one is analog we have to
add analog to digital converter (ADC) and digital to analog converter (DAC). See figure 2.
ADC
Analog Digital
DAC
Synchronized Asynchronized
Handshaking
System System
Device
• Serial/Parallel Interface
To interface two peripherals one of them is parallel and the second is serial we have to use
parallelizing and serializing stages to connect both of them. The parallelizing stage
converts the serial pulses into parallel data while the serializing stage converts the parallel
data into serial pulses. See figure 4.
Parallelizing
Serial Parallel
Serializing
The microprocessor can be interfaced with the peripherals via several techniques, they are:
1. Memory space interface. This is the most common type. It is flexible and reliable to be
applied in any application. Moreover it supports data cash transfer. It can also be
accomplished by several data communication techniques. The drawback of this
technique is the complicated design and usage.
2. I/O ports interface such as serial and parallel ports. I/O port interface is simpler but
less efficient and than memory interface.
3. Interrupts (Hard interrupts)
4. Direct bus interface using internal buses such as ISA, EISA, PCI, USB, AGP, see
figure 5.
5. Indirect bus interface using external buses such as GPIB, SCSI, CAMAC, etc., see
figure 5.
Motherboard
Internal External
Microprocessor Peripheral
Bus Bus
Indirect bus interface
Peripheral
Bus
When referring to a computer, the bus also known as the address bus, data bus, or local bus is
a data connection between two or more devices connected together. For example a bus
enables a computer processor to communicate with the memory or a video card to
communicate with the memory.
A bus is capable of being (parallel or a serial bus), (Synchronized or Asynchronized) and
today all computers utilize two types of buses, an internal or local bus and an external bus. An
internal bus enables a communication between internal components such as a computer video
card and memory (e.g. ISA, EISA, PCI, AGP, etc.) and an external bus is capable of
communicating with external components such as a SCSI bus, CAN, CAMAC, GPIB, etc.
A computer or devices bus speed or throughput is always measured in bits per second or
megabytes per second.
The bus is not only cable connection but also hardware (bus architecture),
protocol, software, and bus controller
BUS Basics
A computer bus is a method of transmitting data from one part of the computer to another part
of the computer. The computer bus connects all devices to the computer CPU and main
memory. The computer bus consists of three parts the address bus, a data bus and control
bus. The data bus transfers actual data whereas the address bus transfers information about
where the data should go. The control bus exchanges all control signals. The following part
contains a brief overview on each of the computer buses.
Definitions:
1- PnP
Short for Plug and Play, PnP is an ability of a computer to detect and configure a new piece
of hardware automatically, without the requirement of the user to physically configure the
hardware device with jumpers or dipswitches. Plug and Play was introduced on IBM
compatible computers with the release of Microsoft Windows 95, where Apple Macintosh
computers have always supported the ability to automatically detect and install hardware.
For Plug and Play to operate properly on IBM compatible computers the user must have the
following:
Today all new computers have PnP capabilities. Computers running Microsoft Windows XP
no longer support non PnP devices.
Also known as "communication speed", throughput is a numerical value used to illustrate the
total amount of data transferred being transferred through the computer or device at that given
time. This number is commonly represented in bits per second (bps) or bytes per second
(Bps).
3- Proprietary
Term used to describe a product that is only compatible with a specific type of hardware,
software, computer or manufacturer. When referring to computer hardware, it is
recommended that you do not choose a proprietary device as it reduces compatibility and
generally the capability of upgrading that product in the future.
ISA BUS
Introduced by IBM, ISA or Industry Standard Architecture was originally an 8-bit bus that
was later expanded to a 16-bit bus in 1984. When this BUS was originally released it was a
proprietary BUS, which allowed only IBM to create peripherals and the actual interface.
However in the early 1980's other manufacturers were creating the bus.
In 1993, Intel and Microsoft introduced a PnP ISA bus that allowed the computer to
automatically detect and setup computer ISA peripherals such as a modem or sound card.
Using the PnP technology an end-user would have the capability of connecting a device and
not having to configure the device using jumpers or dipswitches.
To determine if an ISA card is an 8-bit or 16-bit card physically look at the card. You will
notice that the first portion of the slot closest to the back of the card is used if the card is an 8-
bit card. However, if both sections of the card are being utilized the card is a 16-bit card.
Many manufacturers are trying to eliminate the usage of the ISA slots however for backwards
compatibility you may find 1 or 2 ISA slots with additional PCI slots, AGP slots, etc.
However, today you may also have a motherboard that has no ISA slots. We highly
recommend when purchasing any new internal expansion card that you stay away from ISA
as it has for the most part disappeared.
MCA BUS
Short for Micro Channel Architecture, MCA was introduced by IBM in 1987, MCA or the
Micro Channel bus was a competition for ISA BUS. The MCA bus offered several additional
features over the ISA such as a 32-bit bus, automatically configure cards (similar to what Plug
and Play is today), and bus mastering for greater efficiency.
One of the major downfalls of the MCA bus was it being a proprietary BUS and because of
competing BUS designs. The MCA BUS never became widely used and has since been fazed
out of the desktop computers.
EISA BUS
Short for Extended Industry Standard Architecture, EISA was announced September of
1988. EISA is a computer bus designed by 9 competitors to compete with IBM's MCA BUS.
These competitors were AST Research, Compaq, Epson, Hewlett Packard, NEC, Olivetti,
Tandy, WYSE, and Zenith Data Systems.
The EISA Bus provided 32-bit slots at an 8.33 MHz cycle rate for the use with 386DX, or
higher processors. In addition the EISA can accommodate a 16-bit ISA card in the first row.
Unfortunately, while the EISA bus is backwards compatible and is not a proprietary bus the
EISA bus never became widely used and is no longer found in computers today.
PCI BUS
Introduced by Intel in 1992, revised in 1993 to version 2.0, and later revised in 1995 to PCI
2.1. PCI is short for Peripheral Component Interconnect and is a 32-bit computer bus that
is also available as a 64-bit bus today. The PCI bus is the most commonly used and found bus
in computers today.
MINI PCI
Mini PCI is a new standard which measures at 2.75-inch x 1.81-inch x 0.22-inch is a new
standard developed by leading notebook manufactures. This technology could allow
manufactures to lower their price as the motherboards would be simpler to design.
Type I - Identical to Type II, except requires extra cables for connectors like the RJ-11 and
RJ-45. However, offers more flexibility to where it can be placed in the computer.
Type II - Used when size is not important. Type II is able to integrate the RJ-11 and RJ-45
connectors and due away with extra cables.
Type III - SO-DIMM style connector that can be installed with a mere 5 mm overall height
above the system board. In addition cabling to the I/O connectors allow Type III cards to be
placed anywhere in the system.
PCI-X
PCI-X is a high performance bus that is designed to meet the increased I/O demands of
technologies such as Fiber Channel, Gigabit Ethernet and Ultra3 SCSI. PCI-X capabilities
include:
Introduced by Intel in 1997, AGP or Advanced Graphic Port is a 32-bit bus designed for
the high demands of 3-D graphics. AGP has a direct line to the computers memory which
allows 3-D elements to be stored in the system memory instead of the video memory.
For AGP to work in a computer must have the AGP slot which comes with most Pentium II
and Pentium III machines. The computer also needs to be running Windows 95 OSR2.1,
Windows 98, Windows 98 SE, Windows 2000, Windows ME or higher.
USB Bus
USB (Universal Serial Bus) is a new external bus developed by Intel, Compaq, DEC, IBM,
Microsoft, NEC and Northern Telcom and released to the public in 1996 with the Intel
430HX Triton II Mother Board. USB has the capability of transferring 12 Mbps, supporting
up to 127 devices and only utilizing one IRQ. For PC computers to take advantage of USB the
user must be running Windows 95 OSR2, Windows 98 or Windows 2000. Linux users also
have the capability of running USB with the proper support drivers installed. To determine if
your computer supports USB on the back, front or sides of the computer look for a small
connector with the following symbol.
USB cables are hot swappable which allows users to connect and disconnect the cable while
the computer is on without any physical damage to the cable.
The above illustration is an example of what the end of a USB connector looks like. There
are two standards of USB connectors. Type A connectors are found on the computer and or
USB hub and Type B connectors are found on the peripheral. All USB cables should only be
legally 5m (16ft) max as defined by the USB standard. When exceeding this length or
utilizing extensions in the cables data loss will occur.
The below illustration is the slots used for each of the connectors shown in the above
illustration.
USB VERSIONS
USB 1.0 - The original release of USB supports 127 devices transferring 12 Mbps.
USB 1.1 - Also known as full-speed USB, USB 1.1 is similar to the original release of USB
however minor modifications for the hardware and the specifications. This version of USB
still only supports a rate of 12 Mbps.
USB 2.0 - USB 2.0 also known as hi-speed USB was developed by Compaq, Hewlett
Packard, Intel, Lucent, Microsoft, NEC and Philips and was introduced in 2001. Hi-speed
USB is capable of supporting a transfer rate of up to 480 Mbps and is backwards compatible
meaning it is capable of supporting USB 1.0 and 1.1 devices and cables.
Exercises: