Professional Documents
Culture Documents
ComputerHW SystemSWCourse Offering
ComputerHW SystemSWCourse Offering
ComputerHW SystemSWCourse Offering
Software Concepts
Course Objective
To introduce
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
References
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Organization of a simple computer
Central Processing Unit
(CPU) Input/Output devices
KeyBoard
Function
– Examine
– Execute
– ALU
– Registers
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
CPU – Functional Units
Fetches Instructions from memory
CPU
Interprets the instructions
Performs arithmetic operations
Control Unit
Performs Logical operations
Very high speed memory units in the CPU-
for storing very small amount of data.
ALU Examples
•Program Counter (PC)
•Instruction Register (IR)
•Memory Address Register (MAR)
Registers
•Memory Buffer Register (MBR)
•Accumulator (A)
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Memory
MEMORY
Internal External
RAM ROM
Cache Cache
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Bus
Unidirectional or bi-directional
Major Categories
– Data bus
– Address bus
– Control bus
Bus width and Bus speed are the two major components for performance
measure
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Registers, CPU and the memory
Main Memory
CPU
Special Purpose
Registers
MAR
Instruction Register
General Purpose
MBR
registers
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Von Neumann architecture
Data & Program, both stored in the same place.
Central Processing
Program Unit (CPU)
Control Unit
Address Bus
d
an Arithmetic Logic
m
gr a ta y Unit (ALU)
o a r
Pr D mo
e Data/Program Bus
M
REGISTERS
Advantages
+it treats data and programs alike meaning the same mechanisms to
fetch data and the programs.
Disadvantage
− same bus used for both program as well the data leads to so
called Von Neumann bottleneck.
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Von Neumann architecture - characteristics
One processor
Use of stored programs
Sequential processing of instructions
Single Instruction, Single Data stream (SISD) mode
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Execution of the Instructions
– Decode Phase: Once the instructions are retrieved these are decoded by
the CU.
– Execute Phase: Once the instructions are decoded, they are executed by
the ALU (in case they are Arithmetic instructions).
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Summary
Execution of Instructions
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Session Plan
– Process Management
– Information Management
– Device Management
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Software Classification
Software
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
System Software
Example
– Compilers
– Assemblers
– Loaders
– Linkers
– Operating System
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Translators
The language in which the user’s program is written is called the source
language
The language to which the source language is converted is called the target
language
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Translator
Compiler Assembler
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Loaders
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Various Loading Schemes
Absolute Loader
Relocatable Loaders
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Linkers
Large Program
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Linkers
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Compiler
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Phases in a compiler
Lexical analysis
Syntactic analysis
Semantic analysis
Code optimization
Code generation
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Phases in a compiler
Lexical Analysis
(Scanner /
Tokenizer)
Front End
Syntax Analysis
(Parser)
Semantic
Analysis
Symbol
Error
Table
Intermediate Processing
Manager
Code
Generation
Code Optimization
Back End
Code generation
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Compilation for different machines
High Level
HLL1 HLL2 HLL3 Languages
Compilers
Resultant
1001010 1100111 1001010 1100111 1001010 1100111 Object Code for
111 0001 111 0001 111 0001 Machine M1
and M2
Object Object Object Object Object Object
Code for Code for Code for Code for Code for Code for
M1 M2 M1 M2 M1 M2
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Compiler (Front - End )
– Syntactic Analysis
– Semantic Analysis
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Back-End
– Code Generation
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Interpreter
Interpreter
User (line by line) Result
pgm
D
ata
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Interpreter
Whenever the programs have to be executed repeatedly, the source code has
to be interpreted every time. In contrast the compiled programs create an
object code and this object code will be executed.
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
OPERATING SYSTEMS
Operating systems
A program which acts as an interface between the user and the computer and
provides an environment in which a user can execute programs
– Processors
– Information
– Peripherals
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Memory management
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Memory management Schemes
Partitioned allocation
Demand Paging
Segmentation
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Single Contiguous Allocation
Memory Memory
OS 20K OS 20K
I am waiting
20K
User’s Job
Case:1 Case:2
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Partitioned Allocation
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Fixed Partitioned Allocation
Memory Memory Memory
OS OS OS
20K 20K 20K
(20K) (20K) (20K)
Job 4
(Only 10K used)
Job 3 20K Free 20K 20K
Not Used
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Variable Partitioned Allocation
Memory Memory
OS OS
(20K) (20K)
I am waiting for
Job 1 Free free memory
(10K) (10K)
Job 2 Job 2
(10K) (10K)
Job 3 Free
(20K) (20K) New Job
(30K)
Free Job 4
(10K) (10K)
Case:1 Case:2
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
(A) Technologies Ltd (B)
Version No: 2.0
Variable Partitioned allocation
Processes are loaded into consecutive areas until the memory is filled or
remaining space is too small to accommodate a new process.
Disadvantage
– External Fragmentation
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Relocatable Partitioned Allocation
Simple to implement
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Relocatable partitioned allocation
MEMORY MEMORY
OS OS
JOB 2 10 K
FREE 20 K
JOB 2 10 K 60 K
FREE
FREE 30 K
FREE 10 K
After Compaction
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Simple paged allocation
Divides the jobs address space into pages of the same size(4K)
Pages are units of memory that are swapped in and out of primary memory
Pages are grouped together for a given user job and are placed in page tables
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Simple paged allocation
Frame 0
Frame 1
2
A-
Page 0
Page 1 Frame 2 B-0
A-
Page 2 1
Job A Page 0
Page 1
Frame 3
Job B
A-
1
B-
0 Free Frame Frame 4
Frame 5
Frame 7
Memory Space
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Internal Fragmentation due to simple paging
allocation
Frame 0
-0
A
A-1 Frame 1
Page 0
Page 1 A-2
Job A 17K Page 2
Frame 2
Page 3
Page 4 A-3
Logical Address Pages of Job A
Frame 3
A-
Page size=4K 4
Only 1K used
3K of memory Frame 4
wasted
Memory
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Demand paging
Frame 0
-2
A
Page 0
Page 1 0 Frame 1
B -
Page 2
Job A Page 0
Page 1
Frame 2
Job B B-1
Memory Space
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Demand paging
Page Table
Page number Frame number Modify
Status
OS
JOB 1 1000
2000
2 3 1 0 3000
4000
7000
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Page replacement algorithms
Examples
– First in First out (FIFO )
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Thrashing
Most of the time is being spent in either swapping in or swapping out of the
pages from main memory to secondary memory,instead of doing useful work
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Segmentation
A process is divided into different segments each of its own length for example
one segment can correspond to a single subroutine, a group of closely related
subroutines etc.
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Process Management
Functions:
– To keep track of the status of each process
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Some concepts
Processor
– Hardware component that is capable of executing instructions
Process
– An instance of a program in execution
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Structure of a process
Program Counter (PC): The PC gives the address of the next instruction to be
executed by the process.
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
States of a process
New : Created
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Process State Diagram.
Admitted
New
Interrupt
Ready
I/O or Event
Completion Running Exit
IO or Event
Waiting wait(Blocked) Terminated
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Context switching
The task of switching the CPU to another process by saving the state of the old
process and loading the saved state of the new process is known as context
switching
Context switching
– Keeps the CPU busy all the time
• An interrupt occurs
• An I/O is completed
• A process terminates
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Some concepts
Uniprogramming
Multiprogramming
Multiprocessing
Multitasking
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Scheduling
– Throughput
– Turnaround time
– Waiting time
– Response time
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Scheduling policy
– Preemptive scheduling
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Non-preemptive scheduling
CPU is allocated to a process till the job is over or incurs an I/O wait
Example
– FCFS ( First Come First Serve )
Disadvantage
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Preemptive scheduling
If the process gets terminated before the time slice then CPU makes a context
switch
Example
– Round Robin
– Priority Scheduling
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Threads
In the case of multi threading two parts of the same program can execute
simultaneously
Threads shares the same address space, data section and resources
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
File Management
Features:
– Minimal I/O operations on files
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
File System.
File System is a method of storing and managing the files, which contain data.
Example.
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Structure of a Hard disk
SECTOR
TRACK
CYLINDER
PLATTER
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
FAT.
File Allocation Table (FAT) is a file system that was developed for MS-DOS.
The purpose of the “File Allocation Table” is to keep track of which areas of the disk are
available and which areas are in use.
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
How to access the contents of a file?
FAT
0 FFFD
1 FFFF
4 0007
7 FFFF
Cluster 8 is free
8 0000
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Volume structure in MS-DOS
Additional FAT : used for recovery during the failure of main FAT
File space : Rest of disk space which is available for files and sub-directories.
Additional
Boot Sector FAT Root Directory File Space
FATs
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
UNIX File system
A file system
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Volume structure in UNIX
Super block : Has the state of the file-its size,where to find the free space on
the file system,how many files it can store etc.
Inode list : It follows the super block-Give the internal representation of the file
Data Block : Contains data.( Size of the blocks can vary from 512 bytes to 4K)
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Volume structure of UNIX
Boot Block Super Block Inode Block Data Block File System 1
Boot Block Super Block Inode Block Data Block File System 2
Boot Block Super Block Inode Block Data Block File System 3
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Inode pointer structure Data Block
Direct 0
.
.
. Data Block
Direct 9
Data Block
Single Index Block
Indirect
Double
Indirect
Data Block
Triple Index Block Index Block
Indirect
Array of 13
pointers
Data Block
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
NTFS.
NTFS stands for New Technology File System.
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
NTFS
Copy of first 16
MFT records
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Device management
Functions
– To provide the simplest interface possible to the rest of the system
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Interrupt handling
Interrupt
– is a hardware facility that enables a device to notify the CPU.
– causes the CPU to suspend its work, saves the status and jumps to the interrupt
handler routine at a fixed address in memory.
– The interrupt handler routine determines the cause of the interrupt, does the
necessary processing and returns the CPU to the execution state prior to the
interrupt.
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Software Interrupts
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Direct Memory Access (DMA)
DMA unit (called DMA controller which is like another processor) has access to
the data bus and can transfer the data in and out of the memory.
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Device management (Structure of an I/O System)
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Device management (Allocation Policy)
– Shared
– Jobs intended to be printed are saved in the disk until the job is completed
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Device management (Allocation Policy)
Shared
Devices are used concurrently by more than one job
Example
– Disk
Issues
– Readers and writers problem
– Mutual exclusion
– Security rights
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Computer Network
Introduction to Computer Network
Connecting computers via a communication network
microprocessor COMMUNICATION
NETWORK general
purpose
Specific
Expensive
purpose (DSP)
Printer
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Complete topology Star topology
SWITCHING
ELEMENT
Ring topology
Linear bus
N nodes
Link
Terminator
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
OSI Layer model
– Helps in shielding the implementation details of the services offered by each layer
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
OSI Layer model
Application
7 APPLICATION protocol APPLICATION
Presentation
6 PRESENTATION PRESENTATION
protocol
Session SESSION
5 SESSION protocol
Transport TRANSPORT
4 TRANSPORT
protocol
Network NETWORK packet
3 NETWORK
protocol
Datalink frame
2 DATALINK DATALINK
protocol
Physical
1 PHYSICAL PHYSICAL bit
protocol
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Routing devices
Repeaters
Bridges
Routers
Gateway
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Network types
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Communication methods
Point-to-point network
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Summary
Computer Architecture
System Software
Operating System
– Memory Management
– Process Management
– File Management
– Device Management
Computer Networks
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0
Thank You!
ER/CORP/CRS/OS09/003
Copyright © 2004, Infosys
Technologies Ltd Version No: 2.0