CS3451 – Introduction to
Operating Systems
UNIT - 1
INTRODUCTION
Introduction
• An operating system is a program that manages a computer ’s
hardware.
• In other words Operating System is a program that controls the
execution of application programs. It is an interface between
application and hardware.
• It provides a basis for application programs and acts as an
intermediary between the computer user and the computer
hardware.
• The application programs such as word processors, spread sheets,
compilers, and Web browsers define the ways in which these
resources are used to solve users’ computing problems.
• Latest Version of Android Os is 15, released in September 2024.
• As of February 2025,most recent version of windows for PCs,
tablets and embedded devices is Windows 11 version 24H2.
Open-Source Operating Systems
• Operating systems made available in source-code format rather than
just binary closed-source
• Counter to the copy protection and Digital Rights Management (DRM)
movement
• Started by Free Software Foundation (FSF), which has “copy left” GNU
Public License (GPL)
• Examples include GNU/Linux and BSD UNIX (including core of Mac OS
X), and many more
• Can use VMM like VMware Player (Free on Windows), Virtual box (open
source and free on many platforms - http://www.virtualbox.com)
– Use to run guest operating systems for exploration
Computer System Structure
• Computer system can be divided into four
components:
– Hardware provides basic computing resources
• CPU, memory, I/O devices
– Operating system
• Controls and coordinates use of hardware among various
applications and users
– Application programs define the ways in which the
system resources are used to solve the computing
problems of the users
• Word processors, compilers, web browsers, database systems, video
games
– Users
• People, machines, other computers
Four Components of a Computer System
What is an Operating System?
• OS controls the hardware and co-ordinates its use among various
application program for various user.
• It act as resource manager, controls the allocation of processor, memories
and I/O devices among the programs competing for it.
• Single User OS has its own hard disk, CPU and other resources. Ex : MS
DOS
• Multiuser OS each user has their own terminal and keyboard and the
resources will be shared among various user.
• Operating system goals:
– Execute user programs and make solving user problems easier
– Make the computer system convenient to use
– Use the computer hardware in an efficient manner
2 View Points of operating System
1) User View - Based on the interface being used. The OS is
classified as
2 View Points of Operating System…
2) System View
• Os is a program that acts as a resource allocator,allocating
computer system resources such as CPU time,memory
space,file storage space,I/O devices fairly to numerous
programs a user requesting them.
• Control programs manages the execution of user programs to
prevent errors and improper use of computer.
Tasks Performed by OS
• Maintain the list of authorized users, list of resources in
system.
• Initialize the execution of programs and process.
• Maintain resource usage list,
• Maintain resource allocation list, scheduling of resources
(CPU, Secondary storage)
• Maintain protection information.
What Operating Systems Do
• Users want convenience, ease of use and good performance
– Don’t care about resource utilization
• But shared computer such as mainframe or minicomputer
must keep all users happy.
• Users of dedicate systems such as workstations have
dedicated resources but frequently use shared resources from
servers.
• Handheld computers are resource poor, optimized for
usability and battery life.
• Some computers have little or no user interface, such as
embedded computers in devices and automobiles.
Operating System Definition
• OS is a resource allocator
– Manages all resources
– Decides between conflicting requests for efficient and fair
resource use
• OS is a control program
– Controls execution of programs to prevent errors and improper
use of the computer
• “The one program running at all times on the computer” is the
kernel.
• Everything else is either
– a system program (ships with the operating system) , or
– an application program.
Types of Software
System Software :
• Set of programs that helps the programmer in simplifying the
programming process and create a environment to run
application software.
Ex : Compiler, Linker, Loader, Assembler, Interpreter.
Application Software:
• Collection of programs written by users to solve a particular
problem.
BASIC ELEMENTS OF A COMPUTER SYSTEM
• Processor – Controls operations of computers and data
processing. Also Contains registers.
Register Types:
a) Processor Registers
Enable programmer to minimize main memory references by
optimizing register use.
b) Control and Status Registers
Controls Processor operations and execution of programs.
c)User Visibile Registers
Referenced by machine Language.
Both application and system program user this consist of
Segment pointer - Memory is referenced by segment and
offset.
Stack pointer – Points to top of stack, control register and
status register.
Program Counter(PC) – Contains address of an instruction
to be fetched.
Instruction Register(IR) – Contains the instruction most
frequently fetched.
Program Status Word – Contains status information.
Main Memory – Stores data and programs.
I/O Modules – Moves data between computer and external environment
contains internal buffer to temporarily hold data.
System Bus – Provides communication between memory, processors and
I/O modules.
Memory Address Register(MAR)
• Specifies the address from which data or instruction is to be accessed or
where to be stored.
Memory Buffer Register(MBR)
• Also known as memory data register (MDR) is the register in a CPU, that
stores the data being transferred to and from the immediate access
storage.
Computer System Organization
• Computer System is a combination of hardware and software,
which provides a tool for solving user problems.
• Contains one or more CPUs, main memory and various I/O
devices, device controllers connect through common bus
providing access to shared memory.
• Common bus is used for communication.
• CPU and Device Controllers use memory for execution.
• Memory is available for one device at a time.
• I/O devices and the CPU can execute concurrently.
• Each device controller is in charge of a particular device type.
• Each device controller has a local buffer.
• CPU moves data from / to main memory to/from local buffers.
• I/O is from the device to local buffer of controller.
• Device controller informs CPU that it has finished its operation by
causing an interrupt.
Interrupt
• Interrupt is both software and hardware, which sends signals to
CPU.
• It is an event that cause a change in the normal flow of
instruction execution.
• Software interrupt is called as system call.
• If interrupt is triggered, CPU stops execution of instruction and
control is transferred to that location.
• Interrupt transfers control to the interrupt service routine
generally, through the interrupt vector, which contains the
addresses of all the service routines
• Interrupt architecture must save the address of the interrupted
instruction
• A trap is a OS generated interrupt caused either by an error or a
user request
• An operating system is interrupt driven.
• CPU uses a table and interrupt vector to find OS the code to
execute in response to interrupts.
• When interrupt is signaled, the processor executes a routine
called an interrupt handler to deal with the interrupt.
• Interrupt service Routine(ISR) is the software code that is
executed when the hardware request interrupt.
• Interrupt handlers create local variables and global variables
to pass information between threads.
• The execution of main program is called foreground thread
and execution of various interrupt service routine are called
background threads.
• Synchronous interrupts occur when a process attempts to
perform an illegal action such as dividing by zero or referencing
a protected memory location. The following figure is instruction
cycle with interrupts.
Fetch Stage Execute Stage Interrupt Stage
Interrupt Disables
Check for
interrupt,
Fetch Next Execute
Start initiate
Instruction Instruction
interrupt
handler
Halt
Classes of interrupt
1) Program - It occurs as a result of an instruction execution like
arithmetic overflow, divide by zero, attempting illegal
instruction, refreshing outside memory.
2) Timer – Generated by timer within the processor. Allows OS
to perform certain functions on regular basis.
3) I/O – Generated by I/O controller to signal normal
completion of operation or at error conditions.
4) Hardware failure – Generated at failures (Power Failure)
Interrupt Handling
• The operating system preserves the state of the
CPU by storing registers and the program counter
• Determines which type of interrupt has occurred:
– polling
– vectored interrupt system
• Separate segments of code determine what action
should be taken for each type of interrupt
Polling :
• CPU monitors all served devices continuously, looking
for a “service request flag”.
• Whenever it sees a request, it serves the device and
then keeps polling.
• CPU is always “busy” with polling doing the “while any
request” loop.
Interrupts
• If and when a device is ready and needs attention, it
informs the CPU.
• CPU drops whatever it was doing and serves the
device and then returns back to its original task
• CPU is always “free”, when not serving any interrupt
Interrupt Timeline
Storage Structure
• Main memory – only large storage media that the CPU can access
directly
– Random access, Typically volatile
• Secondary storage – extension of main memory that provides large
nonvolatile storage capacity
• Hard disks – rigid metal or glass platters covered with magnetic recording
material
– Disk surface is logically divided into tracks, which are subdivided into
sectors
– The disk controller determines the logical interaction between the
device and the computer
• Solid-state disks – faster than hard disks, nonvolatile, replaces harddisk
by using flash based memory.
• Samsung SSD 860 EVO 4TB –Largest Solid State drive. It has a capacity of
holding 4 TB of data and uses an innovative V-Nand Technology.
Storage Structure..
• Processor access the data from main memory before
executing any instruction.
• CPU registers are used for fastest access.
• Cache memory capacity is less than 1 MB.
• User program and data are stored in main memory.
• Temporary storage are of low capacity with faster
access.
• Permanent Storage are of large capacity with slow CPU
access.
Storage Hierarchy
• Storage systems organized in hierarchy
– Speed
– Cost
– Volatility
• Caching – Copying information into faster storage
system; main memory can be viewed as a cache for
secondary storage
• Device controllers for each device driver manage I/O
– Provides uniform interface between controller and kernel
Storage-Device Hierarchy
Cache Memory
• A small, fast memory between the processor and
main memory is called as cache memory.
Word Transfer(2 bytes) Block transfer(8 bytes)
CPU Cache Main Memory
• It is made up of semiconductor memory.
• Holds data for temporary purpose to reduce time
required to service requests from the host.
• Cache in CPU unit is called as Level1 cache (L1).
• Cache in the next chip of CPU is called L2 cache (L2).
• Cache has the copy of portion of main memory.
• Cache memory performs its operation at many levels in a
computer (in hardware, operating system, software)
• Information in use is copied from slower to faster storage
temporarily
• Faster storage (cache) is checked first to determine if
information is there
– If it is, information used directly from the cache (fast)
– If not, data copied to cache and used there
• If the processor has to read a byte of memory, a check is done
to determine if it is in cache. If it is there, it is delivered to
processor.
• If not, then it is read from main memory to cache and then
delivered to processor.
• Cache address is specified by index and offset.
• Cache Hit - CPU tries to access an address and matching cache
block is available in cache. So, the cache did not need to access
RAM.
• Cache Miss – CPU tries to access address and there is no
matching cache block. So cache need to access RAM. It
increase I/O response time.
• Cache includes tags to indicate which block of main memory is
in each cache slot.
• Each cache block has modify and valid bits, tag address.
• Valid bit says if cache block is used or unused.
• Modify bit says whether the data in the cache block is different
from RAM or is same as RAM.
• Size of a page is dependent on the size of cache and how it is
organized.
• Cache page is broken into smaller pieces called cache lines.
• When processor starts a read cycle, the cache checks whether it
is cache miss or cache hit.
Example of Cache Memory
Read Operation
For read operation, if there is a cache miss, the item is
retrieved from main memory and copied into cache.
In the mean time some other item in the cache is removed to
make for new item.
Read Policies
1) Read Through – Reading a word(2 byte) from main memory
to CPU.
2) No read Through – reading a block from main memory to
cache and then from cache to CPU.
Write Operation
For write operation, write through protocol or write
back protocol.
Write through protocol – Cache and main memory
are updated simultaneously.
Write back protocol – Update is made on the cache
and it is marked with an associated dirty or
modified bit. Main memory is updated later.
I/O Structure
• Device controller is used to connect each device with
computer address and data bus.
• All I/O devices are interconnected through a bus including
CPU and main memory.
• SCSI (small computer system interface) handle upto 8
devices, each devices has separate buffer.
• Device controller handle data transfer between devices and
its controller.
• Device driver is controlled by device controller.
I/O Structure…
• After I/O starts, control returns to user program only upon I/O
completion
– Wait instruction idles the CPU until the next interrupt
– Wait loop (contention for memory access)
– At most one I/O request is outstanding at a time, no
simultaneous I/O processing
• After I/O starts, control returns to user program without waiting
for I/O completion
– System call – request to the OS to allow user to wait for I/O
completion
– Device-status table contains entry for each I/O device
indicating its type, address, and state
– OS indexes into I/O device table to determine device status
and to modify table entry to include interrupt
I/O Operation Steps
• Device driver loads registers.
• Device controller takes action according to the data
loaded into register.
• Data is transfer from device to its local buffer with the
help of device controller.
• After completion of data transfer, device controller
send an interrupt signal to device driver about
completion.
• Then control goes to operating system.
Direct Memory Access Structure
• Is one of the faster type of synchronization mechanism co-
ordinates the data transfers between input and output device
with respect to time.
• CPU is responsible for transferring the data between external
device and main memory.
• When we use this DMA controller, there is no need of CPU
intervention. The data can be directly transferred from main
memory to external device.
• DMA controller uses(HOLD) and (HOLDA) hold acknowledge
signals to tell CPU to stop driving data, address and control bus.
• The DMA controller directly carry out data transfer. This DMA
controller use the bus while CPU is not using it.
Instruction Execution
• Program to be executed by a processor consists of set of
instruction stored in memory.
• Two steps of instruction processing are,
• Fetch – Processor reads instruction from memory.
• Execute - Executes the fetched instruction.
• Processing of single instruction is known as instruction
cycle.
• Program execution halts, if the machine is turned off
and there arises error.
Fetch Stage Execute Stage
Fetch Next Execute
Start Halt
Instruction Instruction
Instruction Fetch and execute
• At the beginning of instruction cycle, processor fetches
instruction from memory.
• Program counter(PC) holds the address of next instruction to be
read.
• Processor increments PC, after an instruction is read.
• Example: If PC is at location 300. The processor will read 301,302,
…
• Fetched instruction is loaded into instruction register.
• The instruction bit has the operation to be done by processor.
• The operations are as follows.
1) Processor Memory – Data transferred from processor
to memory and vice versa.
2) Processor I/O – Data transferred to / from peripheral
device between processor and I/O.
3) Data Processing – Processor performs arithmetic and
logical operations on data.
4) Control – An instruction can alter the sequence of
execution.
Example:
• Instruction from location 149 tells that next
instruction is from 182.
• Hence PC is set to 182.
• And next instruction is read from 182.
OS Services
Program Development
• OS assists programmers to create programs using editors and
debuggers.
Program execution
• Number of steps are needed to execute a program.
1. Instructions and data are loaded into memory.
2. I/O devices and files are initialized.
3. Other resources are prepared.
4. Scheduling is performed.
Access to I/O devices
• I/O devices require instructions or control signals for
operation.
Controlled Access to files
• Unauthorized users should not be able to access files.
OS Services …
System Access
• OS provides protection to resources from
unauthorized users.
Error Detection and Response
• Internal and external hardware errors are to be
detected.
• OS provides solution through ending the program,
retrying the operation or error reporting.
Accounting
• OS collects usage statistics of all resources and
monitor performance through responsibilities
Functions of an OS
Resource Management
Time management
CPU and disk transfer scheduling
Space management
main and secondary storage allocation
Synchronization and deadlock handling
IPC, critical section, coordination
Accounting and status information
resource usage tracking
Evolution of Operating System
Serial Processing
• From late 1940’s to mid 1950’s programmers interacted
directly with the computer’s hardware.
• There is no operating system.
• Computer run as a console with display lights, toggle
switches, some form of input devices and printer.
• Programs in machine code were loaded via input devices like
card reader.
• Errors were indicated through lights.
• Output will be appeared in the printer.
Two problems in early system
1.Scheduling
• Reservation of time were done using hard copy sign up sheet
as multiples of half hour or so.
• Running process held with error in allotted time will be freed
to stop.
2.Setup Time
• Single program is a job.
• First source program is compiled. Then save the compiled
program( Object Code).
• Load common functions and link it.
• These are done through mounting and dismounting tapes.
• If error occurs go back to beginning of sequence.
Mainframe Systems
First computers are used to solve many commercial and
scientific applications
• Evolved from batch and time shared systems
Reduce setup time by batching similar jobs
• Serial card readers were initial input device then disks enabled
job scheduling by the operating system
Automatic job sequencing – automatically transfers control from
one job to another.
• CPU often idle because of great differences in speed
between mechanical I/O vs. electronic devices
Early OS called resident monitor
• Initial control in monitor
• control transfers to job
• when job completes control transfers back to monitor
• eliminates intervention by programmer
Spooling refers to putting jobs in buffer, a special area in
memory where a device can access them when it is ready.
Multiprogrammed Batch Systems
• Most important aspect of job scheduling is ability to multi program.
• Several jobs available in the pool, the only submitted jobs are kept
in main memory at a time, and the CPU is multiplexed among them.
• A single user cannot in general keep either the CPU or the I/O
Devices busy at all times.
• Multiprogramming increases CPU utilization by organizing jobs so
the CPU always has one to execute.
• OS keeps several jobs in memory simultaneously.
• In multiprogramming system, OS simply switches to and executes
another job.
• At least one job needs to execute, CPU is never idle.
• If several jobs enters into the job pool.
• The CPU executes the job based on job scheduling.
• If several jobs are ready to run at the same time, then CPU
Time Sharing Systems
• A time shared OS allows many users to share the computer
simultaneously.
• The response time should be short typically within 1 second
or so.
• Sharing of processor time among multiple processes is time
sharing system.
• Multiple users simultaneously access the system through
terminals.
Advantages
Minimized response time
Commands are entered in terminal
Minimized size of monitor.
Distributed Systems
• Distribute the computation among several physical processors.
• Loosely coupled system – each processor has its own local
memory, processors communicate with one another through
various communications .
• It is a model in which components located on networked
computers communicate and co-ordinate their actions by
passing messages.
• Distributed applications runs on multiple computers within a
network at the same time and can be stored on servers.
Goals: Transparancy - Scalability,
Openness – Easier to configure,
Reliability – Mask errors
Performance – More Performance.
Challenges:
Security, fault Tolerance, Co-ordination, resource sharing and
process knowledge.
Embedded Systems
• Control many devices in common use today.
• 98 % of all microprocessors are manufactured as components
of embedded systems.
• Modern embedded systems are based on microcontroller
systems.
• CPU with integrated memory or peripheral interfaces.
• Low power consumption, small size, low unit cost.
• They are dedicated to specific tasks.
• Ex : Digital watches,MP3 players,Traffic Lights,Factory
controllers,MRI,etc.,
Real time System
•Often used as a control device in a dedicated application such
as controlling scientific experiments, medical imaging systems,
industrial control systems, and some display systems.
•Well-defined, fixed time
constraints.
Hard real-time:
Secondary storage limited or absent, data stored in short
term memory, or read-only memory (ROM)
Not supported by general-purpose operating systems.
No time delay. Example: Medical systems.
Soft real-time
Limited utility in industrial control of robotics
Useful in applications (multimedia, virtual reality) requiring
advanced operating-system features. Ex: Minimal delay
Handheld Systems
•Personal Digital Assistants (PDAs) Cellular telephones
Issues:
Limited memory (512KB to 8MB) requires efficient management
Slow processors
Small display screens.
System call
• Programming interface to the services provided by OS ie) acts
as interface between OS and Process.
• Written in a high level language C or C++.
• Mostly accessed by programs via high level API rather than
direct system call use.
• 3 most common API are Win32 API for windows, POSIX API for
POSIX based systems and java API for Java Virtual Machine.
• System Call sequence to copy the contents of one file to
another file.
Example : System call sequence
System Call is divided into following Types
• File Management – Create file, delete, open, close,
get and set file attributes
• Process management – create process, delete
process,
• Interprocess Communication – two process
communicate each other by passing messages.
• I/O device management - request device, Release
device.
• Information processing and maintenance – Set time
and date, get time and date, get system data.
System Calls
Example of windows and Unix system calls
• The message passing model must support calls to:
– Identify a remote process and/or host with which to communicate.
– Establish a connection between the two processes.
– Open and close the connection as needed.
– Transmit messages along the connection.
– Wait for incoming messages, in either a blocking or non-blocking state.
– Delete the connection when no longer needed.
• The shared memory model must support calls to:
– Create and access memory that is shared amongst.
– Provide locking mechanisms restricting simultaneous access.
– Free up shared memory and/or dynamically allocate it as needed.
Message passing is simpler and easier and is generally appropriate for
small amounts of data.
Shared memory is faster, and is generally the better approach where large
amounts of data are to be shared.
Multiprocessor Systems
• Also called as parallel systems or tightly coupled system.
• This type of processor have more than one processor in close
communication with a common bus, clock, memory and
peripheral devices.
• If one processor fails the other processors should retrieve the
interrupted process state and the process continues.
• Two types:
1. Asymmetric Multiprocessing – each processor is
assigned a specific task.
2. Symmetric Multiprocessing – each processor performs
all tasks
Symmetric Multiprocessing
• Multiple processors run independently without affecting
other programs.
• Each processor uses different data and program but share
some common resources like memory, I/O device, etc.,
• Shares same OS.
• Example: Windows XP, and Unix,…
Asymmetric Multiprocessing
• One master processor and remaining slave processor.
• Each processor has its own memory address space.
• Master Processor controls slave processor by assigning
predefined set of tasks.
• It is difficult to implement.
Slave P1
Master P2
Slave P3
(No Shared Memory)
Advantages
• Increased Throughput - Because of more number of
processors, more processes are executed..
• Cost – Cheaper
• Reliability – Increases because if one processor fails it does
not affect others.
• Response Time – Less because of more number of processors.
Disadvantages
• CPU are separate, so one may be idle and other may be
overloaded using data structure.
Multicore Processor
• All processors are on same chip.
• It is a single computing component with two or more
independent processing units called cores which read and
execute program instructions.
• Objective is to create a system that can complete more tasks
at the same time, to provide overall system performance.
• Core refers to processor.
• Currently upto 24 core processors are available.(Intel 14th
generation core processors)
Multicore processor
System Programs
• These programs are no usually a part of OS
kernel, but are part of overall operating
system.
File management
• programs to create, delete, copy, rename, print, list,
and generally manipulate files and directories.
Status information
• Utilities to check on the date, time, number of users,
processes running, data logging, etc.
• System registries are used to store and recall
configuration information for particular applications.
File modification
• E.g. text editors and other tools which can change file
contents.
Programming-language support
• E.g. Compilers, linkers, debuggers, assemblers, library
archive management, interpreters for common
languages and support.
Program loading and execution
• Loaders as well as interactive debuggers.
Communications
• Programs for providing connectivity between
processes and users, including mail, web browsers,
remote logins, file transfers, and remote command
execution.
Background services
• System daemons(background process) are
commonly started when the system is booted,
and run for as long as the system is running,
handling necessary services.
• Examples include network daemons, print
servers, process schedulers, and system error
monitoring services.
Computer Startup
• Bootstrap program is loaded at power-up or reboot
– Typically stored in ROM or EPROM, generally known as
firmware.
– Initializes all aspects of system
– Loads operating system kernel and starts execution
– After Bootstrap, OS is loaded.
– In Unix OS, init() is first executed.
User Operating-System Interface
Command Interpreter
• In some systems the CI is incorporated directly into
the kernel.
• More commonly the CI is a separate program that
launches once the user logs in or accesses the
system.
• UNIX, for example, provides the user with a choice of
different shells, which may either be configured to
launch automatically at login,
Graphical User Interface - GUI
• Generally implemented as a desktop metaphor,
with file folders, trash cans, and resource icons.
• Icons represent some item on the system, and
respond accordingly when the icon is activated.
• First developed in the early 1970's at Xerox PARC
research facility.
• In some systems the GUI is just a front end for
activating a traditional command line interpreter
running in the background.
Choice of interface
• Most modern systems allow individual users to select their
desired interface, and to customize its operation, as well as
the ability to switch between different interfaces as needed.
• System administrators generally determine which interface a
user starts with when they first log in.
• GUI interfaces usually provide an option for a terminal
emulator window for entering command-line commands.
• Command-line commands can also be entered into shell
scripts, which can then be run like any other programs
Operating-System Structure
• For efficient performance and implementation an OS
should be partitioned into separate subsystems, each
with tasks, inputs, outputs, and performance
characteristics.
• These subsystems are arranged in various
architectural configurations.
Simple Structure
• MSDOS is example of simple structure OS.
• The original UNIX OS also used a simple
layered approach.
• Initially DOS is small and Simple in size.
• When new versions introduced size goes on
increasing.
• No CPU execution mode and so errors cause
whole system to crash.
MS - DOS Layered Architecure
• Application programs directly interact with BIOS
device driver.
• If user makes any changes in BIOS device driver, it
creates the problem and affects the whole system.
• Kernel provides system calls for CPU scheduling, I/O
management,file management and memory
management.