You are on page 1of 96

Operating System

Lecture 1 – Introduction
ENGR. Muhammad Talha Jahangir,
MS(Computer Engineering) NUST, Pakistan
mtjahangir17@ce.ceme.edu.pk

Exam Type Marks


Assignment 05
Quiz 10
Mid Term 30
Final 40
Project 10
Class Performance 05
About Me
 Professional Education
 BS Computer Engineering, BZU MULTAN, PAKISTAN
 MS Computer Engineering, NUST, PAKISTAN
 PhD Scholar Computer Engineering, NUST, PAKISTAN

 Work Experience
 MNS UET MULTAN, Pakistan
(Lecturer in CS Department)
 BZU Multan
(Visiting Lecturer in IT, Telecom Department)
 IRAS, Multan Pakistan
(Visiting Lecturer in CS & IT Department)
 MNSUA University of Agriculture, Multan Pakistan
(Visiting Lecturer in CS & IT Department)
 KAIMS International Institute, Multan Pakistan
(Visiting Lecturer in CS & IT Department)
 University Of Central Punjab, Multan Pakistan
(Visiting Lecturer in PHSICS & ADP in IT Department)
 GWC Networks LLC Dubai
(Network Engineer)
 Pakistan Telecommunication Company Limited (PTCL) Data Centre & Pakistan Internet Exchange (Pie), Lahore Pakistan
(Intern)
About Me (Cont…)
 Certifications
 Cisco Certified Network Associate CCNA (Routing & Switching)
 Cisco Certified Network Professional CCNP (Routing & Switching)
 Microsoft Certified Systems Associate (MCSA)
 Microsoft Certified Professional (MCP)
 Microsoft Certified Solutions Expert (MCSE)
 Palo Alto Firewall Accredited Configuration Engineer (ACE (PAN-OS 7.0))
 Cisco Certified Network Associate (Cisco IOS Network Security) & (VOIP)
 Cisco Certification of “Introduction of Data Science”
 Cisco Certification of “Python-1”
 Cisco Certification of “Python-2”
 Workshops & Seminars
 Blockchain Workshop Conducted By IBM conducted by NUST
 Designing & Delivering Data Science Course at Scale Workshop conducted by LUMS
 Competition
 3MT Competition in NUST
Software House & Computer Training Institute
JTech Solution’s & Computer Academy Links
1. Website

https://jtechsolutionspk.com/

2. Facebook Page

https://m.facebook.com/JtechSolutionsAcademy/

3. Instagram Page

https://www.instagram.com/jtechsolution93/

4. YouTube Channel

https://www.youtube.com/channel/UCvq1NY2HnxzptJ3PSU75zsA?app=desktop
Previous Work
1. SDN Based Inter-Isp Caching of Big Data (MSc Research)
Previous Work
1. Results

Cache User User User User User


server Location request request request from request from request from
from 1a from 2a 3a 4a 5a
1a 91.54 101.95m 114.43ms 93.64ms 99.88ms
ms s
2a 101.95 91.55ms 112.36ms 104.05ms 110.28ms
ms
3a 114.43 112.36m 91.55ms 112.36 106.12ms
ms s
4a 93.58 103.96m 112.31ms 91.5ms 97.72ms
ms s
5a 99.88 110.28m 106.12ms 97.8ms 91.55ms
ms s
Previous Work
2. PROCESS TIME REDUCTION IN HOMOGENEOUS
RASPBERRY PI CLUSTER USING LINUX OPERATING
SYSTEM (BSc FYP Project)
Previous Work
3. Free Falling and Obstacle Prevention Arduino Based
Bluetooth Control Car
Previous Work
4. Live Tracking and Accident Detection System
Previous Work
5. University Bus Tracker System
Previous Work
6. An improved Strategy of Preventing DDOS Attack
Previous Work
7. Degree Management System of MNS, Uet, Multan
Previous Work
8. Face Recognization Sytem for Attendence and the
identification of Covid Vaccination
Previous Work
9. IOT and Deep learning based Plant Monitoring and Disease
Classification System
Previous Work
10. Classification of Iris flowers with Machine Learning
Previous Work
11. ERP SYSTEM of MNS, UET
Previous Work
12. Sentimental Analysis on Amazon Product Review’s Using
Deep Learning
Previous Work
13. Email Spam Filtering using Deep Learning
Previous Work
14. Efficient Mobile-Driven Automated Attendance system
employing Biometric Authentication for University Employees
Previous Work
15. Voice Assistants for Comprehensive University General
Question Handling
Previous Work
16. Defender OF Fort: AI-Powered Adventure Game Based On
Saint City Multan
Previous Work
17. Leveraging Deep Convolutional Neural Networks For
Accurate Discrimination Between Benign And Malignant Skin
Lesions
Previous Work
18. Systematic Approach To Analyze The Avast IOT-23
Challenge Dataset For Malware Detection Using
Machine Learning
Previous Work
18. Systematic Approach To Analyze The Avast IOT-23
Challenge Dataset For Malware Detection Using
Machine Learning
Previous Work
19. Bilingual Toxic Comment Classification In English And
Roman Urdu Through Machine Learning
Previous Work
20. Advancing WiFi Intrusion Detection Systems with Machine
Learning Techniques for Enhanced Classification of Wireless
Attacks
NGIRI (Shortlisted For Funding)
1. IOT and Deep Learning based Plan Monitoring
System and Disease Classification
(FYP CODE: NGIRI-2022-14526)

2. University Bus Tracking System


(FYP CODE: NGIRI-2022-15152)
Research Papers
1. Journal Paper

“A Novel Cooperative Micro-Caching Algorithm


based on Fuzzy Inference through NFV in Ultra-
Dense IoT Networks”
(Springer, Impact factor: 2.198, Published: 2021)

2. Conference Paper

“Subject Wise Motor Imagery Classification


from EEG Data Using Neural Networks”
(IEEE, 24th International Multi Topic Conference 2022)
Areas Of Interest & Research
1. Data Science

2. Digital Signal Processing

3. Cybersecurity

4. Data Structure & Algorithm Analysis

5. Software Engineering
CODE OF ETHICS
 All students must come to class on time (Attendance will
be taken in first 5 to 10 mins)
 Students should remain attentive during class and avoid
use of Mobile phone, Laptops or any gadgets
 Obedience to all laws, discipline code, rules and
community norms
 Respect peers, faculty and staff through actions and
speech
 Student should not be sleeping during class
 Bring writing material and books
 Class participation is encouraged, if someone shy to ask
questions, then student can ask me questions via Piazza
platform. (Piazza Access code: ds101)
Email Submission Policy
 When emailing me, please format the subject line as
follows:

 “Course - <First name> - <subject>” e.g. “DS-TALHA-


Assignment1

 While submitting assignments all related files must be


enclosed in a “.rar” file.

 File name “must” be same as mentioned above.

 Email Id is: talha93uet@gmail.com


Course Outline
• What is Operating systems
• Types of Operating System
• OS Design & Implementation
• DOS
• Layered Kernel
• Monolithic Kernel
• Microkernel
• Exo-kernel
• Hybrid Approaches
• Why operating System is Required in Computer
• What is system calls
• Types of systems calls
• What is Interrupts
• Difference between Interrupts and Pooling
• Difference between Interrupts and Traps
• Interrupt processing (Interrupt Service Routine)
• Process states
• Process states transitions
• Process life cycle
• Five state process model
Course Outline
• Context Switch
• Scheduler
• Scheduling algorithm
• Objectives of Scheduling
• Criteria for scheduling
• CPU-bound vs I/O-bound processes
• Process scheduling queues
• Difference between preemptive and non-preemptive Scheduling
• Scheduling Algorithms
• FCFS (First Come First Served),
• SJF (Shortest Job First)
• Priority Scheduling
• Round Robin,
• Multilevel feedback queues scheduling
• Inter-process communication
• Multithreaded programming
• Multithreading models
• Threading issues
Course Outline
• Thread scheduling
• Synchronization
• Race Condition
• Critical section
• Semaphores
• Synchronization hardware
• Synchronization problems
• Bounded-Buffer Problem
• Readers and Writers Problem
• Dining Philosophers Problem
• Deadlocks
• Detecting and recovering from deadlocks
• What is Memory
• Memory hierarchy
• Process loading and swapping
• Memory management
• Memory allocation methods
• Single partition allocation
• Storage management strategies
• Fetch strategies
Course Outline
• Placement strategies
• Replacement strategies
• Variable partition with compaction
• Noncontiguous memory allocation: Paging vs Segmentation
• Simple paging
• Implementation of paging
• Simple segmentation
• Segment addressing
• Virtual memory
• Mechanism of virtual memory
• Address translation
• Page fault
• Page replacement
• Page replacement algorithm
• FIFO
• Belady’s anomaly
• Optimal LRU
• Random page replacement
• LFU
• MFU
Course Outline
• Non-used recently page replacement algorithm
• Paging Mechanism
• Memory protection and sharing
• MS-DOS Memory management
• Windows memory management
• Unix memory management file systems
• RAID
• File concept
• Directory and disk structure
• Directory implementation
• Free space management
• Disk structure and scheduling
• Swap space management
• Operating System Networking and Security
Expected Outcome
A student who successfully completes the course will have the ability to:
 Understand the Internal Working of Operating System.
 Understand fundamental operating system abstractions such as processes,
threads, files, semaphores, IPC abstractions, shared memory regions, etc
 Develop low-level operating system code.
 Analyze important algorithms eg. Process scheduling and memory
management algorithm
 Parallelize the code using threads.
 Learn different process scheduling algorithms and synchronization
techniques to achieve better performance of a computer system.
 Understand virtual memory concepts.
 Learn secondary memory management.
 Understand the OS design of Microsoft and Linux Operating System.
 Understand and Evaluate Research published in the field of operating
systems at a level commensurate with their experience.
 Appear in any operating system based computer related Job Interviews
and Written Tests.
Relevant Books
1. Operating Systems Concepts, 9th edition by Abraham
Silberschatz
2. Operating Systems Internals and Design Principles by
William Stallings
3. A Comprehensive Study Operating System & Networks
by Tariq Mehmood (IT Series)

 Programming Tool: Python, C++


Chapter 1: Introduction
1.1 Introduction
1.2 What is an Operating System?
1.3 Can computer system work without OS?
1.4 Computer-System Organization
1.5 Operating-System Structure
1.6 Operating-System Operations
1.7 Computer Startup
1.8 Open Vs. Closed Source Operating System
1.9 Types of OS
1.10 Memory Hierarchy
1.11 Top Level Components of Computer
1.12 Instruction Life Cycle
1.13 Policy & Mechanism
1.14 Operating System Modes
1.15 Operating System Architecture
1.16 System Call
1.17 Difference Among Interrupts, pooling and traps
1.18 Interrupt Processing
1.19 Device Controller
1.20 Direct Memory Access (DMA)
1.21 Process Management
1.22 Memory Management
1.23 Storage Management
1.24 Hardware Protection
1.25 POSIX
Introduction
 A computer is a versatile electronic device that can perform computations and
make logical decisions billions of times faster than human beings can.
 Computer is Fast but it is dumb it cannot do any task our instruction.
 Computers process data under the control of sets of instructions called
computer programs.
 These programs guide the computer through orderly sets of actions specified by
people called computer programmers.
 If we are talking about AI systems, game has been changed.
 AI systems can process vast amounts of data, recognize patterns, and perform
complex tasks that would be challenging or impossible for humans to achieve
quickly and accurately.
 AI technologies include machine learning, deep learning, natural language
processing, and more, all of which enable computers to perform tasks that seem
intelligent.
 Main Components of Computer:
 A computer consists of various devices referred to as hardware (e.g., the
keyboard, screen, mouse, hard disk, memory, DVDs and processing units).
 The programs that run on a computer, untouchable and and data that
control the operation of the hardware are referred to as software.
Across Incredible Diversity

Computers
Per Person Number
crunching,
1:106 Data Storage,
Massive Inet
Mainframe Services,
Bell’s Law: Mini
ML, …
1:103
New Workstatio Productivity,
computer n PC Interactive
1:1 Laptop
class every PD
10 years A Ce Streaming
from/to the
103:1 ll physical world

years Mo
The Internet
te!
of Things!
HW Functionality comes with great complexity!
For Instance: Software Complexity keeps growing!

Linux 2.2.0

Mars Curiosity Rover

Firefox New Versions usually (much) larger older versions!


Android

Linux 3.1 (recent)

Windows 7

Microsoft Office 2013

Windows Vista Cars getting really complex!


Facebook

Mac OS X "Tiger"

Modern Car

Mouse Base Pairs

0 20 40 60 80 100 120 140

Millions of Lines of Code


(source https://informationisbeautiful.net/visualizations/million-lines-of-code/)
What is an Operating System?
 The one program always running on the computer” is the kernel.
 Everything else is either a system program or an application program.
 The kernel is a fundamental component of an operating system.
 An operating system, on the other hand, is a broader software package that
includes not only the kernel but also various system utilities, libraries, user
interfaces, and applications that together provide an environment for users
and software to interact with the 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.
Hardware/Software Interface

Running
Software Program
Instruction Set Architecture (ISA)
Hardware Memory
Page
Table
& TLB Cache
Processor

OS Memory

Ctrlr Networks The OS abstracts


these hardware
Storag details from the
e
application
Displays
Inputs
Can computer system work without OS?
 The operating system is a program that acts like a manager to
all the other programs on the computer.
 It also decides how much memory to allocate to each program
that is running.
 Without an operating system, the computer would only be
able to run one program at a time.
 Example of the computer without Operating system is BIOS.
 BIOS is not microcontroller. The BIOS chip is just flash
memory. All execution is done by the CPU.
 Many devices we encounter daily, such as digital cameras,
microwave ovens, and vending machines, use specialized
embedded systems. These systems are designed to perform a
specific function and often do not require a full-fledged OS.
Instead, they run on custom firmware that directly controls
the hardware and implements the required functionality.
Explanation
 The microcontroller is the heart of an embedded
system. The microprocessor is the heart of a
Computer system.
 A typical microcontroller includes a processor,
memory and input/output (I/O) peripherals on a
single chip.
 Microcontrollers can't run an operating system.
 Arduino is an example of microcontroller.
 A typical microcontroller includes a processor,
memory and input/output (I/O) peripherals on a
single chip.
 Microcontrollers can't run an operating system.
 Arduino is an example of microcontroller.
Diagram
Computer System Organization
 Computer Organization comes after the decision of
Computer Architecture.
Computer System Structure
 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
High Level Components of a Computer System
Computer-System Operation
 I/O devices and the CPU can execute concurrently (one after
other).
 Peripheral Component Interconnect is a common connection
interface for attaching computer peripherals to the motherboard.
 PCI was popular between 1995 and 2005 and was most often
used to connect sound cards, network cards, and video cards.
 Now-a-days PCI-e technology is used (PCIe 4.0 enables a more robust
equalization. In term of performance, with PCIe 4.0, throughput per lane is 16 GT/s. The
link is full duplex, which means the data can be sent and received simultaneously a Total
Bandwidth: 32GT/s)
 Each device controller is in charge of a particular device type.
 Each device controller has a local buffer.
 CPU moves data from/to main memory to/from local buffers
 I/O is from the device to local buffer of controller.
 Device controller informs CPU that it has finished its operation
by causing an interrupt.
Diagram
Function of Computer-System
 Below are the main functions of Operating System:
Explanation
 In an operating system software performs each of the function:
 Process management: Process management helps OS to
create and delete processes. It also provides mechanisms for
synchronization and communication among processes.
 Memory management: Memory management module
performs the task of allocation and de-allocation of memory space
to programs in need of this resources.
 File management: It manages all the file-related activities such
as organization storage, retrieval, naming, sharing, and protection
of files.
 Device Management: Device management keeps tracks of all
devices. This module also responsible for this task is known as the
I/O controller. It also performs the task of allocation and de-
allocation of the devices.
 I/O System Management: One of the main objects of any OS
is to hide the peculiarities of that hardware devices from the user.
Cont …
 Secondary-Storage Management: Systems have several levels
of storage which includes primary storage, secondary storage, and
cache storage. Instructions and data must be stored in primary
storage or cache so that a running program can reference it.
 Security: Security module protects the data and information of a
computer system against malware threat and authorized access.
 Command interpretation: This module is interpreting
commands given by the and acting system resources to process
that commands.
 Networking: A distributed system is a group of processors
which do not share memory, hardware devices, or a clock. The
processors communicate with one another through the network.
 Job accounting: Keeping track of time & resource used by
various job and users.
 Communication management: Coordination and assignment
of compilers, interpreters, and another software resource of the
various users of the computer systems.
Abstract View

Compiled
Program

System Libs

Process: Execution environment with restricted rights


provided by OS
Threads Address Spaces Files Socket
s
Operating System
ISA
PgTbl Networks
Processor Memory
& TLB Storage
Hardware OS
Mem

I/O Ctrlr
Compiled Program’s View of the World

Compiled
Program

System Libs

Process: Execution environment with restricted rights


provided by OS
Threads Address Spaces Files Socket
s
Operating System
ISA • Application’s “machine” is the process abstraction provided by the
OS PgTbl Networks
Processor Memory
& TLB Storage
Hardware • Each running program runs in OS
its own process
• Processes provide nicer interfaces
Mem than raw hardware
I/O Ctrlr
System Programmer’s View of the World

Program
Linker
System Libs

Process: Execution environment with restricted rights


Compile provided by OS
Threads Address Spaces Files Socket
r s
Operating System
ISA • Application’s “machine” is the process abstraction provided by the
OS PgTbl Networks
Processor Memory
& TLB Storage
Hardware • Each running program runs in OS
its own process
• Processes provide nicer interfaces
Mem than raw hardware
I/O Ctrlr
What’s in a Process?

A process consists of:


 Address Space
 One or more threads of control executing in that
address space
 Additional system state associated with it
 Open files
 Open sockets (network connections)
 …
Operating System’s View of the World

Compiled Compiled
Program 1 Program 2

System Libs System Libs

Process 1 Process 2
Compile
Threads Address Spaces Files Sockets Threads Address Spaces Files Sockets
r
Operating System
ISA
PgTbl Networks
Processor Memory
& TLB Storage
Hardware OS
Mem

I/O Ctrlr
Operating System’s View of the World

• OS translates fromRunning Running


hardware interface to application interface
running1program with its own process Program 2
• OS provides eachProgram

System Libs System Libs

Process 1 Process 2
Compile
Threads Address Spaces Files Sockets Threads Address Spaces Files Sockets
r
Operating System
ISA
PgTbl Networks
Processor Memory
& TLB Storage
Hardware OS
Mem

I/O Ctrlr
OS Basics: Running a Process

Compiled Compiled
Program 1 Program 2

System Libs System Libs

Process 1 Process 2
Compile
Threads Address Spaces Files Sockets Threads Address Spaces Files Sockets
r
Operating System
ISA
PgTbl Networks
Processor Memory
& TLB Storage
Hardware

I/O Ctrlr
OS Basics: Switching Processes

Compiled Compiled
Program 1 Program 2

System Libs System Libs

Process 1 Process 2
Compile
Threads Address Spaces Files Sockets Threads Address Spaces Files Sockets
r
Operating System
ISA
PgTbl Networks
Processor Memory
& TLB Storage
Hardware OS
Mem

I/O Ctrlr
OS Basics: Switching Processes

Compiled Compiled
Program 1 Program 2

System Libs System Libs

Process 1 Process 2
Compile
Threads Address Spaces Files Sockets Threads Address Spaces Files Sockets
r
Operating System
ISA
PgTbl Networks
Processor Memory
& TLB Storage
Hardware OS
Mem

I/O Ctrlr
OS Basics: Switching Processes

Compiled Compiled
Program 1 Program 2

System Libs System Libs

Process 1 Process 2
Compile
Threads Address Spaces Files Sockets Threads Address Spaces Files Sockets
r
Operating System
ISA
PgTbl Networks
Processor Memory
& TLB Storage
Hardware OS
Mem

I/O Ctrlr
OS Basics: Switching Processes

Compiled Compiled
Program 1 Program 2

System Libs System Libs

Process 1 Process 2
Compile
Threads Address Spaces Files Sockets Threads Address Spaces Files Sockets
r
Operating System
ISA
PgTbl Networks
Processor Memory
& TLB Storage
Hardware OS
Mem

I/O Ctrlr
OS Basics: Protection

Compiled Compiled
Program 1 Program 2

System Libs System Libs

Process 1 Process 2
Compile
Threads Address Spaces Files Sockets Threads Address Spaces Files Sockets
r
Operating System
ISA
PgTbl Networks
Processor Memory
& TLB Storage
Hardware OS
Mem

I/O Ctrlr
OS Basics: Protection

Segmentation
fault (core
Compiled Compiled
dumped)
Program 1 Program 2

System Libs System Libs

Process 1 Process 2
Compile
Threads Address Spaces Files Sockets Threads Address Spaces Files Sockets
r
Operating System
ISA
PgTbl Networks
Processor Memory
& TLB Storage
Hardware OS
Mem

I/O Ctrlr
Computer Startup
• bootstrap program is loaded at power-up or reboot
– Typically stored in ROM or EPROM, generally known as
firmware (Firmware provides instructions to help hardware start
up, communicate with other devices, and perform basic
input/output tasks. )
– First thing BIOS does when it boots the PC is to perform what is
called POWER-ON-SELF-TEST (POST).
– Loads operating system kernel and starts execution
Open Vs. Closed Source Operating System
 Closed-source operating systems use code that is proprietary and kept secret
to prevent its use by other entities.
 Traditionally, they are sold for a profit.
 Open-source operating systems use code that is freely-distributed and available
to anyone to use, even for commercial purposes.
 Both types of operating systems have advantages.
 Linux is open source operating system while Microsoft window is closed
source OS.

 Note

1. Freeware, as name suggests, is


simply a product or software that is
free to use, requires no payment and
allows user to have access to it
without any restriction except some
restrictions on its commercial-use.

2. Public domain software is any


software that has no legal,
copyright or editing restrictions
associated with it. It is free and
open-source software that can be
publicly modified, distributed or
sold without any restrictions.
Types of OS
Types of operating system are:

1. Single-user operating systems


2. Batch operating systems
3. Multi programmed operating system
4. Time-sharing operating system
5. Real time operating system
6. Network Operating System
7. Distributed operating system
Single-user Multiple Tasking operating Systems
 An operating system that allows a single user to perform more than one task at a time is
called Single-User Multitasking Operating System.
 Examples include Microsoft Windows and Macintosh OS.
Single-user Single Tasking operating Systems
 A computer system that allows only one user to use the computer at a given time is
known as a single-user system.
 The goals of such systems are maximizing user convenience and responsiveness,
instead of maximizing the utilization of the CPU and peripheral devices.
 Single-user systems use I/O devices such as keyboards, mice, display screens,
scanners, and small printers.
 They can adopt technology developed for larger operating systems.
 Often individuals have sole use of computer and do not need advanced CPU
utilization and hardware protection features.
 They may run different types of operating systems, including DOS, Windows, and
MacOS.
 Linux and UNIX operating systems can also be run in single-user mode.
Batch Systems operating Systems
 In the earlier time when the operating system was not available then every program
required full hardware access or time for execution.
 To overcome this problem and used the CPU efficiently, the operating system introduced.
 By the early 1950’s, the General Motors Research Laboratories implemented the
first Single-Stream batch processing systems.
 Batch Operating System was the First operating system of the second-generation
computer is the batch operating system.
 Batch operating system took the input on the punch card.
 Each punch card contained different data or instructions.
 This allowed for the input of multiple jobs that were processed one after the other.
 When one job from the batch executed, then the second job has taken from it and so on.
 The process of placing the jobs in queue for execution is known as spooling.
How its work:
 OS keeps the number of jobs in memory and executes them one by one.
 Jobs processed in first come first served order. Each set of a job considered as a
batch.
 When a job completes its execution, its memory is released, and the output for the
job gets copied into an output spool for later printing or processing.
 User interaction in the batch processing system is minimal.
 One’s system accepts the jobs from users, and then the user is free.
Explanation
 For example, all FORTRAN programs were complied one after the other.
 The major task of such an operating system was to transfer control
automatically from one job to the next.
 In this execution environment, the CPU is often idle because the speeds of
the mechanical I/O devices such as a tape drive are slower than that of
electronic devices.
 Such systems in which the user does not get to interact with his/her jobs
and jobs with similar needs are executed in a “batch”, one after the other,
are known as batch systems.
 Digital Equipment Corporation’s VMS is an example of a batch operating
system.
Spooling
 Spooling stands for "Simultaneous Peripheral Operations Online".
 Here peripheral mean Input output devices.
 So, in a Spooling, more than one I/O operations can be performed
simultaneously i.e. at the time when the CPU is executing some process then
more than one I/O operations can also de done at the same time.
 This method was used when processor was support only uniprogramming not
multiprogramming.
 As we know that, Input and output devices are relatively slow as compared to
CPU.
 When CPU directly execute I/O operation it consume lot of time such as we
can type some alphabets (may be 5 alphabets in one second) but I GHz processor
process one billion instruction in one second.
 So when CPU directly execute I/O instruction it will slow down the speed of
CPU.
 Spooling provide the solution of this problem.
 In spooling, data is first stored into the disk, and then cpu interact with the disk via
RAM.
 Advantage:
1. No directly interaction of I/O device with CPU.
2. CPU utilization is more as CPU is busy most of the time (CPU process its task, moreover
cpu process the I/O task which are stored in the hard.) .
Diagram
Explanation
 From the previous image, we can see that the input data is stored in some kind of secondary
device and this data is then fetched by the main memory.
 The benefit of this approach is that, in general, the CPU works on the data stored in the main
memory.
 Since we can have a number of input devices at a time, so all these input devices can put the data
into the disk or secondary memory.
 Then, the main memory will fetch the data one by one from the secondary memory and the
CPU will execute some instruction on that data.
 Both the main memory and secondary memory are digital in nature, so taking data from
the main to secondary is very fast.
 Also, when the CPU is executing some task then at that time, the input devices need not wait
for its turn.
 They can directly put their data in the secondary memory without waiting for its turn.
 By doing so, the CPU will be in the execution phase most of the time. So, the CPU will not be
idle in this case.
 When the CPU generates some output, then that output is first stored in the main memory
and the main memory transfers that output to the secondary memory and from the
secondary memory, the output will be provided to some output devices.
 By doing so, again we are saving time because now the CPU doesn't have to wait for the
output device to show the output and this, in turn, increases the overall execution speed of
the system. The CPU will not be held idle in this case.
 For example, in a printer spooling, there can be more than one documents that need to be
printed.
 So, the documents can be stored into the spool and the printer can fetch that documents and
print the document one by one.
Buffering
 The main memory has an area called buffer that is
used to store or hold the data temporarily that is
being transmitted either between two devices or
between a device or an application.
 Buffering is an act of storing data temporarily in
the buffer.
 It helps in matching the speed of the data stream
between the sender and the receiver.
 If the speed of the sender’s transmission is slower
than the receiver, then a buffer is created in the
main memory of the receiver, and it accumulates
the bytes received from the sender and vice versa.
Spooling VS Buffer
 A spooling is a buffer that holds the jobs or tasks for a system until the
system is ready to accept or execute another job.
 In spooling, the input/output of a job is overlapped with the computation of
another job.
 For instance, a spooler may read the input of a job and simultaneously print
the output of another job.
 On other hand Buffering is an act of storing data temporarily in the buffer
which is present in the RAM, while spooling having a storage in the hard
disk.
Mutliprogramming operating Systems
 Batch OS is the grouping of various processing jobs that are run one after
another by a system without user input.
 In contrast, multiprogramming OS is the ability of an OS to run multiple
programs on a single processor simultaneously.
 The multi-programming is interleaved execution of multiple jobs by the
same computer.
 Multiprogramming OS is faster than batch operating system.
 As we know that, I/O device consume more time than CPU.
 In multi-programming system, when one program is waiting for I/O
transfer; there is another program ready to utilize the CPU.
 While in batch operating system, a series of jobs are executed without any
human intervention.
 So, in Multiprogrammed OS, it is possible for several jobs to share the time
of the CPU.
 But it is important to note that multi-programming is not defined to be
the execution of jobs at the same instance of time.
 Rather it does mean that there are a number of jobs available to the CPU
(placed in main memory) and a portion of one is executed then a segment of
another and so on.
Explanation
 A simple process of multi-programming is shown in figure:

 In our example below, P1 and P2


would finish their execution in 10
time units, if no
multiprogramming is used and in
six time units if
multiprogramming is used.

 As shown in fig, at the particular situation, job’ A’ is not utilizing the CPU time because it
is busy in I/ 0 operations.
 Hence the CPU becomes busy to execute the job ‘B’.
 Another job C is waiting for the CPU for getting its execution time. So in this state the
CPU will never be idle and utilizes maximum of its time.
 A program in execution is called a “Process”, “Job” or a “Task”.
 The concurrent execution of programs improves the utilization of system resources and
enhances the system throughput as compared to batch and serial processing.
Diagram
Time Sharing operating Systems
 A time-sharing system is multi-user, multi-process, and
interactive system.
 This means that it allows multiple users to use the
computer simultaneously.
 A user can run one or more processes at the same
time and interact with his/her processes.
 A time-shared system uses multiprogramming and CPU
scheduling to provide each user with a small portion of a
time-shared computer.
 In Time Sharing OS, response time should be < 1 second.
 Each user has at least one separate program in memory.
 To obtain a reasonable response time, jobs may have to be
swapped in and out of main memory.
 UNIX, Linux, Widows NT server, and Windows 2000
server are timesharing systems.
Time Sharing vs Multiprogramming OS
 The main difference between Multiprogrammed OS’s and
Time-Sharing OS’s is that in case of Multiprogrammed batch
systems, the objective is to maximize processor use, whereas in
Time-Sharing Systems, the objective is to minimize response
time.
 Multiple jobs are executed by the CPU by switching between
them, but the switches occur so frequently.
 Thus, the user can receive an immediate response.
 For example, in a transaction processing (Banks), the processor
executes each user program in a short burst or quantum of
computation.
 That is, if n users are present, then each user can get a time
quantum.
 When the user submits the command, the response time is in few
seconds at most.
 The operating system uses CPU scheduling and
multiprogramming to provide each user with a small portion of a
time.
Diagram
Real Time operating Systems
Real Time operating Systems
 A real time system has well defined, fixed time
constraints, and if the system does not produce
output for an input within the time constraints,
the system will fail.
 Often used as a control device in a dedicated
application such as controlling scientific
experiments, medical imaging systems,
industrial control systems, and some
embedded systems.
 Well-defined fixed-time constraints.

 Two Types:
1. Hard Real Time OS
2. Soft Real Time OS
Hard Real Time OS
 Hard RTOS OSs are meant for applications where time
constraints are very strict and even the shortest
possible delay is not acceptable.
 These systems are built for saving life like automatic
parachutes or airbags which are required to be readily
available in case of any accident.
 A hard real time system guarantees that critical tasks
be completed on time. This goal requires that all delays in
the system be completed on time.
Examples of Hard Real-Time Systems
 Below are some examples of the hard real-time
operating system, such as:
Flight Control Systems
Missile Guidance Systems
Weapons Defense System
Medical System
Railway signalling system
Air traffic control systems
Anti-missile system
Chemical plant control
Autopilot System in Plane and car.
Etc.
Soft Real Time OS
 A less restrictive type of real time system is a soft real time
system, where a critical real-time task gets priority over other
tasks, and retains that priority until it completes.

 If the system, did not perform the task within the deadline it is
not considered as a failure as long as it provides the required output.
 But performance is considered to be degraded.
 In this type of system, missing an occasional deadline, while not
desirable, is acceptable and does not cause any permanent
damage.
 Some examples of software real-time systems are multimedia
streaming, advanced scientific projects, and virtual reality.
 Linux and many OS provide a soft real time system.
Network OS
 An Operating system, which includes software and
associated protocols to communicate with other
autonomous computers via a network conveniently and
cost-effectively, is called Network Operating System.
 It allows devices like a disk, printers, etc., shared
between computers.
Distributed OS
 Distributed Operating System is a loosely coupled system,
where distributed applications are running on multiple
computers linked by communications.
 A distributed operating system is an extension of the network
operating system that supports higher levels of
communication and integration of the machines on the
network.
 This system looks to its users like an ordinary centralized
operating system but runs on multiple, independent central
processing units (CPUs).
 This type of OS provide a greate feature of scalability.
 For example, Rocks Cluster Distribution is an example of
Distributed OS.
 It is the Linux distribution intended for high-performance
computing clusters.
 Google Search Engine also used the service of Distributed OS.
Diagram

You might also like