You are on page 1of 37

COMPUTER

ARCHITECTURE AND
OPERATING SYSTEMS

SCHOOL OF COMPUTING RIEL A. GOMEZ


COMPUTER SYSTEM OPERATION BASICS

• The four basic components of a computer system: the CPU, the


primary memory, the secondary memory and the different I/O
devices.

• These components communicate with each other through the


interconnecting bus or system bus. A bus is a set of wires used to
interconnect the different components of the system.

Main or
Secondary I/O
CPU Primary
Memory Devices
Memory

Interconnecting Bus

Computer Architecture and OS


COMPUTER SYSTEM OPERATION BASICS

Computer Architecture and OS


COMPUTER SYSTEM OPERATION BASICS

• Since there is only a single bus used, only two components


may actively communicate with each other at any one time.

• For example, if the CPU is fetching data from the main


memory, no other component may transmit data to
another component.

Main or
Secondary I/O
CPU Primary
Memory Devices
Memory

Interconnecting Bus

Computer Architecture and OS


THE CPU

• The CPU is responsible


for executing the
instructions of a program
and for coordinating the
activities of the other
system components.

• Take note that no


program or data can be
processed by the CPU
unless it is inside the
main memory.

Computer Architecture and OS


THE CPU

• Whenever a user wants to


execute a particular program,
the operating system will:

1. first locate the program


and its data in secondary CPU
Secondary
memory, Memory
(Fixed Disk)
2. copy them to main
memory,
3. and the CPU will then fetch
the instructions (and the
data) from main memory Primary or Main Memory

for execution.

Computer Architecture and OS


THE CPU

• To execute an instruction, the


CPU must do the following:

1. Fetch that instruction from


main memory.
2. Decode the instruction to
determine what must be
done and where the
operands or the data to be
processed are located.
3. Execute the instruction.

• This fetch-decode-execute
cycle is repeated for each
succeeding instruction.

Computer Architecture and OS


THE CPU

• Since main memory is


much slower as
compared to the CPU,
fetching instructions
and data from it slows
down the CPU.

• Because of this, many


refer to the memory
as the bottleneck of
most computer
systems.

Computer Architecture and OS


THE CPU

• In order to minimize the


effects of this, the CPU
places the frequently used
data in its internal
registers.

Registers are the CPU's


built-in storage.

They are typically 10 to


100 times faster than the
main memory.

Computer Architecture and OS


Operator Overloading
THE PRIMARY MEMORY

• The primary memory, or


main memory as it is also
called, is where programs
and their data are stored
during execution.

• Main memory is volatile


memory. So it loses its
contents when power is
turned off.

• Therefore, it cannot be used


to store programs and data
permanently.

Computer Architecture and OS


THE PRIMARY MEMORY

• Main memory is also called


random-access memory (RAM).

• RAM is a type of memory


wherein any memory location
can be accessed by the CPU in
the same amount of time.

• In other words, RAM is memory


whose memory access time (the
time needed to read or write
data from or to main memory) is
fixed or constant, regardless of
the memory location being
accessed.

Computer Architecture and OS


THE PRIMARY MEMORY

• It should be noted
that the
performance of a
computer system is
not only measured
in terms of the
speed of its CPU.

• Since the CPU fetches its instructions and data


from main memory, the execution speed of
programs is also dependent on the speed with
which instructions and data can be transferred
between the CPU and the main memory.
Computer Architecture and OS
THE SECONDARY MEMORY
• Secondary memory (also
called auxiliary memory)
is where all programs and
data are stored on a more
permanent basis.

• So whenever a user wants


to execute a particular
program, the operating
system will first locate the
program and its data in
secondary storage, copy
them to main memory,
and schedule the CPU to
execute it.

Computer Architecture and OS


THE SECONDARY MEMORY

• Secondary memory is where all programs and data are


permanently stored since it does not lose its contents
whenever power is cut off (non-volatile).

• The other advantage of secondary memory is that they


are less expensive than main memory which is the
reason why the capacity of secondary memory is much
larger than main memory in all computer systems.

For example, the price of an 1 TB fixed disk is almost


the same as that of a 8 GB main memory (for PCs).

Computer Architecture and OS


THE SECONDARY MEMORY
• The main disadvantage of secondary
memory is that it is much slower
than primary memory. There are
two reasons for this.

1. Most secondary memory has


mechanical or moving parts
(rotating disk platters and
moving read/write heads) while
main memory does not. In
other words, main memory
operates at electronic speed.

2. The main memory is the only


memory that can be directly
accessed by the CPU (without
passing through I/O channels).

Computer Architecture and OS


THE SECONDARY MEMORY

• These are the reasons


why programs and
data should be stored
in main memory
during execution.

All other programs and


data are stored in
secondary storage
until they are needed
by the CPU and loaded
into memory.

Computer Architecture and OS


I/O DEVICES

I/O devices comprise the


biggest part of any computer
system. They are also the
slowest components.

I/O devices are composed of


input devices (keyboard,
scanners, optical character
readers, mouse, trackballs,
joystick, game pads, etc.) and
output devices (printers,
monitors, speakers, etc.).

Some devices have both input


and output capabilities such as
touch-screen monitors.

Computer Architecture and OS


INTERRUPTS

• When the CPU communicates


with the slower I/O devices, it
becomes inefficient. Consider
the following scenario:

Assume that the computer user


wants to print a file.

– The CPU will send the first


batch of characters to be
printed to the printer (this
assumes that the printer has
a small buffer memory to
store these characters during
printing).

Computer Architecture and OS


INTERRUPTS

– While the printer is busy


printing, the CPU will have
to wait until the printer
finishes before it can send
the next batch of
characters.

If it takes 10 seconds for


the printer to print a
batch of characters, the
CPU will have to be idle
during that time.

Computer Architecture and OS


INTERRUPTS

– In a multitasking or
multiprogramming
environment, the operating
system schedules the CPU to
execute another program to
maximize its utilization.

This addresses the issue of


the CPU's inefficiency but
another problem is created.

Computer Architecture and OS


INTERRUPTS

At some point in time, the


printer finishes printing the
first batch of characters.

But since the CPU is busy


executing another program,
it will not know that the
printer is now waiting for it
to send the second batch.
So the printing job may stop
for a certain amount of
time.

Computer Architecture and OS


INTERRUPTS

• To solve this problem,


computer systems and
operating systems were
designed to be interrupt-
driven.

• Interrupts are signals sent by


devices and programs to the
CPU to tell the CPU that its
services are needed.

• They are used mainly to get


the attention of the CPU and
the operating system.

Computer Architecture and OS


INTERRUPTS

• Going back to the printer


scenario:

– When the printer finishes


printing a batch of
characters, it sends an
interrupt signal to the CPU
to inform the CPU that it is
now ready to print the
next batch.

– The CPU would then stop


executing the current
program and sends the
printer another batch to
be printed.

Computer Architecture and OS


INTERRUPTS

• In general, when there is nothing


happening in a computer system,
its operating system will simply be
idle.

• If a user wants to execute a


program or an I/O device needs a
particular service, an interrupt
signal is generated informing the
operating system that its
attention is needed.

The operating system will then


attend to this request.

Computer Architecture and OS


INTERRUPTS

• Most of the time, it will


be the I/O devices
making interrupt
requests. These are
called hardware
interrupts.

• There are also interrupt


requests made or
generated by software.

These are called traps or


exceptions

Computer Architecture and OS


INTERRUPTS

• Traps are used by programs


to inform the operating
system of the occurrence of
errors such as a divide-by-
zero error or an unauthorized
access to a certain memory
location.

• Traps are also used by


programs if they need a
service from the operating
system such as printing a
document or retrieving a file
from secondary storage.

Computer Architecture and OS


INTERRUPTS
• When an interrupt request is made, the CPU stops
whatever program it is executing and will start executing
the interrupt service routine (ISR) of the device that made
the request.

• An ISR is a program that instructs the CPU how to handle


or respond to a particular interrupt request.

• ISRs for the different I/O devices are usually part of their
respective device drivers.

• Each device has its own ISR. If the keyboard was the one
that sent the interrupt signal, then the CPU will execute
the keyboard's ISR.

Computer Architecture and OS


INTERRUPTS

Program
ISR of
• If the printer made the Printer
interrupt request, the At this point, the printer
makes an interrupt
CPU will execute the request so CPU stops
ISR of the printer. executing the program
and starts executing the
ISR of the printer

• Once the ISR has been


executed, the CPU
returns to the program
it was executing before Once execution of the ISR
the interrupt occurred. is completed, CPU returns
to the program it was
executing before the
interrupt request occurred

Computer Architecture and OS


CACHE MEMORY

• In order to understand what a cache memory is, it is better to present first the
two main technologies used in manufacturing RAM memory chips.

• There are generally two types of RAM chips available, static bipolar RAM chips
(SRAM chips) and dynamic RAM chips (DRAM chips).

SRAM DRAM
Access Time (Speed) Fast Access Times Relatively Slower
Low Packing Density. An
SRAM chip has limited High Packing Density. A
storage capability. For typical DRAM chip may
Packing Density
example, a typical SRAM have as much as 1 GB of
chip may have a maximum storage space.
of 1 MB of storage space.
Cost Very Expensive Much Cheaper

Computer Architecture and OS


CACHE MEMORY

• Since having a fast main memory is of prime


importance, SRAM chips seem to be the logical
choice as the principal building blocks of main
memory of most computer systems because of
their speed.

• However, the high cost of SRAM chips prevents it


from being used to build large memory systems.

• Even if cost is ignored, their relatively low packing


densities present a second obstacle.

Computer Architecture and OS


CACHE MEMORY

• For example:

Assume 1-MB SRAM chips will be used to construct a 4-GB (4,096


MB) main memory system.
4,096 MB
Number of Chips Required = = 4,096 chips
1 MB

So 4,096 SRAM chips are needed to build such a memory system.

This would probably make a personal computer the size of a


minicomputer. This would also increase the computer's power
consumption.

Computer Architecture and OS


CACHE MEMORY

But if 1-GB (1,024 MB) DRAM chips were used:

4,096 MB
Number of Chips Required = = 4 chips
1,024 MB

So only 4 DRAM chips will be needed.

• Therefore, using DRAM chips is the practical choice in


implementing main memory.

Computer Architecture and OS


CACHE MEMORY

• The problem now in using DRAM technology in


implementing main memory is its slow memory access
time.

• The solution to this dilemma comes in the form of a cache


memory.

• Cache memory is a smaller version of the main memory but


is constructed using SRAM chips.

• Since the size of a cache memory is small (typical cache


memory size is about 10% of main memory size), it will not
be that expensive.

Computer Architecture and OS


CACHE MEMORY

• It is placed between the


CPU and the main
memory

• The idea behind cache


memories is that the CPU
Cache
Memory
Main
Memory
most frequently and
recently used CPU fetches its
instructions and data instructions and data
from the cache
Frequently used
instructions and data
are copied from the memory instead of the
main memory
are transferred from
main memory to cache
main memory to the memory

cache memory.

• The CPU will now fetch these instructions and data from the
much faster cache memory thereby giving a remarkable
improvement in the over-all memory access speed.

Computer Architecture and OS


CACHE MEMORY

Computer Architecture and OS


CACHE MEMORY

• There are two types of cache


memories.

• The Primary Cache or L1


Cache (level 1 cache) is
found inside the CPU chip
itself while Secondary Cache
or L2 Cache (level 2 cache) is
found outside the CPU.

• L1 cache is generally smaller


but faster than L2 cache.

Computer Architecture and OS

You might also like