Government College of Engineering, Nagpur: Operating System III Semester/ CSE (2021-2022)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 60

Government College Of

Engineering, Nagpur

Operating System
IIIrd Semester/ CSE (2021-2022)

By Prof. Ashwini Kukade


M.Tech (CSE)
What is Operating System
• An Operating System (OS) is a program that acts as an
intermediary between the computer hardware and the
users of a computer.

• The OS provides certain services to programs and the


users of those programs in order to make their tasks easier.

• OS is a software, that communicates with hardware and


allow other programs to run.
Block Diagram for OS Mechanism

Figure : The Components of a Computer System


1.1 Evolution of OS

• History of an OS is of a great interest & it is


strongly linked with the development and history
of different generations of computer system.

• It had changed drastically in size, capacity, type


and speed.
Evolution of OS is divided
in mainly FIVE stages
Stage 0: No Operating System (1940-55)

• Computers are exotic experimental equipment


only
• Programs in machine language
• Programs manually loaded via card disks
• There was no OS used with this hardware
Stage 1: Batch System (1955-70)
• Make a more efficient use of a computer
• One user at a time
• Batch Monitor to load a program
• OS becomes a batch monitor that loads user’s
Program
• Run, print
Stage 2: Time Sharing (1970-80)
• Interactive time sharing
• One of the first time sharing system which lets
multiple users to interact with the system at same
time
• Users do debugging, editing, email online
Stage 3: Multiprogramming System
(1980-90)
• OS becomes a subroutine library and command
executive
• Finish quickly and run existing program
• One application at a time
• GUI OS was developed
Stage 4 : Networked System (1990-2000)

• Local area networking


• Internet service providers
• Different machines shares resources, file servers,
web servers
• Client- server model
• Services: computing, file storage
1.2 Types of OS
• There are various kinds of OS which are widely
used as per requirements, are as follows:
1. Batch OS
2. Multiprogrammed OS
3. Time Sharing OS
4. Multiprocessor OS
5. Real Time OS
6. Distributed OS
7. Desktop OS
1.2.1 Batch System

Batch
Job 1

OS
Job 2 Batch CPU

Job N Batch

Figure : Block Diagram for Batch OS


• The user did not interact directly with computer
system
• A JOB is prepared by user instead, consist of
program, data, some control information
• There is an Operator- takes jobs having similar
requirements and grouped into Batches & as the
computer become available, would run each batch
• The output from each job would be sent back to
the appropriate programmer
1.2.2 Multiprogrammed OS
• OS keeps several jobs in memory simultaneously
• OS picks & begins to execute one of the jobs in the
memory
• These types are fairly sophisticated as it is the first
instance where the OS must make decisions for the
users
• The most important aspect of Job scheduling is the
ability to multiprogram
• Multiprogramming increases CPU utilization by
organizing jobs so that the CPU always has one to
execute
Figure : Block diagram of Multiprogrammed OS
1.2.3 Time Sharing OS
• Also known as Multitasking OS
• Each task has been given some time to execute
• The time here given is called as Quantum
• Each task has equal opportunity
• Extension of Multiprogrammed OS
• Allows many users to share the computer
simultaneously
• More complex than Multiprogrammed OS
Word

EXcel OS
CPU

Web

Figure : Block Diagram For Time Sharing OS


1.2.4. Multiprocessor System
• Also known as Parallel system or Tightly Coupled
System
• Collection of number of standard processors
together
• Main purpose is to provide high performance with
high speed
• Generally characterized by- increased system
throughput, application speed, economy of scale
Figure : Block diagram of Multiprocessor System

CPU1 CPU 2 --------------------------- CPU N

Memory
1.2.5 Real Time OS

Figure : Block Diagram for RTOS


• RTOS has ability to provide a required service in a
bounded Response time
• responds immediately to the inputs
• This OS has to responds Quickly
• Ex : controlling Traffic signals, Nuclear Reactor,
Aircrafts
• Real time computing is equivalent to fast
computing
• Types of RTOS – Hard RTOS & Soft RTOS
• HRTOS – guarantees that critical tasks to be
completed on time
• Ex for HRTOS- Traffic Signal system, air traffic
system
• SRTOS – critical real time task gets priority over
other tasks, deadlines are occasionally missed.
• Ex for SRTOS – Multimedia transmission, web
sites services, computer games
1.3 Basic H/W Support
• The operating system lies between user programs
and the bare machine. It's roles are varied
depending on the particular hardware and user
programs it is designed to work with
• Hardware must provide appropriate mechanisms
to ensure correct behaviour
• Some categories are necessary to look after for
better and accurate performances, such as follows
• I/O Structure- I/O Interrupts
• Storage Structure- Main Memory, Magnetic disks,
tapes
• Storage Hierarchy- caching, Coherency &
Consistency
• Hardware Protection – Dual Mode operation, I/O
Protection, Memory Protection, CPU Protection
• Network Structure – LAN, WAN
Speed

Secondary
Memory

Space
1.4 Operating System Services
• OS provides certain services to program & to users as well
• These services are provided for the convenience of the
programmer to make programming easier
• Such services are as follows :
• Program Execution
• I/O Operations
• File- system Manipulation
• Communications
• Error Detection
• Resource Allocation
• Accounting
• Protection
1.5 System Programs & System Calls

• System Programs (SP) provides a convenient environment


for program development and execution
• Some are simply user interfaces & others are complex
Categories of SP:
• File Management
• Status Information
• File Modification
• Programming Lang. support
• Program loading & execution
• communication
• Most important system program for an OS is the
command interpreter, the main function is to get
& execute the next user-specified command

Figure : System Program Overview


• System Call (SC), provides the interface between a
process and the OS.
• Generally available in assembly language
instructions
• Several level languages like C, C++ etc have been
replace assembly language for system
programming
• These languages allow system calls to be made
directly
• Ex, UNIX system calls may be invoked directly
from C or C++ program
Figure : Overview of System Call

• System calls are usually made when a process in user mode


requires access to a resource. Then it requests the kernel to
provide the resource via a system call.
• System calls occur in different ways, depending on the
computer system in use
• Generally more information is required than just
identity of the desired system call
• May need to specify the file or device to use as the
source if to get input with address and the length of
the memory buffer into which the input should be
read
• System Calls has Five main categories/ types made by
an OS as-
1. Process Control
2. File Management
3. Device Management
4. Information Maintenance
5. Communications
register
System call copy
() Use
Parameters parameters
Load address X
System call 10

User os
program

Figure : Overview of System Calls parameters


passing
1. Process Control (mainly used for processes)
- end, abort
- load, execute
- create process, terminate process
- get process attributes, set process attributes
- wait for time
- wait event, signal event
- allocate and free memory

2. File Management (used for manipulation of file)


- create file, delete file
- open, close
- read, write, reposition
- Get file attributes, set file attributes
3. Device Management (used for managing devices)
- request device, release device
- read, write, reposition
- get device attributes, set device attributes
- Logically attach or detach devices

4. Information Maintenance (to do info.


Maintenance)
- Get time or date, set time or date
- Get system date, set system date
- Get process file, or device attributes
- Set process file, or device attributes
5. Communications (for communicating among calls)
- create, delete communication connection
- send, receive messages
- transfer status information
- attach or detach remote devices
1.6 OS Structure
• For efficient performance and implementation an
OS should be partitioned into separate
subsystems, each with carefully defined tasks,
inputs, outputs, and performance characteristics
• These subsystems can then be arranged in various
architectural configurations
• Types of operating System Structure
1. Layered Structure
2. Monolithic Structure
3. Microkernel Structure
1.6.1 Layered Structure
• The modularization of an OS can be done by
layered approach
• The OS is broken up into a number of layers or
levels, whereas each level bulit on top of lower
layers
• The bottom layer i.e. layer 0 is hardware
• The highest layer i.e. layer N is the user interface
• The main advantage of this approach is
Modularity
• The each layer is selected such that each uses
functions and services of only lower-level layers
Figure : A Layered OS

• This approach allows each layer to be developed and debugged


independently, with the assumption that all lower layers have already been
debugged and are trusted to deliver proper services.
• Once the first layer is debugged, its correct
functioning can be assumed while the second layer
is debugged and so on
• If an error is found during the debugging of a
particular layer, the error must be on that layer, as
the layer below it are already debugged
• Each layer is implemented with only those
operations provided by lower level layers
• A layer does not need to know how these
operations are implemented, it needs to know only
what these operations do
1.6.2 Monolithic structure

procedure

Service procedures ( for system


calls)

Utility routines (for


common tasks)

Figure : Monolilthic structure of OS


• This is a common approach
• Can be referred as big mess
• Can be described as there is no structure
• The OS is collection of procedures where each can
call any of the other ones whenever needs to
• Each procedure is free to call any other one
• This propose a basic structure for the OS
• There are service procedures
• The set of service procedures which carry out the
system calls
• A set of utility procedures that help the service
procedures
1.6.3 Microkernel Structure
• The kernel is a computer program at the core of a
computer's operating system and has complete control
over everything in the system. It is the "portion of the
operating system code that is always resident in
memory", and facilitates interactions between
hardware and software components
• As an OS is expanded mainly UNIX, then the kernel
became large & difficult to manage
• On this situation, in mid-1980s researchers at
Carnegie Mellon University developed an OS called
Mach which modularize the kernel
• This approach is Microkernel approach
Figure : Microkernel Structure OS
Figure : Difference between Monolithic & Microkernel OS Structure
• In this structure, all the nonessential components
removed from the kernel and implemented them
as system-and- user-level program
• As a result, the smaller Kernel
• The main function of the microkernel is to provide
a communication facility between the client
program and the various services that are also
running in user space
• Communication is provided by message passing
• If the client program wants to access a file, it must
interact with file server
• But the client program and service never interact
directly, rather they communicate indirectly by
exchanging messages with the microkernel
• In this, all new services are added to User space
which does not need modification of the kernel
• Benefits of Microkernel OS structure:
1. Easier to extend a microkernel
2. Easier to port the OS to new architecture
3. More reliable
4. More secured
5. Very less detriments
1.7 Disk Space Management & Disk Space
Allocation Strategies
• Computer system must provide secondary storage
to back up main memory
• Most modern systems uses Disks as the principal
storage medium for both program & data
• Most programs including compilers, assemblers,
sort routines, editors, formatters are stored on a
disk until loaded into main Memory & then use
the disk as both the source and destination of their
processing
• Therefore, it is necessary and central important of
proper management of disk storage to a system
• OS is responsible for activities related to disk
management :
1. Free space management
2. Storage allocation
3. Disk scheduling
• As secondary storage is used frequently, it must be
used efficiently
• The entire speed of operation of a system may
affect on the speed of the disk subsystem.
1.7.1 Disk Management
• The OS is responsible for several aspects of
disk management

Figure : Disk structure


• Disk is a secondary storage device that is used to
store data. Disks provide a means to store a large
amount of information for modern computer.
Examples include: Hard Disk, Floppy Disk
• A Disk is usually divided into TRACKS,CYLINDERS
AND SECTORS Hard disks drives are organized as
a concentric stack of disks or ‘platters’.
• Each platter has 2 surfaces and two read/write
heads for each surface. Each platter has the same
No. of tracks. Platter is made from aluminium,
ceramic, or class, coated with a magnetic materials
such as iron oxide.
• Platters: Platters resemble the phonograph records found in an old-
Fashioned Jukebox. Multiple platters increase storage without
equivalent increase in cost.
• Heads: Each platter is associated with the read/write Head. They are
energy converters: i.e., they transform electric signals into
magnetic(write the disk) and vice-versa(read the disk). Tracks- circular
areas of the disk. Length of a track one circumference of disk. Over
1000 on a hard disk. Data first written to outer most track. Sectors-
Divide tracks sections
• Cylinders- Logical groupings of the same track on each disk surface in
a disk unit. OR All the tracks with the same radius are known as a
CYLINDER. Clusters- Several sectors form a cluster. 64 sectors in one
cluster . Groups of sectors used by operating system.
• Platter : A round magnetic plate that constitutes part of a Hard disk.
Hard drives can contain a dozen of platters mounted on the same
spindle. Platters require two read/write heads, one for each side and
therefore can store information on both sides
• Disk Formatting:
• A new disk like a blank slate
• It must be divided into sectors that the disk
controller can read & write before a disk can store
data, this process is called low-level formatting or
physical formatting
• In this process, the disk fills with a special data
structure for a sector, which typically consists of a
header, a data area & a trailer
• Where header & trailer contains information used
by disk controller such as sector number & ECC-
error correcting code
• Boot Block :
• When powered up the system, it needs to have an
initial program to run
• This initial bootstrap program tends to be simple
• It initializes all aspects of the system from CPU
registers to device controllers & the contents of main
memory & then starts the OS
• To do this, bootstrap program finds OS kernel on disk,
loads that kernel into memory & jumps on initial
address to begin the OS execution
• the full bootstrap program is stored in a partition
called the Boot blocks
• A disk that has a boot partition is called a boot disk or
system disk
1.7.2 Space Allocation Strategies
• The disks allows the direct access with flexibility
in the implementation of files
• Many files will be stored on the same disk
• Here main problem is how to allocate space to
these files so that disk space is utilized effectively
& files can be accessed quickly
• There are mainly 3 categories which are widely
used:
1. Contiguous Allocation
2. Linked Allocation
3. Indexed Allocation
1. Contiguous Allocation

Figure : Contiguous Allocation of Disk Space


• It is in sequential manner
• Easy to access
• This method requires each file to occupy a set of
contiguous blocks on the disk
• Disk addresses define a linear ordering on the disk
• This allocation of a file is defined by the disk
address & length (in block units) of the first
block
• If the files is n blocks long & starts at location b,
then it occupies blocks b, b+1,b+2……., b+n-1
• The directory entry for each file indicates the
address of the starting block & the length of the
area allocated for this file
• Advantages
1. It is simple to implement.
2. We will get Excellent read performance.
3. Supports Random Access into files.
• Disadvantages
1. Difficulty to find space for a new file
2. Problem for determining how much space is
needed for a file
3. This suffers from the problem of external
fragmentation
2. Linked Allocation
• Solves the problems of Contiguous
allocation
• In this allocation, each file is a linked list of
disk blocks
• The directory contains a pointer to the first
& the last blocks of the file
• The pointers are not made available to the
user
Figure : Linked Allocation of Disk Space
• In this approach, the pointers (i.e. the disk
address) requires 4 bytes separately
• There is no external fragmentation with linked
allocation

You might also like