Computer Organization &
Operating Systems
--- Mr.Harish G Reddy
UNIT – I
(Syllabus)
Basic Structure of Computers: Computer Types, Basic
Operational Concepts, Bus Structures, Software,
Performance, Multiprocessors and Multi Computers, Data
Representation, Fixed Point Representation, Floating –
Point Representation.
Register Transfer Language and Micro Operations:
Register Transfer Language, Bus and Memory Transfers,
Arithmetic and Logic Micro Operations, Role of Interrupt
Service Routines, Instruction Formats, Addressing Modes
Basic Structure of Computers
Computer Architecture in general covers 3
aspects:
Computer Hardware,
Instruction set Architecture and
Computer Organization.
Computer hardware consists of electronic circuits, displays, and
storage media and communication facilities.
Instruction set Architecture is an interface which contain
instruction set, registers and memory organization. Two main
approaches include: CISC (Complex Instruction Set Computer)
and RISC (Reduced Instruction Set Computer)
Computer Organization includes the memory system, the bus
structure and the design of the internal CPU.
Computer Types
Computer is a fastest electronic calculating machine which accepts
digital input, processes it according to the instructions (Programs)
and produces the result on the output device.
The computers can be classified into various types as given below:
Personal Computer/Desktop/Micro Computer
Laptop
Notebook
Work Stations
Servers
Main Frame
Super Computer
Gaming Computer
Personal Computer: A personal computer; designed to meet the
computer needs of an individual. Provides access to a wide variety
of computer applications, such as word processing, photo editing, e-
mail, and internet.
Laptop: A portable, compact computer that can run on power supply or a
battery unit. All components are integrated as one compact unit.
Notebook: A smaller version of Laptop is called a Notebook.
Work Station: Desktops designed for specialized tasks or an ordinary PC
attached to a LAN (local area network).
Servers: A server is a computer that provides data to other computers. It
may serve data to systems on a local area network (LAN) or a wide area
network (WAN) over the Internet. Many types of servers exist, including web
servers, mail servers, and file servers.
Main Frame: Large expensive computer capable of simultaneously
processing data for hundreds /thousands of users. Used to store, manage,
and process large amounts of data that need to be reliable, secure, and
centralized.
Super Computer: A computer that is considered to be fastest, which is used
to execute tasks that would take lot of time for other computers. For Ex:
Weather forecasting systems, genome sequence, etc
Gaming Computers: Specially designed for gaming purpose. Exclusive
gaming chips(GPU) included. Eg: Sony Play station etc.
Functional Units
A computer comprises five functional units namely:
input unit, output unit, memory unit, arithmetic & logic unit
and control unit.
Arithmetic
Input and
logic
Memory
Output Control
I/O Processor
. (Von Neumann Architecture)Basic functional units of a computer
1. Input: Input is received from an input device such as
a keyboard, mouse, camera or scanner.
2. Output: Output is sent to an output device such as a
monitor, printer, scanner or speaker.
CPU: CPU processes data & instructions and controls the
computer system. It is logically divided into i)CU ii)ALU
3. Control Unit (CU):
it fetches, decodes and executes instructions
it issues control signals that control, hardware components
within the CPU
it transfers data and instructions around the system
4. Arithmetic logic unit (ALU):
it performs arithmetic and logical operations (decisions).
it acts as a gateway between primary storage and secondary
storage - data transferred between them passes through the
ALU.
5. Memory Unit:
The function of memory unit is to store programs and data. The
memory unit is classified into: 1.Primary Memory/Main memory and
2.Secondary Memory.
Primary memory is the fast memory that operates at electronic
speeds. Programs are stored in the main memory while they are
being executed. The main memory contains a large number of
semiconductor storage cells, each capable of storing one bit of
information.
Memories in which any location can be reached in a short and fixed
amount of time after specifying its address are called Random
access memories(RAM).
The time required to accesss one word is called the Memory Access
Time. ( typically 10 to 100 ns).
Secondary Memory is used when large amount of data have to be
stored, particularly if some of the data need not to be accessed
frequently. Eg: Magnetic tapes, Hard Disk Drive(HDD), Solid State
Drive(SSD) .
Basic Operational Concepts
An Instruction consists of two parts: an Operation code and
Operand(s)
ADD LOCA, R0
This instruction adds the operand at memory location LOCA to
the operand in a register R0 in the processor and places the
sum into it.
The following are the steps to execute the instruction:
Step 1: Fetch the instruction from main memory into the
processor
Step 2: Fetch the operand at location LOCA from main memory
into the processor
Step 3: Add the memory operand to the contents of register R0
Step 4: Store the result (sum) in R0.
Registers
In addition to the ALU and CU, the CPU contains a no. of registers
used for temporary data storage.
Registers are small amounts of high-speed memory contained
within the CPU. They are used by the processor to store small
amounts of data that are needed
during processing, such as:
• the address of the next
instruction to be executed
• the current instruction being
decoded
• the results of calculations
Instruction Register(IR): Holds the instruction that is currently being
executed. Its output is available to the CU.
The Program Counter(PC) It contains the memory address of the next
instruction to be fetched and executed. It keeps track of the execution
of the program.
The CPU has n General purpose registers- R0 to RN-1. which can be
used by the programmers during writing programs.
There are two special registers used to communicate with the main
memory. (MAR and MDR)
The Memory Address Register(MAR) holds the address of the current
instruction that is to be fetched from memory, or the address in
memory to which data is to be transferred.
The Memory Data Register (MDR) holds the contents found at the
address held in the MAR, or data which is to be transferred to primary
storage.
The Accumulator (ACC) is a special purpose register and is used by
the ALU to hold the data being processed and the results of
calculations
Typical Operating Steps
Programs reside in the memory through input devices
Execution of Program starts, when PC is set to point to the first
instruction
The contents of PC are transferred to MAR
A Read signal is sent to the memory
The first instruction is read out and loaded into MDR
The contents of MDR are transferred to IR
Decode and execute the instruction
If the instruction involves an operation to be performed by ALU, get
the required operands for ALU.
If the operand is in memory, it has to be fetched by sending its
address to MAR and initiating a read Cycle.
When the operand has been read from the memory into the MDR it
transferred from MDR to ALU.
If the result need to stored in the memory ,then the result is sent to
the MDR. The address of the location where the result is to be
stored is sent to MAR and a Write cycle is initiated.
During the execution, PC is incremented to the next instruction
Interrupt
An interrupt is a request from an i/o device for
service by the processor.
In order to deal with the Interrupt, normal execution of
the current program must be interrupted. The device
raises an interrupt signal. The processor provides the
requested service by executing an Interrupt-service
routine.
The internal state of the processor must be saved
The details of the current state of the processor (PC,
general-purpose registers, control information) must be
saved in the memory before servicing the interrupt.
Bus Structures
A bus is a high-speed internal connection. Buses are used to send
control signals and data between the processor and other
components.
A System Bus is usually a combination of address bus, data bus and
control bus:
Address bus - carries memory addresses from the processor to
other components such as primary storage and input/output devices.
The address bus is unidirectional.
Data bus - carries the data between the processor and other
components. The data bus is bidirectional.
Control bus - carries control signals from the processor to other
components. The control bus also carries the clock's pulses. The
control bus is unidirectional.
Software
Software is divided into 3 types:
1) System Software
2) Application Software
3) Utilities
1) System Software is a collection of various programs, providing a
platform to the user through which, he can easily interact with the
system. System software is thus responsible for the coordination of all
activities in a computer system. Eg: Operating Systems, Compilers and
Interpreters.
i) Operating system - An operating system (OS) is system software
that manages computer hardware, software resources, and provides
common services for applications.
ii) Compilers: A compiler translates a high-level language program into
a sequence of machine instructions.
iii) Interpreters: They translate the high-level program instructions into
machine language instructions line-by-line.
2) Application programs are usually written in
High-level languages such as C, C++, Java etc.
A programmer using it need not know the
machine program instructions
Text Editor: It is used for entering and editing
application programs.
User program and OS routine sharing of the Processor
In order to understand the basics of OS, Let us consider a System with
1 processor, 1 disk and 1 printer and an application program is in
machine code on disk. The various tasks are performed in a coordinated
fashion, which is called multitasking. t0, t1 …t5 are the instances of time
and the interaction during various instances as given below:
t0: OS loads the program from the disk to memory
t1: program executes
t2: program accesses disk
t3: program executes some
more instructions.
t4: program accesses printer
and prints the result.
t5: program terminates
Performance
Performance: The most important measure of
a computer is how quickly it can execute
programs.
Performance is affected by:
Hardware design
Machine Language Instruction set
Compiler
Processor Clock
Clock: A clock is a circuit that generates signals that define
regular time intervals during which basic steps are performed.
It is a component of CPU
Clock cycle: is the amount of time between two pulses of an
oscillator.
Clock rate: Cycles per second.
The execution of each instruction is divided into several steps, each
of which completes in one clock cycle.
Hertz – cycles per second
The Basic Performance Equation, T =(NxS)/R, is the Program
execution time, where N= no. of instructions,
S= Avg. no. of steps needed to execute 1 instruction
R= Clock rate in cycles per second.
In order to make Program Execution Time (T), better:
Try ways to reduce N and S.
Try ways to increase R.
Pipeline and Superscalar
Operation
Instructions are not necessarily executed one after
another.
Performance can be improved by overlapping the
execution of successive instructions, using a
technique called “Pipelining”
Eg: Add R1,R2,R3 which adds the contents of R1 and R2 and places
the sum into R3.
A higher degree of concurrency can be achieved, if
there are multiple instruction pipelines implemented
in the processor – called “Superscalar Execution”.
RISC CISC
(Complex Instruction Set Computers)
(Reduced Instruction Set Computers)
Single cycle instructions. Instruction can take several
Few no. of instructions clock cycle to execute.
Few no. of addressing modes. Large no. of instructions(100-250)
Fixed length instruction format. Large no. of addr’ modes(5-20)
Faster, bcoz, it uses Reg-Reg Variable length instruction format
transfer Relatively slower, as it uses Reg-
No. of registers are more Memory transfers.
Memory access is limited to No. of registers are less
LOAD and STORE operations. As it has many instructions,
All operations are done within memory access is more
the registers of CPU. Direct manipulation of operands
Efficient Pipelining residing in the memory.
Software centric design- High Relatively slow Pipelining
level compilers take the burden Hard ware centric design- Does as
of coding many software steps. much as possible using hardware.
Heavy use of RAM. Most efficient use of RAM
Eg:MIPS, Alpha, SPARC, ARM. Eg: AMD, Intel X86, VAX, Motorola
Multiprocessors and Multicomputers
Multiprocessor computer
Large computer systems may contain a number of processor
units, in which case they are called multiprocessor systems.
Execute a number of different application tasks in parallel
Execute subtasks of a single large task in parallel
All processors have access to all of the memory – shared-
memory multiprocessor
The high performance of these systems comes with much
increased complexity and cost. In addition to multiple
processors and memory units, cost is increased because of
the need for more complex interconnection networks
Multi Computer
In contrast to multiprocessor systems, it is possible to
use an interconnected group of complete computers to
achieve high computational power.
The computers normally have access only to their own
memory units. When the tasks they are executing
need to communicate data, they do so by exchanging
messages over a communication network.
This property distinguishes them from shared-memory
multiprocessors, leading to the name message-
passing multi- computers.
Data Representation
Fixed point Representation and Floating point Representation
Now suppose a number is +326.5 and another number is -
123.42 , we store the digits easily.
How to store +,- and .(decimal point)?
Similarly there is a binary number +1010.11 and -
10101.1010
How to store the signbit (+,-) and the binary point .?
Binary and decimal point is generally characterised by a
position in a register.
There are 2 ways of specifying binary point in a register by
giving a fixed point position or employing a floating point
position.
First of all see the integer representation of signed number.
Let us say the number is +12, How to store this?
Remember:
When an integer binary number is +ve, its sign is represented
by 0.
When an integer binary number is –ve, its sign is represented
by 1.
It is represented in one of the three possible ways:
Signed Magnitude representation.
1's Complement Representation.
2’s Complement Representation.
The Signed Magnitude representation of a negative number consists
of a magnitude and a negative sign.
In other two representation the negative number is represented either by
1’s complement or 2’s complement of its positive value.
Signed Magnitude Representation:
+12 binary value is 1100, if we allocate 8 bits for that , then it
is 00001100, Here 0 represents the + sign.
+12 for 1's complement represenation we use the same
value.
+12 for 2's complement represenation we use the same
value.
-12, the signed magnitude representation is 10001100, Here
1 represents the -ve sign, where 0001100 reprents 12.
-12 , the 1's complement representation, we take the 1's
complement of 00001100 and that is 11110011 (-12).
-12 ,the 2's complement represenation ,we must take the 2's
complement of 00001100 and that is 11110100.
12----00001100
More examples:
So it is noted that, Binary number with the sign 2's
complement system has added and subtracted by the
same basic addition and subtraction rules as unsigned
number.
Therefore computer needs only one common hardware
circuit to handle both type arithmetic operations, Because
we are doing subtraction using addition.
The user/programmer must interpret the results of such
addition/subtraction differently depending on whether the
numbers are signed or unsigned.
Floating Point Representation:
The floating-point representation of a number has two parts. The
first part represents a signed, fixed-point number called the
mantissa. The second part designates the position of the
decimal (or binary) point and is called the exponent. The fixed-
point mantissa may be a fraction or an integer. Eg. 45.56
In system memory it is represented using IEEE format. There are
2 formats.
Single precision format (32 bits)
Double precision format(64 bits)
Example: Represent (1259.125)10 in single and
double precision format.
Step1: convert it to binary number.
(1259)10 =(10011101011)2
(0.125)10 =(001)2
so the binary equivalent of (1259.125)=10011101011.001
Step2: Normalize the number
Here N represents Mantissa and E represents Exponent.
10011101011.001
Step3:Now compare the number with the formula
and rewrite it.
1 .0011101011001 X 210 = (1 . N)2E-127
Now E-127=10, E=127+10=137.
So, N=0011101011001 and Exponent E=137.
Step4: Represent the binary bits
Now in single precision format we have to represent the
exponent in 8 bits,
So convert the exponent (E) into binary.
E=(137)10 = (10001001)2
As the number is positive so the sign bit is 0.
Now Mantissa N= 0011101011001
and Exponent E=10001001
But the exponent is of 23 bits , so add 0's for the rest
of the bits.
1. First, convert to the binary (base 2) the integer part: 1259
Divide the number repeatedly by 2. Keep track of each remainder.
We stop when we get a quotient that is equal to zero.
division = quotient + remainder;
1259 ÷ 2 = 629 + 1;
629 ÷ 2 = 314 + 1;
314 ÷ 2 = 157 + 0;
157 ÷ 2 = 78 + 1;
78 ÷ 2 = 39 + 0;
39 ÷ 2 = 19 + 1;
19 ÷ 2 = 9 + 1;
9 ÷ 2 = 4 + 1;
4 ÷ 2 = 2 + 0;
2 ÷ 2 = 1 + 0;
1 ÷ 2 = 0 + 1;
2. Construct the base 2 representation of the integer part of the number. Take
all the remainders starting from the bottom of the list constructed above.
1259(10) = 10011101011(2)
3. Convert the fractional part: 0.125 to binary (base 2). Multiply it repeatedly
by 2. Keep track of each integer part of the results. Stop when we get a
fractional part that is equal to zero. #) multiplying = integer + fractional part;
1) 0.125 × 2 = 0 + 0.25;
2) 0.25 × 2 = 0 + 0.5;
3) 0.5 × 2 = 1 + 0;
4. Construct the base 2 representation of the fractional part of the
number. Take all the integer parts of the multiplying operations,
starting from the top of the constructed list above:
0.125(10) = 0.001(2)
5. Positive number before normalization:
1259.125(10) = 100 1110 1011.001(2)
6. Normalize the binary representation of the number. Shift the decimal mark
10 positions to the left so that only one non-zero digit remains to the left of it:
1259.125(10) = 100 1110 1011.001(2) =
100 1110 1011.001(2) × 20 =
1.0011 1010 1100 1(2) × 210
7. Up to this moment, there are the following elements that would feed into the
32 bit single precision IEEE 754 binary floating point representation:
Sign: 0 (a positive number)
Exponent (unadjusted): 10
Mantissa (not normalized): 1.0011 1010 1100 1
8. Adjust the exponent. Use the 8 bit excess/bias notation:
Exponent (adjusted) = Exponent (unadjusted) + 2(8-1) - 1 = 10 + 2(8-1) - 1 =
(10 + 127)(10) = 137(10)
9. Convert the adjusted exponent from the decimal (base 10) to 8 bit
binary. Use the same technique of repeatedly dividing by 2:
division = quotient + remainder;
137 ÷ 2 = 68 + 1;
68 ÷ 2 = 34 + 0;
34 ÷ 2 = 17 + 0;
17 ÷ 2 = 8 + 1;
8 ÷ 2 = 4 + 0;
4 ÷ 2 = 2 + 0;
2 ÷ 2 = 1 + 0;
1 ÷ 2 = 0 + 1;
10. Construct the base 2 representation of the adjusted exponent.
Take all the remainders starting from the bottom of the list constructed
above: Exponent (adjusted) = 137(10) = 1000 1001(2)
11. Normalize the mantissa.
a) Remove the leading (the leftmost) bit, since it's always 1, and the
decimal point, if the case.
b) Adjust its length to 23 bits, by adding the necessary number of zeros to
the right.
Mantissa (normalized) = 001 1101 0110 0100 0000 0000
12. The three elements that make up the number's 32 bit single
precision IEEE 754 binary floating point representation:
Sign (1 bit) = 0 (a positive number)
Exponent (8 bits) = 1000 1001
Mantissa (23 bits) = 001 1101 0110 0100 0000 0000
Number 1259.125 converted from decimal system (base 10) to 32 bit
single precision IEEE 754 binary floating point:
0 - 1000 1001 - 001 1101 0110 0100 0000 0000
Double Precision Representation
Now compare the same number with the formula.
1.0011101011001 X 210 = (1 . N)E-1023
Now the Mantissa N=0011101011001
and the Exponent E= 1023+10=1033 and the binary
representation of
(1033)10 = (10000001001)2 , So E=10000001001
Now the representation is given as follows: