You are on page 1of 29

Chapter 7

Operating System
Dr. Anita Goel
University of Delhi
Contents
Objectives of OS
Types of OS
Functions of OS
Process Management: CPU scheduling, CPU scheduling
algorithms, process synchronization, deadlock
Memory Management: Multiple Partition Allocation,
Paging, Virtual Memory
File management
Device management : I/O services
Protection and Security
User Interface
Examples of OS: MS-DOS, Windows, Linux
Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 2
Objectives of OS
Software that provides interface between computer
hardware, application programs and users
Hides working of hardware from user; makes it
convenient for user to use machine
User gives commands to perform the required actions
OS handles all operational steps
Supervises and manages hardware of computer
Uses hardware efficiently, handles details of
operations
Controls and coordinates use of hardware among
different application software and users
E.g. MS-DOS, Windows 7, Linux, UNIX, Mac OS X
Snow Leopard
Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 3
Types of OS
Single user and single task
Used by single user for standalone computer, for
single task Which OS
runs in your
E.g. MS-DOS mobile
phone?
Single user and Multitasking
Allows execution of more than one task or process
concurrently. Uses time sharing
E.g. Windows 95 and later versions of Windows
Multiuser
Allows same data and applications to be accessed by
multiple users at same time
E.g. Linux, UNIX, Windows 7
Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 4
Types of OS (contd..)
Multiprocessing
Have two or more processors for single running
process. Use parallel processing
E.g. Linux, UNIX, Windows 7
Real time
respond to event within predetermined time. Used to
control processes
E.g. LynxOS
Embedded
Embedded in device in ROM. Device specific. Used in
appliances like microwaves, washing machines etc.

Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 5


Can you
recognise
these
Logos?

Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 6


Can you name
the devices
which use
Android?

Windows-7 Linux Ubuntu Android

Mac Snow Solaris Symbian


Leopard
Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 7
Functions of OS

User Interface

Process Protection
Management and Security

OS
Memory Device
Management Management

File
Management

Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 8


Functions of OS
Process Management
Control access to shared resources. E.g. file, memory,
CPU
Control execution of applications
Create, execute, delete process
Cancel or resume process, schedule process
Synchronization, communication, deadlock handling
File Management
Create and delete: both files and directories
Provide access to files, allocate space for files
Keep back-up of files, secure files

Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 9


Functions of OS (contd..)
Memory Management
Allocate memory, free memory, keep track of memory
usage, re-allocate memory
Device Management
Open, close, write device drivers
Communicate, control and monitor device driver
Protection and Security
Protect system resources
Uses user authentication, file attributes like read,
write, encryption & back-up of data
User Interface or command interpreter
Provides interface between computer user and
computer hardware
Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 10
Process Management
Process - Program in state of execution. Unit of
work for OS. Can be created, executed, stopped.
Handles resource allocation to processes efficiently
States changes during execution
New A new state when process is created

Ready When process waits for processor

Running Processor is executing the process

Waiting Process waits for some event to happen (I/O etc)

Terminated Process has finished execution

Collection of process - system process & user process


Concurrent execution of process requires process
synchronization, CPU scheduling

Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 11


CPU Scheduling
For multiprogramming and time sharing system
Multiple processes executed by switching CPU
Processor time distributed amongst processes
efficiently
Scheduler: schedules transition of processes
Running state: one process; rest: ready/waiting state
Assigns processor so that no process waits for long
Kinds of scheduling
Non pre-emptive: processor executes process till
termination without interruption
Pre-emptive: running process may be interrupted by
another process
Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 12
CPU Scheduling Algorithms
FCFS (process requesting CPU first, gets CPU first)
Non pre-emptive. Drawback: assigned process may
take long time to complete, other process wait
SJF (process requiring least CPU time gets CPU
first)
Non pre-emptive. Drawback: process requiring more
CPU time may wait for long
RR (For time-sharing systems)
Small quantum of time (10-100 ms) is defined, and
each process in queue assigned CPU for this
quantum circularly
Pre-emptive. Overcomes disadvantage of FCFS &
SJF

Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 13


Process Synchronization
Concurrent processes: Two or more process
execute at same time, independent of each other
Race condition: Multiple processes access and
manipulate same data concurrently; final result
depends on order of process execution
Synchronization & coordination of processes required

Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 14


Deadlock
Process waits endlessly for resource used by another
process, which is further waiting for some other resource
Necessary conditions for deadlock (simultaneously)
Mutual Exclusion Only one process at a time can use resource

No preemption Process releases resource by itself

Hold & Wait Process holds resource; requests another resource

Circular wait P1 waits for resource held by P2. P2 waits for P1

Deadlock prevention
At least one necessary condition does not hold true
Deadlock avoidance
requires OS be given information in advance regarding
resources process will request & use

Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 15


Memory Management
Handles allocation of memory to different processes
On completion of process execution, memory is de-
allocated and made available to another process
Processes allocated memory should not interfere
into each others memory space
Requires memory protection and sharing mechanism
Memory Allocation Schemes
Multiple Partition Allocation
Paging

Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 16


Multiple Partition Allocation
Memory allocation
Hole (single block of available memory) large enough
for process allocation
Released memory block placed in set of holes
During allocation, set of holes searched for allocation
Hole allocation strategies
First fit (allocate first hole big enough for process)
Best-fit (allocate smallest hole big enough for process)
Worst-fit (allocate largest available hole)
Results in fragmentation. Free memory broken into
small pieces. Lies unused.
Paging overcomes fragmentation

Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 17


Paging
Physical memory broken into fixed size blocks: frames
Logical memory broken into blocks of same size: pages
During process execution, pages loaded into frames
Address generated by CPU has two parts: page
number and page offset
Page table maps page number to frame number
Page offset is added to frame number to get physical
memory address
Handles problem of fragmentation
Frames need not be contiguous and can reside
anywhere in memory

Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 18


Virtual Memory
Needed because: for some applications, large
memory is required to run applications & whole
program cannot be loaded into memory
Allows execution of processes not completely in
memory
Implemented by demand paging (paging with
swapping)
Processes reside in on-line secondary memory. When
a page is required, it is swapped-in into memory
Swapping: transferring of block of data from on-line
secondary storage to memory and vice versa

Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 19


File Management
Handles file system. Two parts: files & directory structure
File: collection of related information
Smallest named unit written to secondary storage device
Attributes: name, location, size, type, time, date etc.
Access: sequential access and direct access
Directory structure
Stores file information on secondary storage
Contains name, location, size, type of all files
System calls: interface between process and OS
Operations on directory: search, create, delete and
rename file, list directory, traverse file system

Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 20


Device Management
Manages and controls devices attached to computer
Handles devices by both hardware and software
techniques
I/O hardware: Ports, buses, device controllers for
devices
Software: Device driver. OS communicates with I/O
hardware via device driver of device
Device Controller
Operates port, bus, device. Bridge between device
and OS
Complexity of handling devices is abstracted and
hidden in device drivers of device

Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 21


I/O Services
I/O Scheduling: arranges requests to improve
system performance. Queue of request is
maintained for each device
Buffering: handles speed mismatch by storing data
in buffer till complete data arrived. Writes in single
write operation
Spooling: stores jobs in spool where device
accesses it when ready. Commonly used for printers

Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 22


Protection and Security
Protection mechanism: Access of programs,
processes, users to resources defined by computer
Ensures resources used in consistent way
Security mechanism: prevents unauthorized access
to computer. Includes, security of software, security of
data and security of computers physical resources
In PC, security ensured using
User accounts, user authentication, access rights
Data encryption, data backup
Common security threats due to hacking, viruses etc.

Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 23


User Interface
Two kinds of interfaces: CLI and GUI
CLI: User interacts with OS in form of text keyed in
from keyboard
E.g. MS-DOS and Linux shell
GUI: Uses graphics to display various commands
Consists of icons, menus, windows and pointers
E.g. Windows 7 and Mac OS 10
GUI interface for Linux OS - GNU Object Model
Environment (GNOME)

Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 24


Examples of OS
MS-DOS
Windows family of operating systems
Unix OS
Linux OS
Mac OS X

Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 25


MS-DOS
First widely-installed OS for PCs
Easy to load and install
Neither requires much memory nor a very powerful
computer to run on
CLI user interface
Single-user and single-tasking OS for PC
16-bit OS - can send or receive 16 bits of data at a
time and can process 16 bits of data
User must know where programs and data are
stored and how to interact with it

Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 26


Windows Family of OS
Personal computer OS from Microsoft
Includes: Windows 9x family (Windows 95, Windows
98, Windows 2000), Windows XP, Windows Vista,
Windows 7
GUI-based OS
Support multi-tasking
Contains built-in networking; allows users to share
files and applications with each other when
connected to network
Windows 7 comes in six editions: Starter, Home
Basic, Home Premium, Professional, Enterprise,
Ultimate

Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 27


Linux OS
Unix-like OS. Developed by Linus Torvalds
User interface called shell
Kernel : interface for programs to interact with
hardware. Provides services like process management
Shell interacts with kernel through system calls
Free OS. Copyright under GNU Public License.
Constantly upgraded by programmers
CLI interface. GUI interfaces: GNOME and KDE
Multi-tasking, reliable, secure OS
Linux with add-on features and capabilities
Redhat Linux ver.9, Mandrake, Debian (Ubuntu,
Kubuntu, Edubuntu), Novell

Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 28


Thank You

Computer Fundamentals by Dr. Anita Goel Chapter-7: Operating System 29

You might also like