UNIT-1
Operating System
Dr. Akhtar Husain, Department of C
omputer Science and Information T
echnology, FET, MJP Rohilkhand Un
What is an Operating System?
• An operating system is a
collection of system
programs that manages and
coordinates the internal
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
functions performed by the
computer hardware and
provides the user interface.
• It acts as an intermediary
between a user and the 2
computer hardware.
Operating System Goal
• Execute user programs and make solving
problem easier
• Make the computer system convenient to
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
use
• Use the computer hardware in efficient
manner
3
Operating System Definition
OS is a resource allocator
• Manages all resources
• Decides between conflicting requests for efficient
and fair resource use
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
OS is a control program
• Controls execution of programs to prevent errors
and improper use of the computer
4
Operating System Definition (Cont.)
No universally accepted definition
“Everything a vendor ships when you order an operating
system” is a good approximation
• But varies wildly
“The one program running at all times on the computer” is
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
the kernel.
Everything else is either
• a system program (ships with the operating system) , or
• an application program.
5
Examples of Operating System
• Multiple User Interface
» UNIX
» LINUX
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
• Single User Interface
» MS DOS
» Windows
6
UNIX LINUX DOS MS Windows
Multi User Multi User Single Single User
Multi Multi User Multi Tasking
Tasking Tasking Single
Tasking
Command Command Command Graphic User
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
Line User Line User Line User Interface
Interface Interface, Interface (GUI)
GUI
Network Network Desktop Desktop OS
OS OS OS 7
Main Function Of Operating
System
(1).Process management:- Process management module
takes care of creation and deletion of processes, and
providing mechanisms for synchronization and
communication among processes.
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
(2). Memory management:- Memory management
module takes care of allocation and de-allocation of
memory space to programs in need.
(3). File management:- It takes care of file-related
activities such as organization storage, retrieval,
naming, sharing, and protection of files. 8
(Contd..)
Main Function Of Operating
System
(4). Device Configuration:- Controls peripheral
devices connected to the computer.
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
(4). Interface Platform:- Allows the computer to run
other applications.
9
Classification of Operating
System
• Batch Processing OS
• Multi-user OS
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
• Multi-processor OS
• Multi-programming OS
• Multi-tasking OS
• Multi-Threaded OS
• Real-time OS 10
• Time Sharing
Batch Processing OS
• This type of OS was one of the first to evolve.
• Jobs, together with input data, are fed into the
system with batch.
• The jobs are then run one after the another.
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
• No job can be started until previous job is
completed.
• It works on a series of programs that are held in
a queue.
• This OS is responsible for scheduling the jobs
11
according to priority and the resources required.
Batch-processing OS
Dr. Akhtar Husain, Department of C
12
omputer Science and Information T
echnology, FET, MJP Rohilkhand Un
Multi-user OS
• This OS allows different users to access
the same data and application programs
on the same network.
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
• It builds a user database account, which
defines the right of users.
• Examples are UNIX, LINUX, Windows,
etc.
13
Multi-user OS
Dr. Akhtar Husain, Department of C
14
omputer Science and Information T
echnology, FET, MJP Rohilkhand Un
Multi-processor OS
• This system can support more than one
processor at the same time.
• This technique is also known as parallel
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
processing.
• Its main advantage is that they increase
the system throughput by getting more
work done in less time.
15
Multi-processor OS
Dr. Akhtar Husain, Department of C
16
omputer Science and Information T
echnology, FET, MJP Rohilkhand Un
Multi-programming OS
• In this system, more than one process
(task) can be executed concurrently.
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
• A user can have more than one process
running at a time.
• It allows the users to switch between the
running applications.
17
Multi-programming OS
Dr. Akhtar Husain, Department of C
18
omputer Science and Information T
echnology, FET, MJP Rohilkhand Un
Multi-tasking OS
• Computer users like to have many application programs simultaneously
operational. This is necessary because some application programs require
long processing times before the desired results can be produced.
• It is true that by having more than one application program operational, the
time that it takes for each process to complete its task increases. However,
the overall system productivity also increases.
omputer Science and Information T
• These simultaneously executing programs are called tasks. Therefore, a
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
system with the capability of multitasking allows users to activate more than
one task, or application program, at a time. An Internet browser that
searches for some information and A word-processing software that is
activated to perform the word-processing task are applications.
• The operating system will switch between tasks based on the tasks current
states and their requirements and priorities.
• Multitasking is only possible when multiprogramming is the fundamental
capability of simultaneously executing pieces of software.
• Most modern operating systems, like UNIX, Linux, and Windows, support 19
multitasking.
Multi-tasking OS
Dr. Akhtar Husain, Department of C
20
omputer Science and Information T
echnology, FET, MJP Rohilkhand Un
Multi-threaded OS
• A multithreading operating system is one that is capable of handling
processes and threads at the same time and in which from each
process the system is able to generate more than one thread.
• In such an operating system, there must be facilities for thread
creation, deletion, switching, etc.
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
• Such an operating system allows users to generate more than one
request to a process at a time. For example, a browser can be made
to search simultaneously for more than one topic, even though there
is only one copy of the “browser program” in main memory.
• The multiprogramming methodology and technique are essential in
the implementation of multithreading. In this new environment, a
thread becomes the smallest functional object to which CPU is
assigned.
21
• The applications where this OS is used are flight and railway
reservation systems, etc.
Real-time OS (RTOS)
• This OS is designed to respond to an
event within a predetermined time.
• A real time OS responds very quickly
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
(usually less than one second)
• The applications where this OS is used
are flight and railway reservation
systems, etc.
22
Time Sharing OS
• Each user is given time slice to interact
with the CPU.
• The size of the time slice will depend on
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
the system.
• Each user is served in sequence.
23
Time Sharing OS
Dr. Akhtar Husain, Department of C
24
omputer Science and Information T
echnology, FET, MJP Rohilkhand Un
Architecture of Computer
System
Hardware
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
Operating System (OS)
Programming Language (e.g. PASCAL)
Application Programs (e.g. WORD, EXCEL)
25
Detail Layered View of Computer
Dr. Akhtar Husain, Department of C
26
omputer Science and Information T
echnology, FET, MJP Rohilkhand Un
System Software, Application
Software and Driver Programs
• System Software- Performs essential operation tasks
• Operating system
• Utility programs
• Application Software - Performs specific tasks for
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
users
• Business application
• Communications application
• Multimedia application
• Entertainment and educational software
• Driver Programs (Device Driver) 27
• small program that allows a specific input or output device
to communicate with the rest of the computer system
Operating System Structure
General-purpose OS is very large program
Various ways to structure ones
• Simple structure – MS-DOS
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
• More complex -- UNIX
• Layered – an abstrcation
• Microkernel -Mach
28
System Structure-MS-DOS
MS-DOS-written to provide the most functionality
in the least space
• Not divided into modules
• Although MS-DOS has some
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
structure, its interfaces and
level of functionality are not
well separated
29
Non Simple Structure-UNIX
UNIX-limited by hardware functionality, the original UNIX
operating system had limited structuring. The UNIX
OS consists of two separable parts.
• System Programs
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
• The Kernel
Consists of everything below the system-call interface and
above the physical hardware
Provides the file system, CPU scheduling, memory
management, and other operating-system functions; a
large number of functions for one level
30
Structure
Traditional UNIX System
Dr. Akhtar Husain, Department of C
31
omputer Science and Information T
echnology, FET, MJP Rohilkhand Un
Layered Approach
The operating system is divided into a number of
layers (levels), each built on top of lower layers. The
bottom layer (layer 0), is the hardware; the highest
(layer N) is the user interface.
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
With modularity, layers are
selected such that each uses
functions (operations) and
services of only lower-level
layers
32
Microkernel System Structure
Mach example of microkernel
Moves as much from the kernel into user space
• Mac OS X kernel (Darwin) partly based on Mach
Communication takes place between user modules using
message passing
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
Benefits:
• Easier to extend a microkernel
• Easier to port the operating system to new architectures
• More reliable (less code is running in kernel mode)
• More secure
Detriments:
• Performance overhead of user space to kernel space 33
communication
Microkernel System Structure
Dr. Akhtar Husain, Department of C
34
omputer Science and Information T
echnology, FET, MJP Rohilkhand Un
Components Of Operating System
Process Management
Memory management
I/O Device management
File system
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
Protection
Network management
Network services
User Interface
35
Operating System Services(Contd.)
User Interface
Program Execution
I/O Operations
File system management
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
Communication
Error detection and handling
Resources allocation
Accounting
Protection 36
Security
Operating System Services(Contd.)
Dr. Akhtar Husain, Department of C
37
omputer Science and Information T
echnology, FET, MJP Rohilkhand Un
Operating System Services(Contd.)
User interface
• All Operating Systems have a user interface.
Types
of user Interface are
• Command –line interface, Batch inter face,
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
GUI
Program execution
• Starting of programs, managing their execution and
communicating their results
I/O operations
38
• Mechanism for initiating and managing I/O operation
Operating System Services(Contd.)
File System Management
• Creating, maintaining and manipulating files
Communications
• Between processes of the same user and different
users
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
Error detection and handlings
• Protection related issues
• Safety in the case of power failures via backups
• Detecting and desirable states such as printer out of
39
papers
Operating System Services
Resources allocations
• Includes processor and I/O scheduling, memory
management
Accounting
• To track user usage of resources for billing and
statistical reasons
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
Protection
• One process must be protected from another
Security
• Security module protects the resources and
40
information of a computer system against destruction
Kernel
Kernel is the central component of Operating system
The sole aim of kernel is to manage the communication
between the software(user level application) and the
hardware( CPU, disk memory etc )
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
When a process makes requests of the kernel, the
request is called a system call. Various kernel designs
differ in how they manage system calls and resources
41
Kernel
Dr. Akhtar Husain, Department of C
42
omputer Science and Information T
echnology, FET, MJP Rohilkhand Un
Nano
Monolithic
KERNEL
Types Of Kernel
Hybrid
Micro
Dr. Akhtar Husain, Department of C
43
omputer Science and Information T
echnology, FET, MJP Rohilkhand Un
Monolithic Kernel
Execute all of their code in the same address space
(kernel space) microkernels try to run most of their
services in user space, aiming to improve
maintainability and modularity of the codebase.
It runs every basic system service like process and
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
memory management, interrupt handling and I/O
communication, file system etc. in kernel space.
Examples are Linux, Unix.
In a monolithic kernel, all OS services run along with
the main kernel thread, thus also residing in the
same memory area.
44
(Contd..)
Monolithic Kernel
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
Advantages: It has very good performance 45
Disadvantages: Difficult to debug and maintain
Micro Kernel
Consists of defining a simple abstraction over the
hardware, with a set of primitives or system calls to
implement minimal OS services such as memory
management, multitasking, and inter-process
communication. Other services, including those
normally provided by the kernel, such as networking,
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
are implemented in user-space programs, referred to
as servers.
Microkernels are easier to maintain than monolithic
kernels, but the large number of system calls and
context switches might slow down the system
because they typically generate more overhead than 46
plain function calls.
(Contd..)
Micro Kernel
A microkernel allows the implementation of the
remaining part of the operating system as a normal
application program written in a high-level language,
and the use of different operating systems on top of
the same unchanged kernel.
It is also possible to dynamically switch among
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
operating systems and to have more than one active
simultaneously.
Advantages:
• Easy to maintain
• Crash resistant(if one server fails still other server
work efficiently)
• Portable
• Smaller in size 47
Disadvantage: Slower processing because of additional
message passing (Contd..)
Monolithic VS Micro Kernel
Monolithic Kernel Micro Kernel
Monolithic Kernel uses Micro Kernel uses message
“signals” and “sockets” queues
Monolithic Kernel Micro Kernel implements
implements everything everything needed for
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
needed for memory memory management in
management in kernel userspace.
space.
The monolithic kernel The microkernel approach
approach handle I/O doesn't handle I/O
communication directly. communication directly.
48
Unstable Stable
Hybrid Kernel
This approach combines the speed and simpler
design of a monolithic kernel with the modularity and
execution safety of a microkernel
are a compromise between the monolithic and
microkernel designs.
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
49
Nano Kernel
Delegates virtually all services — including even the
most basic ones like interrupt controllers or the timer —
to device drivers to make the kernel memory
requirement even smaller than a traditional microkernel
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
50
Re-entrant kernel
• A re-entrant kernel enables a process (and it’s threads) to give away the CPU while in
kernel mode. They do not hinder other processes from also entering kernel mode.
This behavior allows CPU to be shared among multiple processes.
• A typical use case is IO wait. The process wants to read a file. It calls a kernel function
for this. Inside the kernel function, the disk controller is asked for the data. Getting
the data will take some time and the function is blocked during that time.
omputer Science and Information T
Dr. Akhtar Husain, Department of C
echnology, FET, MJP Rohilkhand Un
• With a re-entrant kernel, the scheduler will assign the CPU to another process
(kernel thread) until an interrupt from the disk controller indicates that the data is
available and our thread can be resumed. This process can still access IO (which
needs kernel functions), like user input. The system stays responsive and CPU time
waste due to IO wait is reduced.
• All Unix kernels are reentrant. This means that several processes may be executing in
Kernel Mode at the same time. Of course, on uniprocessor systems, only one process
can progress, but many can be blocked in Kernel Mode when waiting for the CPU or
the completion of some I/O operation.
• If a hardware interrupt occurs, a reentrant kernel is able to suspend the current
running process even if that process is in Kernel Mode. This capability is very 51
important, because it improves the throughput of the device controllers that issue
interrupts.