You are on page 1of 82

Noida Institute of Engineering and Technology,

Greater Noida

Operating System
KCS401

Unit: 1

Operating System
Dr. C S Yadav
Prof and Head,
B Tech 4th Sem CSE

Dr C S Yadav KCS401 OS Unit Number:1


1
3/4/2022
Content

• Course Objective
• Course Outcome
• CO-PO matrix
• CO-PSO matrix

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 2


Course Objective

To learn the fundamentals of Operating Systems. To


understand what a process is and how processes are
synchronized and scheduled. To understand different
approaches to memory management. Students should be
able to use system calls for managing processes, memory
and the file system. To understand the structure and
organization of the file system.

Dr C S Yadav KCS401 OS Unit Number:1


3/4/2022 3
Course Outcome

At the end of semester, students will be able to

CO1: Understand the structure and functions of OS

CO2:Learn about Processes, Threads and Scheduling


algorithms

CO3: Understand the principles of concurrency and Deadlocks

CO4: Learn various memory management scheme

CO5: Study I/O management and File systems

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 4


CO-PO and PSO Mapping
OPERATING SYSTEM(KCS-401)
CODE PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12

KCS401.1 3 3 2 2 1 2 - 2 3 2 2 3

KCS401.2 3 3 3 2 2 3 2 2 3 - 1 3

KCS401.3 3 3 2 2 2 2 2 2 2 3 1 3

KCS401.4 3 2 2 3 1 2 2 - 2 - 2 3

KCS401.5 3 1 2 2 2 2 - - 2 2 2 3

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 5


CO-PO and PSO Mapping

Program Specific Outcomes


Course
Outcomes PSO1 PSO2 PSO3 PSO4

KCS401.1 2 1 2 2
KCS401.2 2 2 1 2
KCS401.3 2 3 3 2
KCS401.4 2 2 1 2
KCS401.5 2 2 2 2

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 6


Prerequisite and Recap

• Basic knowledge of computer fundamentals.


• Basic knowledge of computer organization.

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 7


Unit-1

• Overview of operating system


• Types of Operating Systems
➢ Simple Batch Systems
➢ Multiprogramming Batched Systems
➢ Time-Sharing Systems
➢ Real -Time Systems
➢ Parallel Systems
➢ Distributed Systems

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 8


Overview of Operating System

• A program that acts as an intermediary between a user


of a computer and the computer hardware.
• 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.

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 9


Overview of Operating System

OS is primarily resource manager.


The main resource, it manages is computer hardware in
the form of processors, storage, input/output devices,
and data.
An OS is a collection of programs which realize effective
utilization of a computer system in a given computing
environment

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 10


Computer System Components

1. Hardware – provides basic computing resources (CPU,


memory, I/O devices).
2. Operating system – controls and coordinates the use of
the hardware among the various application programs
for the various users.
3. Applications programs – define the ways in which the
system resources are used to solve the computing
problems of the users (compilers, database systems,
video games, business programs).
4. Users (people, machines, other computers).

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 11


Abstract View of System Components

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 12


Operating System Definitions

• Resource allocator – manages and allocates


resources.
• Control program – controls the execution of user
programs and operations of I/O devices .
• Kernel – the one program running at all times (all else
being application programs).

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 13


Types of Operating Systems
Simple Batch Systems
• Hire an operator
• User  operator
• Add a card reader
• Reduce setup time by batching similar jobs
• Automatic job sequencing – automatically transfers control
from one job to another. First rudimentary operating system.
• Resident monitor
– initial control in monitor
– control transfers to job
– when job completes control transfers back to monitor

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 14


An Introduction to OS

OS is primarily resource manager.

The main resource, it manages is computer


hardware in the form of processors,
storage, input/output devices, and data.

An OS is a collection of programs which


realize effective utilization of a computer
system in a given computing environment
3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 15
Goals of OS

Primary Goal: Convenience


Secondary Goal: Efficiency

OS acts as an interface between user and


hardware
OS acts as resource allocator
OS acts as resource manager

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 16


Functions of OS

OS performs many functions such as


➢implementing the user interface,
➢sharing hardware among users,
➢allowing users to share data among themselves,
➢preventing users from interfering with one another,
➢scheduling resources among users,
➢facilitating input/output,
➢recovering from errors,
➢accounting for resource usage,
➢facilitating parallel operations,
➢organizing data for secure and rapid access,
➢and handling network communications.

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 17


Kernel

➢The kernel layer consists of OS programs which


reside in memory at all times.
➢Non-kernel programs normally reside on disk and
are loaded in memory when needed.
➢Non-kernel programs use facilities provided by
kernel programs.
➢Programs in the user interface layer similarly use
facilities provided by non-kernel programs.
➢Only the kernel programs interact with computer
system hardware.

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 18


Classes of Operating Systems
OS class Period Prime Concern Key concepts
Batch 60’s CPU idle time Spooling, turn- around
Processing time
Multiprogram 70’s Resource Program priorities,
ming utilization preemption
Time Sharing 70’s Good Response Time slice, round-robin
Time scheduling
Real Time 80’s Meet the Real time scheduling
deadline
Distributed 90’s Resource Transparency, distributed
sharing control
Execution of user computations in different
operating systems
OS class OS overview Key execution concept
of computations

Batch Job One job is executed at a time. Programs in a


Processing job are executed sequentially.
Multiprogram Program Interleaved execution of programs to obtain
ming balanced utilization of resources.
Time Sharing Process Interleaved execution of processes to provide
good response to all processes.
Real Time Process Interleaved execution of processes in an
application program to meet its response
requirement.
Distributed Process Execution of processes of a program in
different nodes to achieve sharing and
utilization of resources in the entire system.
Functions Performed by an OS
Function Details
User Interface Processing of user commands to create
computational structures and access resources
Program (Process Management) Initiation and termination of programs,
Scheduling and dispatching of the program
Memory Management Allocation and de-allocation of memory, Virtual
memory management
I/O Management Scheduling and initiation of I/O operations, I/O
interrupt processing
File Management Creation, storage and access of data and
programs in files
Communication Management Manage communications between programs,
Networking
Bootstrapping
The operation of an OS is initialized by the boot
procedure when a computer system is switched on. The
boot procedure is loaded using a hardware/firmware
feature in the computer system and the software
technique of bootstrapping.
The boot software now performs the following
functions:
➢ Determine the configuration of the system, viz. CPU
type, memory size, I/O devices and details of other
hardware connected to the system.
➢ Load OS programs constituting the supervisor in
memory.
➢ Initialize data structures of the supervisor.
➢ Pass control to the supervisor.
Operating System
➢OS denotes those program modules within the
computer system that governs control of
equipment resources.
➢They resolve conflict, attempt to optimize
performance and simplify effective use of
system.
➢It acts as an interface between user’s program
and physical machine hardware.
CPU utilization
It is average fraction of time during
which CPU is busy or during this time
CPU is not idle or to consider useful
work only thus excluding time spent
executing the OS
Throughput

➢It is amount of work completed


in a unit of time i.e. number of
user jobs executed in a unit of
time
Turn- around time

It is the time elapsed from the


moment a program or job is
submitted until it is completed.
Waiting time
Waiting time= Turn- around time – Actual execution time of job

➢It is time job spends waiting for


resource allocation
Response Time
Response time can be classified in
terminal response time and event
response time. It is defined in time
sharing system as the time that elapses
from the moment the last character of
the command entered and the result
obtained from the monitor
UNIX: An Introduction
➢ MULTICS(Multiplexed Information of Computer Service)
➢ Operating system was developed by Bell Lab, General Electric
Company and Massachusetts Institute of Technology (MIT) in
1965.
➢ UNIX(UnipleXed Information of computing service) was
developed by Ken Thompson, DennisRitchie
➢ Finally UNIX is written in C Language to install on any
machine.
Features of UNIX
UNIX has several features
➢Multi-user OS
➢Multitasking
➢Portability
➢Security: Password to individual user, file
accessing security, File encryption and
decryption utilities
➢Communication
Unix System Organization

Users

Commands, Utilities & Applications

Shell

Kernel

Computer Hardware
Bare Machine Approach
➢Machine with no OS
➢Computer used to be programmed directly in
machine language, without any system
software approach
➢Program could be entered into RAM through
front-panel switches
➢Results of execution could be displayed on a
set of LEDs mounted on front cover itself
Serial Processing
➢The programs were executed strictly in a serial
manner, wherein program source code written
in assembly or high level language
Batch Processing
➢With the invention of hard disk drive, the
things were much better.
➢A memory-resident portion of the Batch OS,
called batch monitor. Batch monitor used to
read, interpret and execute these commands
automatically and group the pooled jobs into
separate batches placing similar jobs having
identical needs in the same batch, based on
pre-specified criteria
Multiprogramming
It refers to the concept, wherein more than
one programs used to be activated
concurrently; one of the active programs
being in ‘run-mode’ utilizing the CPU and
others utilizing the I/O devices at the same
time or being in a ‘wait state’ waiting for
resources to be available. This improved the
utilization of system resources, thus increasing
the system throughput.
Interactive Time Sharing System
➢Such systems, in addition to
multiprogramming, support some additional
features, like permitting user interaction with
the system, through OS commands.
➢Each interactive user is assigned a time-slice in
a round-robin fashion, during which it controls
the CPU. During the time-slice, the process
gets control of CPU and tries to complete its
computation.
Interactive Time Sharing System
If the computation is not completed during
the assigned time-slice, then the running
process is preempted; then it has to wait for
time-slice in the next cycle to resume
computation from where it was preempted.
The time slice cycle is so adjusted that each
user has a feel as if the CPU is assigned to it all
time.
Real Time OS
➢It refers to the environment of embedded
systems, with a very rigid requirement to
complete the processing of input data, in a pre-
specified time. The input data in such systems,
is invariably received from real-world sensors.
The outputs may be used to control some real-
world processes.
➢For example, an Air Defense System, receiving
information about aircraft movements from
radars and control weapons for the elimination
of hostile aircraft.
Hard Real Time OS
In Hard RTS, all critical tasks have to be
completed strictly within the specified time
limits. Not meeting the deadlines can be
catastrophic; like an embedded system
controlling the operation of a refinery. In such
systems, all code and data must be in
RAM/ROM.
Soft Real Time System
➢This is less restrictive type of the real time
system. If the input data is not processed
within specified time intervals, the results may
not be catastrophic, but the output may lose
its utility. The soft real time systems are not
suitable for industrial and defense use.
Distributed OS
➢A distributed OS provides easy sharing and
good utilization of resources located in all
computers in the system. To achieve this, it
permits a process to utilize the resources
located in a remote computer using the
networking component. It may also execute
processes of a program in different
computers.
Monolithic Kernel
➢ A monolithic kernel is a large single piece of
code, composed of several logically different
program pieces. It is one single large program
where all the functional components of the
operating system have access to all the data
and routines. (All those components reside in
the kernel space.) Such a program, with the
passage of time, grows more and more
complex, and becomes difficult to maintain
Monolithic Kernel
➢To avoid these problems, modern monolithic
kernels are structured in strictly functional
units. One unit cannot directly access data and
routines belonging to other units. The units
follow strict communication protocols to avail
services from one other. This is though purely
a programming paradigm, and whatever be
the internal structure, every part of the
operating system runs in the kernel mode on
behalf of the running process.
Microkernel
➢ A microkernel system is one that provides only the
bare minimum functionalities in the kernel, and
hence, is quite small and compact. The aim is a
kernel that provides the most basic functionalities
to construct the minimal operating system
services; a few inter-process communication and
synchronization primitives, a processor scheduler,
and an interrupt dispatcher. The remaining
functionalities are implemented through
autonomous processes called operating system
service processes or Servers.
Microkernel
➢The server programs reside outside
the kernel in different address space.
Thus, servers are not truly kernel
processes. They are just like any
other utility process. They run in the
user space, and not in kernel space.
Microkernel
➢ The user-level server processes provide services
that have been traditionally parts of monolithic
kernel executed by client processes when they
operate on the kernel space. They include services
such as memory manager, device driver, system
call handler, and others. The services offered by
the servers are called from the kernel via up calls.
➢ A client does not interact directly with a server.
Clients in fact are not aware of servers, and they
interact with the operating system via regular
system calls. This approach helps in making the
kernel smaller. It is easier to develop and test new
services or to modify existing services in such
systems.
Monolithic Vs Microkernel
➢The operating system development code base is
relatively easy to maintain for microkernel-
based systems. However, it leads to slower
execution of operating system services as there
are high overheads involved in frequent
communications among application processes
and service processes via the kernel space.
➢To obtain services from the operating system,
application processes communicate with the
kernel that channels the service requests to
appropriate service processes
Monolithic Vs Microkernel
➢ The replies to the service requests follow a similar
path in the reverse direction. This extra level of
indirect inter-process communications slows down
the speed of application execution considerably
whenever they need frequent operating system
services. Each service request leads to at least two
process switches: one from the client to the server
and the other from the server back to the client.
➢ Monolithic kernel is bulky, but ensures relatively
fast responses to service requests compared to
microkernel-based operating systems.
Monolithic Architecture
Applications

Monolithic Kernel

Hardware
Microkernel Architecture
Applications Server

Microkernel

Hardware
Reentrant Kernel
➢Several processes may be in kernel mode at
the same time. A reentrant kernel is able to
suspend the current running process even if
process is in the kernel mode
➢Unix kernels are reentrant kernel. This means
that several processes may be executing in
kernel mode at the same time.
Reentrant Kernel
➢A kernel that implements “reentrant routines”
are referred to as “Reentrant kernels”. When
two tasks can execute the function at the
same time without interfering with each
other, then the function is reentrant.
➢In non reentrant kernel mode, every single
process acts on its own set of memory
locations and thus cannot interfere with the
others
Reentrant Functions
➢Reentrant functions only modify local
variables but do not alter global data
structures. To provide reentrant kernel, the
kernel is implemented as a collection of
reentrant functions.
➢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 important, because it
improves throughput of the device controllers
that issues interrupts.
Reentrant Kernel
➢Once a device has issued an
interrupt, it waits until the CPU
acknowledges it. If the kernel is able
to answer quickly, the device
controller will be able to perform
other tasks while the CPU handles
the interrupt.
System Call
➢System calls provide the interface between a
running program and the operating system.
Any single CPU computer can execute only
one instruction at a time. If process is running
a user program in user mode and needs a
system service, such as reading a data from a
file , it has to execute a trap instruction to
transfer control to the operating system.
System Call
➢Operating system provides services and system
call provides interface to these services. System
call is written in language C and C++ as
routines. System calls are performed in a series
of steps.
➢System call is a technique by which a program
executing in user mode can request the
kernel’s service.
Multiprocessor Operating Systems
➢ The Multiprocessor computer systems are
non-Von Neumann computer architectures.
They support more than one CPU, organized in
variety of configurations. The Operating
Systems designed for such systems are called
multiprocessor operating systems. Depending
upon the load, the os schedules the multiple
programs/tasks on different CPUs.
Multiprocessor Operating System
This activity of concurrent execution of
multiple programs on multiple CPUs is called
multiprocessing. Multiprocessing can be
divided into two types-
asymmetric multiprocessing and symmetric
multiprocessing
Asymmetric multiprocessing(ASMP)
➢In ASMP, the operating system sits on one CPU
or processor and other processors run user
programs/tasks.
➢Example OS/VS2 for IBM 370 was an
asymmetric multiprocessor operating system
Symmetric Multiprocessing
➢On the other hand, a symmetric
multiprocessing operating system runs on any
available processor or on all processors
simultaneously, along with user
programs/tasks

➢Example: Windows NT is a symmetric


multiprocessing operating system.
Parallel Processing
➢There are some algorithms which are
inherently parallel in nature.
➢For example, algorithms like quick sort and
merge sort divide the data into partitions
which can be processed independently of
each other, provided a sufficient number of
processors are available in the computer
system.
Parallel Processing
With the availability of multiprocessor
computer systems, it becomes possible to map
independent portions of a program on different
processors.
Example: Windows 2000 and Unix are used
for parallel processing on multiprocessor
computer systems.
Parallel Processing
The ability of an OS to execute different parallel
parts of the same program on multiprocessors is
called parallel processing.
On some environments, the various parallel tasks
of a program are called threads. A thread can
precisely defined as a separate path of execution
through the code of a program. The os that can
handle multiple threads of a program is called a
multithreading operating system
Parallel Processing
If the computer system is a uniprocessor, then
one thread executes at a time. In case of
multiple processors, the operating system maps
various threads of a program on different
processors.
Multi Threading
• A thread is a flow of execution through the
process code, with its own program counter
that keeps track of which instruction to
execute next, system registers which hold its
current working variables, and a stack which
contains the execution history.
Multi Threading
• A thread shares with its peer threads few
information like code segment, data segment and
open files. When one thread alters a code
segment memory item, all other threads see that.
• A thread is also called a lightweight process.
Threads provide a way to improve application
performance through parallelism. Threads
represent a software approach to improving
performance of operating system by reducing the
overhead thread is equivalent to a classical
process.
Multi Threading
Each thread belongs to exactly one process and
no thread can exist outside a process. Each
thread represents a separate flow of control.
Threads have been successfully used in
implementing network servers and web server.
They also provide a suitable foundation for
parallel execution of applications on shared
memory multiprocessors.
Process Vs Thread
S.No. Process Thread
1 Process is heavy weight or resource Thread is light weight, taking lesser
intensive. resources than a process.

2 Process switching needs interaction with Thread switching does not need to interact
operating system. with operating system.

3 In multiple processing environments, each All threads can share same set of open files,
process executes the same code but has child processes.
its own memory and file resources.

4 Multiple processes without using threads Multiple threaded processes use fewer
use more resources. resources.

5 In multiple processes each process One thread can read, write or change
operates independently of the others. another thread's data.
Process
A Process is an instance of a program in
execution.
While a program is just a passive entity, a
process is an active entity performing the
intended functions of its related program.
Process Control Block(PCB)
The PCB refers to a data structure, created in the
system to maintain complete information about
a process. The PCB is kept constantly updated to
reflect the current status of the related process.
The intended contents of PCB vary from one OS
to another.
PCB
• Process id (unique)
• Process name
• Executable file name
• Saved registers (PC, SP, PSW)
• Memory Management Information
• Status of open files
• Accounting Information
• Pointer to previous PCB
• Pointer to next PCB
Simple Batch Systems (continued….)

Memory Layout for a Simple Batch System

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 72


Types of Operating Systems

Multi-Programmed Batch Systems


Several jobs are kept in main memory at the same time, and the
CPU is multiplexed among them.

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 73


Features for Multiprogramming

• I/O routine supplied by the system.


• Memory management – the system must allocate the
memory to several jobs.
• CPU scheduling – the system must choose among several
jobs ready to run.
• Allocation of devices.

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 74


Types of Operating Systems

Time-Sharing Systems

• The CPU is multiplexed among several jobs that are kept


in memory and on disk (the CPU is allocated to a job only
if the job is in memory).
• A job is swapped in and out of memory to the disk.
• On-line communication between the user and the
system is provided; when the operating system finishes
the execution of one command, it seeks the next “control
statement” not from a card reader, but rather from the
user’s keyboard.
• On-line system must be available for users to access data
and code.

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 75


Types of Operating Systems
Real-Time Systems
• 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 system.
– Secondary storage limited or absent, data stored in short-
term memory, or read-only memory (ROM)
– Conflicts with time-sharing systems, not supported by
general-purpose operating systems.
• Soft real-time system
– Limited utility in industrial control or robotics
– Useful in applications (multimedia, virtual reality) requiring
advanced operating-system features.
3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 76
Types of Operating Systems
Parallel Systems
• Multiprocessor systems with more than one CPU in close
communication.
• Tightly coupled system – processors share memory and a
clock; communication usually takes place through the
shared memory.
• Advantages of parallel system:
– Increased throughput
– Economical
– Increased reliability
• graceful degradation
• fail-soft systems

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 77


Types of Operating Systems
Parallel Systems (Cont..)
• Symmetric multiprocessing (SMP)
– Each processor runs an identical copy of the operating
system.
– Many processes can run at once without performance
deterioration.
– Most modern operating systems support SMP
• Asymmetric multiprocessing
– Each processor is assigned a specific task; master
processor schedules and allocates work to slave
processors.
– More common in extremely large systems

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 78


Parallel Systems (Cont.)
Symmetric Multiprocessing Architecture

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 79


Types of Operating Systems
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 lines, such as high-speed
buses or telephone lines.
• Advantages of distributed systems.
– Resources Sharing
– Computation speed up – load sharing
– Reliability
– Communications

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 80


Types of Operating Systems
Distributed Systems (Cont..)

• Network Operating System


– provides file sharing
– provides communication scheme
– runs independently from other computers on the
network
• Distributed Operating System
– less autonomy between computers
– gives the impression there is a single operating
system controlling the network.

3/4/2022 Dr C S Yadav KCS401 OS Unit Number:1 81


SPOOLing
simultaneous peripheral operations on-line

Dr C S Yadav KCS401 OS
3/4/2022 82
Unit Number:1

You might also like