1. Introduction to OS
• What Operating Systems Do?
• Computer-System Organization
• Computer-System Architecture
• Operating-System Structure
• Operating-System Operations
• Process Management
• Memory Management
• Storage Management
• Protection and Security
• Distributed Systems
• Special-Purpose Systems
• Computing Environments
Loganathan R, CSE,HKBKCE 1
2. 1. What Operating System Do
• 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
Loganathan R, CSE,HKBKCE 2
4. OS Role from 2 Viewpoints
• 1.1 User View
• Varies according to the Inter Face Used
• Single User I/F: Ease of Use
• Terminal User I/F: Resource(shared) Utilization
• Workstation User I/F: Dedicated & Shared Resource
• Handheld System User I/F : Individual Usability
• Embedded Computers : Little/No user view
• 1.2 System View
– OS is a resource allocator
–Manages all resources (CPU time, memory space, file-storage space, I/O devices)
–Decides between conflicting requests for efficient and fair resource use
– OS is a control program
–Manages the execution of user programs to prevent errors and
improper use of the computer
–Concerned with the operation and control of I/O devices.
Loganathan R, CSE,HKBKCE 4
5. 1.3. OS Definition
No universally accepted definition
• An operating system is a program that manages the
computer hardware, provides a basis for application
programs and acts as an intermediary between the
computer user and the computer hardware
“Everything a vendor ships when you order an
operating system” is good approximation
◦ But varies wildly
“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
Loganathan R, CSE,HKBKCE 5
6. 2. Computer System Organization
• 2.1 Computer System Operation
– One or more CPUs, device controllers connect through common bus
providing access to shared memory
– Concurrent execution of CPUs and devices competing for memory
cycles
– During Power up/ Reboot, it needs to have a initial program to run
called Bootstrap Program
Loganathan R, CSE,HKBKCE 6
7. Bootstrap Program
Typically stored in ROM or EPROM, generally known as firmware
Initializes all aspects of the system from CPU registers to device controllers
to memory contents
Loads operating system kernel and starts execution and waits for an Event
• An event is usually signaled by an interrupt from either the hardware or
the software
• Hardware may trigger an interrupt at any time by sending a signal to the
CPU
• Software may trigger an interrupt by executing a special operation called a
system call (also called a monitor call)
Loganathan R, CSE,HKBKCE 7
8. Functions of Interrupts
When interrupted, CPU stops what it is doing and immediately
transfers execution to a fixed location, which contains the starting
address where the service routine for the interrupt is located
• The interrupt service routine executes, on completion, the CPU
resumes the interrupted computation.
• A time line of this operation is shown
Loganathan R, CSE,HKBKCE 8
9. Interrupt Handling
• Table of pointers is stored in low memory locations hold the addresses
of the interrupt service routines for the various devices.
• This array, or interrupt vector, of addresses is then indexed by a unique
device number, given with the interrupt request, to provide the address
of the interrupt service routine for the interrupting device
Interrupt architecture must save the address of the interrupted
instruction on the system stack.
• After the interrupt is serviced, the saved return address is loaded into
the program counter, and the interrupted computation resumes as
though the interrupt had not occurred
A trap is a software-generated interrupt caused either by an error or a
user request.
An operating system is interrupt driven.
Loganathan R, CSE,HKBKCE 9
10. 2.2 Storage Structure
• Computer programs to be executed must be in main memory RAM,
Which is the only large storage area that the CPU can access directly
• It is implemented in a semiconductor technology called dynamic
random-access memory (DRAM)
• Each word has its own address & interaction is through a load or store
instructions
• A typical instruction-execution cycle, fetches an instruction from
memory and stores in the instruction register, then decoded and may
cause operands to be fetched from memory and has been executed,
the result may be stored back in memory
• To reside the programs and data in main memory permanently is not
possible for the following two reasons:
– 1. Main memory is usually too small to store all needed programs and data
permanently.
– 2. Main memory is a volatile storage device that loses its contents when
power is turned off or otherwise lost
Secondary storage(Magnetic disks, CD-ROM, Magnetic tapes) – is
extension of main memory that provides large nonvolatile storage
capacity.
Loganathan R, CSE,HKBKCE 10
11. Storage-Device Hierarchy
Storage systems organized in hierarchy according to
speed, cost and volatility
Volatile
N
o
n
v
o
l
a
t
i
l
e Loganathan R, CSE,HKBKCE 11
12. 2.3 I/O Structure
• A general-purpose computer system consists of CPUs and
multiple device controllers that are connected through a
common bus.
• Depending on the controller, there may be more than one
attached device SCSI -8
• The device controller is responsible for moving the data
between the peripheral devices that it controls and its local
buffer storage
• device driver for each device controller presents a uniform
interface to the device to the rest of the operating system
Loganathan R, CSE,HKBKCE 12
13. I/O operation
• Interrupt-driven I/O
– For moving small amount of data
– The device controller, examines the contents of the registers to
determine what action to take.
– The controller starts the transfer of data from the device to its
local buffer
– Once the transfer of data is complete, the device controller
informs the device driver via an interrupt that it has finished its
operation
Direct memory access
– For bulk data movement such as disk I/O
– After setting up buffers, pointers, and counters for the I/O
device, the device controller transfers an entire block of data
directly to or from its own buffer storage to memory, with no
intervention by the CPU
– Only one interrupt is generated per block, rather than the one
interrupt per byte.
Loganathan R, CSE,HKBKCE 13
15. 3. Computer-System Architecture
• 3.1 Single-Processor Systems
– Most systems are single processor and range from PDAs
through mainframes
– One main CPU capable of executing a general-purpose
instruction set
– Special-purpose processors are device-specific processors,
such as disk, keyboard, and graphics controllers with
Limited Instruction Set
– Example:
• PCs contain a microprocessor in the keyboard to convert the
keystrokes into codes to be sent to the CPU
– If there is only one general-purpose CPU, then the system is
a single-processor system.
Loganathan R, CSE,HKBKCE 15
16. 3.2 Multiprocessor Systems
• Multiprocessor systems also known as parallel systems or
tightly coupled systems have two or more processors in close
communication, sharing the computer bus and sometimes the
clock, memory, and peripheral devices
• Advantages
– 1. Increased throughput: speed-up ratio with N processors is less than
N due to overhead in keeping all the parts working
– 2. Economy of scale : Multiprocessor systems can cost less than
equivalent multiple single-processor systems, because they can share
peripherals, mass storage, and power supplies
– 3. Increased reliability :The failure of one processor will not halt the
system
Loganathan R, CSE,HKBKCE 16
17. Reliability
• The ability to continue providing service
proportional to the level of surviving hardware is
called graceful degradation
• Some systems go beyond graceful degradation and
are called fault tolerant, because they can suffer a
failure of any single component and still continue
operation
• Fault tolerance requires a mechanism to allow the
failure to be detected, diagnosed, and, if possible,
corrected
Loganathan R, CSE,HKBKCE 17
18. Types of Multiprocessor Systems
• Asymmetric multiprocessing
– A master processor controls the system; the other processors
either look to the master for instruction or have predefined
tasks
– The master processor schedules and allocates work to the slave
processors
• Symmetric multiprocessing (SMP)
– Each processor performs all tasks within the operating system,
all processors are peers
– SMP architecture:
Loganathan R, CSE,HKBKCE 18
19. Types of Multiprocessor Systems
• Multiple cores
– Multiple compute cores on a single chip
– Multi-core CPUs look to the OS just as N standard processors
• Blade servers
– Multiple processor boards, I/O boards, and networking boards are
placed in the same chassis
– Each blade-processor board boots independently and runs its own OS
• Difference between SMP and asymmetric
multiprocessing
– Special hardware can differentiate the multiple processors,
or the software can be written to allow only one master
and multiple slaves
Loganathan R, CSE,HKBKCE 19
20. 3.3 Clustered Systems
• Gather together multiple CPUs to accomplish computational work
• Composed of two or more individual systems coupled together
• Accepted definition
– Clustered computers share storage and are closely linked via a local-area
network (LAN) or a faster interconnect such as InfiniBand
• provides high-availability service through a level of redundancy
• Asymmetric clustering, one machine is in hot-standby mode while the
other is running the applications
• Symmetric mode, two or more hosts are running applications, and are
monitoring each other
• Parallel clusters and clustering over a wide-area network (WAN) allow
multiple hosts to access the same data on the shared storage, to provide
this, the system needs an access control and locking to ensure that no
conflicting operations occur and this function is known as distributed lock
manager (DLM)
• Storage-area networks (SANs), which allow many systems to attach to a
pool of storage
Loganathan R, CSE,HKBKCE 20
21. 4. Operating System Structure
Single user cannot keep CPU and I/O
devices busy at all times
• Multiprogramming needed for
efficiency
– Multiprogramming organizes jobs
(code and data) so CPU always has
one to execute
– A subset of total jobs in system is
kept in memory
– One job selected and run via job
scheduling
– When it has to wait (for I/O for
example), OS switches to another job
Loganathan R, CSE,HKBKCE 21
22. Operating System Structure contd..
• Timesharing / Multitasking in which CPU switches jobs so
frequently that users can interact with each job while it is
running, creating interactive computing
– Response time should be < 1 second
– Each user has at least one program executing in memory process
– If several jobs ready to run at the same time CPU scheduling
– If several jobs are ready to be brought into memory, and if there is
not enough room for all of them Job scheduling
– If processes don’t fit in memory, swapping moves them in and out
to run
– Virtual memory allows execution of processes not completely in
memory
– advantage of the virtual-memory scheme is it enables to run
programs that are larger than actual physical memory
Loganathan R, CSE,HKBKCE 22
23. 5. Operating-System Operations
OS are Interrupt driven and Events are signaled by Interrupt or trap (or exception)
◦ Division by zero, request for operating system service
Other process problems include infinite loop, processes modifying each other or the
operating system
5.1 Dual-mode operation allows OS to protect itself and other system components
◦ User mode - Executing user application
◦ kernel mode ( Supervisor / System / Privileged) – Boot time / System call
◦ Mode bit indicates current mode (0-Kernal, 1-User) provided by hardware
Loganathan R, CSE,HKBKCE 23
24. 5.2 Timer
• Timer to prevent infinite loop / process hogging resources
– Set interrupt after specific period
– A variable timer is generally implemented by a fixed-rate
clock and a counter
– Operating system decrements counter
– When counter reach zero an interrupt generated
– Set up before scheduling process to regain control or
terminate program that exceeds allotted time
Loganathan R, CSE,HKBKCE 24
25. 6. Process Management
• A process is a program in execution. It is a unit of work within the
system i.e. a job or a time-shared program
• Program is a passive entity, process is an active entity.
• Process needs resources to accomplish its task
– CPU, memory, I/O, files, Initialization data
• Process termination requires reclaim of any reusable resources
• Single-threaded process has one program counter specifying location of
next instruction to execute
– Process executes instructions sequentially, one at a time, until
completion
• Multi-threaded process has one program counter per thread
• Typically system has many processes, some user process, some are OS
process running concurrently on one or more CPUs
– Concurrency by multiplexing the CPUs among the processes /
threads
Loganathan R, CSE,HKBKCE 25
26. Process Management Activities
The operating system activities in
connection with process management:
Creating and deleting both user and system processes
Suspending and resuming processes
Providing mechanisms for process synchronization
Providing mechanisms for process communication
Providing mechanisms for deadlock handling
Loganathan R, CSE,HKBKCE 26
27. 7. Memory Management
• All data in memory before and after processing
• All instructions in memory in order to execute
• Memory management determines what is in memory when
Optimizing CPU utilization and computer response to users
• Memory management activities
– Keeping track of which parts of memory are currently
being used and by whom
– Deciding which processes (or parts thereof) and data to
move into and out of memory
– Allocating and deallocating memory space as needed
Loganathan R, CSE,HKBKCE 27
28. 8.Storage Management
• OS provides uniform, logical view of information storage
– Abstracts physical properties to logical storage unit - file
– Each medium is controlled by device (i.e., disk drive, tape drive)
• Varying properties include access speed, capacity, data-transfer
rate, access method (sequential or random)
8.1 File-System management
• A File is a collection of information defined by its creator usually
organized into directories
• The OS implements the abstract concept of a file by managing mass
storage media and the devices that control them
• OS activities in connection with file management
• Creating and deleting files
• Creating and deleting directories to organize files
• Primitives to manipulate files and directories
• Mapping files onto secondary storage
• Backup files onto stable (non-volatile) storage media
Loganathan R, CSE,HKBKCE 28
29. 8.2 Mass-Storage Management
• Usually disks used to store data that does not fit in main memory or data
that must be kept for a “long” period of time.
• Proper management is of central importance
• Entire speed of computer operation hinges on disk subsystem and its
algorithms
• OS activities in connection with disk management
– Free-space management
– Storage allocation
– Disk scheduling
• Some storage need not be fast for backup of disk data
– Tertiary storage includes optical storage, magnetic tape, platters
– Varies between WORM (write-once, read-many-times) and RW (read-
write)
– It is not crucial to system performance, but it still must be managed
Loganathan R, CSE,HKBKCE 29
30. 8.3 Caching
• Important principle, performed at many levels in a computer
(in hardware, operating system, software)
• Information in use copied from slower to faster storage
temporarily
• Faster storage (cache) checked first to determine if
information is there
– If it is, information used directly from the cache (fast)
– else, data copied to cache and used there
• Cache smaller than storage being cached
– Cache management important design problem
– Cache size and replacement policy
Loganathan R, CSE,HKBKCE 30
31. Performance of Various Levels of Storage
• Movement between levels of storage hierarchy can
be explicit or implicit
Loganathan R, CSE,HKBKCE 31
32. Migration of A from Disk to Register
• Multitasking environments must be careful to use most
recent value, no matter where it is stored in the storage
hierarchy
• Multiprocessor environment must provide cache
coherency in hardware such that all CPUs have the most
recent value in their cache
• Distributed environment situation even more complex
– Several copies of a datum can exist
Loganathan R, CSE,HKBKCE 32
33. 8.4 I/O Subsystem
One purpose of OS is to hide peculiarities of
hardware devices from the user
• Peculiarities of I/O devices are hidden from the
operating system itself by the I/O subsystem
I/O subsystem components
◦ A Memory management component that includes
buffering, caching and spooling
◦ A General device-driver interface
◦ Drivers for specific hardware devices
Only the device driver knows the peculiarities of
the specific device
Loganathan R, CSE,HKBKCE 33
34. 9. Protection and Security
• Protection – any mechanism for controlling access of
processes or users to resources defined by the OS
• Security – defense of the system against internal and external
attacks
– Huge range, including denial-of-service, worms, viruses, identity
theft, theft of service
• Systems generally first distinguish among users, to determine
who can do what
– User identities (user IDs, security IDs) include name and associated
number, one per user
– User ID then associated with all files, processes of that user to
determine access control
– Group identifier (group ID) allows set of users to be defined and
controls managed, then also associated with each process, file
– Privilege escalation allows user to change to effective ID with more
rights
Loganathan R, CSE,HKBKCE 34
35. 10 Distributed Systems
• A distributed system is a collection of physically separate, possibly
heterogeneous computer systems that are networked to provide the users with
access to the various resources
• Access to a shared resource increases computation speed, functionality, data
availability, and reliability
• Distributed systems functionality depend on networking
• Networks vary by the protocols used, the distances between nodes and the
transport media
• TCP/IP is the most common network protocol, although ATM and other
protocols (UDP) are in widespread use
• Networks are characterized based on the distances between their nodes such
as LAN,WAN, MAN and Small-Area Network(home)
• The media to carry networks are equally varied that include copper wires, fiber
strands, and wireless transmissions between satellites, microwave dishes, and
radios
• A network OS provides features such as file sharing across the network and
that includes a communication scheme that allows different processes on
different computers to exchange messages
Loganathan R, CSE,HKBKCE 35
36. 11 Special-Purpose Systems
• 11.1 Real-Time Embedded Systems
– Embedded computers found everywhere, from car engines and manufacturing robots to
VCRs and microwave ovens and expanding
– Embedded systems almost always run real-time OS, which is used when there is a rigid
time requirements, i.e. processing must be done within the defined constraints
– used as a control device in sensors, scientific experiment, medical imaging, industrial
control, display, automobile-engine fuel-injection, home-appliance, weapon systems
• 11.2 Multimedia Systems
– Multimedia data consist of audio and video files as well as conventional files
– Multimedia data, live webcasts, must be streamed according to certain time restrictions
eg. 30 frames per second
– A stock trader may have stock quotes delivered wirelessly and in real time to his PDA.
• 11.3 Handheld Systems
– personal digital assistants (PDAs), such as Palm and Pocket-PCs, and cellular phones,
– Limitation
• Physical memory in a handheld is typically 512 KB to 128 MB
• Speed of the processor , Faster processors require more power
• I/O lack of physical space limits I/O methods to small keyboards, handwriting recognition, or
small screen-based keyboards and small screens (web clipping is used)
Loganathan R, CSE,HKBKCE 36
37. 12. Computing Environments
• 12.1Traditional computing
– Office environment
• PCs connected to a network, terminals attached to mainframe or minicomputers
providing batch and timesharing, awkward Remote access and portability
• Now portals allowing networked and remote systems access to same resources
– Home networks
• Used to be single system, then modems and now firewalled, networked
– Traditional time-sharing systems are uncommon
• 12.2 Client-Server Computing
– Dump Terminals are supplemented for PCs
– Server systems to satisfy requests generated by client systems
• Compute-server provides an interface to client to request services (i.e. database)
• File-server provides interface for clients to store and retrieve files
Loganathan R, CSE,HKBKCE 37
38. 12. Computing Environments contd..
• 12.3 Peer-to-Peer Computing
– Another model of distributed system
– P2P does not distinguish clients and servers
• Instead all nodes are considered peers
◦ May each act as client, server or both
◦ Node must join P2P network and
– Registers its service with central lookup service on network, or
– Broadcast request for service and respond to requests for service via
discovery protocol
◦ Examples include Napster and Gnutella
• 1.12.4 Web-Based Computing
– Web has become everywhere and PCs most common devices
– More devices becoming networked to allow web access
– New category of devices to manage web traffic among similar servers:
load balancers
– Use of operating systems like Windows 95, client-side, have evolved into
Linux and Windows XP, which can be clients and servers
Loganathan R, CSE,HKBKCE 38