Module 1
M1-L1
Introduction to OS
2
What is an 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
Source: “Operating System Concepts: 9th Edition” by
Silberschatz Galvin Gagne
Introduction to OS 3
Operating System(OS) manages computer hardware.
Application Program runs on OS
Computer User interacts with the OS which in turn interacts with the
hardware.
Variety of OS depending on the tasks. Example:-
Mainframe OS
Optimize hardware utilization
Computer standard OS
Standard Application, Games, etc.
Handheld OS -> Apps, etc.
4
OS as a base for Application Programs 5
OS is a resource allocator
Manages all resources
Decides between conflicting requests for efficient and fair resource use
OS is a control program
Controls execution of programs to prevent errors and improper use of the computer
Application program runs on a platform and that platform is an Operating systems.
OS plays an important role to determine which application you need, because some
applications may exists only in some OS.
Example:
Words in windows
Libre office in linux
6
Schematic of Operating System Services
Silberschatz, Gagne, Galvin: Operating System Concepts, 6th Edition
Schematic of Operating System functionality 7
Different types of OS 8
Microsoft Windows
Mainframe
DOS
OS/2
Linux - Example Ubuntu
Mac OS
AmigaOS
Types of Operating Systems
1. Batch Operating System
2. Multiprogramming Operating System
3. Time-Sharing OS
4. Multiprocessing OS
5. Distributed OS
6. Real Time OS
1. Batch Operating System
The users of this type of operating system does not interact with the computer
directly.
Each user prepares his job on an off-line device like punch cards and
submits it to the computer operator
There is an operator which takes similar jobs having the same requirement and
group them into batches.
Batch Operating System cont..
Advantages of Batch Operating System:
Processors of the batch systems know how long the job would be when it is
in queue
Multiple users can share the batch systems
The idle time for the batch system is very less
It is easy to manage large work repeatedly in batch systems
Disadvantages of Batch Operating System:
The computer operators should be well known with batch systems
Batch systems are hard to debug
It is sometimes costly
The other jobs will have to wait for an unknown time if any job fails
Examples of Batch based Operating System:
IBM's MVS
2. Multiprogramming Operating System:
This type of OS is used to execute more than one jobs simultaneously by a
single processor.
It increases CPU utilization by organizing jobs so that the CPU always has one
job to execute.
Multiprogramming operating systems use the mechanism of job scheduling and
CPU scheduling.
3. Time-Sharing Operating Systems
Each task is given some time to execute so that all the tasks work smoothly.
These systems are also known as Multi-tasking Systems.
The task can be from a single user or different users also.
The time that each task gets to execute is called quantum.
After this time interval is over OS switches over to the next task.
Time-Sharing Systems–Interactive Computing 14
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 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” from the user’s keyboard.
On-line system must be available for users
to access data and code.
Time-Sharing Operating Systems cont..
Advantages of Time-Sharing OS:
Each task gets an equal opportunity
Fewer chances of duplication of software
CPU idle time can be reduced
Disadvantages of Time-Sharing OS:
Reliability problem
One must have to take care of the security and integrity of user programs
and data
Data communication problem
Examples of Time-Sharing Oss
Multics, Unix, etc.
4. Multiprocessor operating systems
Multiprocessor operating systems are also known as parallel
OS or tightly coupled OS.
Such operating systems have more than one processor in close
communication that sharing the computer bus, the clock and
sometimes memory and peripheral devices.
It executes multiple jobs at the same time and makes the
processing faster.
It supports large physical address space and larger virtual
address space.
If one processor fails then other processor should retrieve the
interrupted process state so execution of process can
continue.
Inter-processes communication mechanism is provided and
implemented in hardware.
Multiprocessor 17
Multiprocessor systems with more than on 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
Symmetric multiprocessing (SMP)
Each processor runs and 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
allocated work to slave processors.
More common in extremely large systems
5. Distributed Operating System
Various autonomous interconnected computers communicate with each other using a
shared communication network.
Independent systems possess their own memory unit and CPU.
These are referred to as loosely coupled systems.
Examples:- Locus, DYSEAC
Distributed Systems 19
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
Requires networking infrastructure.
Local area networks (LAN) or Wide area networks (WAN)
May be either client-server or peer-to-peer systems.
6. Real-Time Operating System
These types of OSs serve real-time systems.
The time interval required to process and respond to inputs is
very small.
This time interval is called response time.
Real-time systems are used when there are time requirements
that are very strict like
missile systems,
air traffic control systems,
robots, etc.
Real-Time Systems 21
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.
Real-Time Systems 22
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.
OS Services
23
User Interface: There are different kinds, like touchscreen, GUI, and command-line.
Program Execution: (Execute programs for users)
I/O operations: It is much too difficult for users to operate the I/O hardware correctly
without help.
File System Manipulation: The OS helps us store, organize, manage, and protect our
information.
Communications: Users need their processes to exchange information. OSs help. The
two main ways to do it are with shared memory and by message passing.
Error Detection: An OS continually checks to see if something is going wrong. The OS
is programmed to take appropriate action.
Resource Allocation
Logging:
Records for accounting, fault detection, failure, protection, maintenance, update, security, etc.
Protection and Security.
Program execution 24
OS handles many activities, that are encapsulated as a process.
Process refer to a full execution that includes:-
code to execute,
data to manipulate,
registers,
OS resources in use.
When Program is executing the OS manages the following:
Loads a program into memory.
Executes the program.
Handles program's execution.
Provides a mechanism for process synchronization.
Provides a mechanism for process communication.
Provides a mechanism for deadlock handling.
Design Goals 25
Design Goals:
system that is convenient,
reliable,
safe, and
fast.
Implementation: The implementation of the operating system, that is the
manner in which the ideas of the design are written in programming language(s).
Assembly
High Level Language
Earlier assembly could make the code run faster but nowadays high-level are
translated to equivalently good assembly code.
Instead performance of OS will increase if selection data structure and
algorithms are done rather than proper assembly code.
Operating System Structure 26
Simple
Monolithic
Micro-kernel models
Layered (conceptual)
Modular
Kernels may be classified mainly in three categories: -
Monolithic Kernel
Micro Kernel
Hybrid Kernel
Simple 27
Advantages of Simple structure:
It delivers better application performance
because of the few interfaces between the
application program and the hardware.
Easy for kernel developers to develop such
an operating system.
Disadvantages of Simple structure:
The structure is very complicated as no
clear boundaries exists between modules.
It does not enforce data hiding in the
operating system.
Monolithic 28
Monolithic Kernel
value on speed and efficiency.
Monolithic is a single static
binary file.
It executes in a single address
space.
Silberschatz, Gagne, Galvin: Operating System Concepts, 6th Edition
Layered
29
Division into number of layers as shown in figure.
Innermost layer is hardware
Outermost layer is interface
Advantages of Layered structure:
Layering makes it easier to enhance the operating system as
implementation of a layer can be changed easily without
affecting the other layers.
It is very easy to perform debugging and system verification.
Disadvantages of Layered structure:
In this structure the application performance is degraded as
compared to simple structure.
It requires careful planning for designing the layers as higher
layers use the functionalities of only the lower layers.
Silberschatz, Gagne, Galvin: Operating System Concepts, 6th Edition
Microkernels:
30
Keep only necessary component in kernel. Others are implemented as programs (system or user level).
Resulting in a kernel smaller in size.
Minimal process management
Minimal memory management
Main role is that it facilitates communication between the client program and the various services that
are running in user space.
Mach example of microkernel
Mac OS X kernel (Darwin) partly based on Mach
Communication takes place between user modules using message passing
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 communication
31
Microkernel 32
Silberschatz, Gagne, Galvin: Operating System Concepts, 6th Edition
Monolithic vs Microkernel 33
Source: www.atg.world/Monolithic vs Microkernel
34
BASIS FOR COMPARISON MICROKERNEL MONOLITHIC KERNEL
Basic In microkernel user services and In monolithic kernel, both user services
kernel, services are kept in separate and kernel services are kept in the
address space. same address space.
Size Microkernel are smaller in size. Monolithic kernel is larger than
microkernel.
Execution Slow execution. Fast execution.
Extendible The microkernel is easily extendible. The monolithic kernel is hard to extend.
Security If a service crashes, it does effect on If a service crashes, the whole system
working of microkernel. crashes in monolithic kernel.
Code To write a microkernel, more code is To write a monolithic kernel, less code
required. is required.
Example QNX, Symbian, L4Linux, Singularity, Linux, BSDs (FreeBSD, OpenBSD,
K42, Mac OS X, Integrity, PikeOS, NetBSD), Microsoft Windows
HURD, Minix, and Coyotos. (95,98,Me), Solaris, OS-9, AIX, HP-UX,
DOS, OpenVMS, XTS-400 etc.
Modular 35
Divided into different module.
Typically employs:
dynamic loadable kernel module (LKM). i.e. Different
modules communicate through kernel (core part).
LKM may be loaded during boot or when
required, and can be deleted also.
An example would be a device driver support
module loaded when a new device is plugged into
the computer, and when the device is unplugged,
the module is deleted because it is not needed any
more.
Silberschatz, Gagne, Galvin: Operating System Concepts, 6 th Edition
Abstraction 36
OS acts as an intermediary between a user and the hardware
Interface for the user is provided by the OS. This interface is how a
user use the service.
Creates an environment for the user
Abstract Machine
Complex details of the hardware are hidden
APIs
Application development becomes simple
Command Interpreter
Part of a OS that understands and executes commands that are
entered interactively by a human being or from a program
Shell
Abstraction 37
Processor → Thread Abstract Machine
Application
Memory → Address Space Interface
Disks, SSDs, … → Files OS
Networks → Sockets
Physical Machine
Machines → Processes Hardware
Interface
OS as an Illusionist:
Remove software/hardware quirks (fight complexity)
Optimize for convenience, utilization, reliability, … (help the programmer)
For any OS area (e.g. file systems, virtual memory, networking, scheduling):
What hardware interface to handle? (physical reality)
What’s software interface to provide? (nicer abstraction)
38
Abstraction
Application
Shell
Operatin
g System
CPU Memory
Video Card Network
Monitor Disk Printer
Operating Systems Provide Abstraction 39
Providing abstraction via system calls 40
Application
System Calls: fork(), wait(), read(), open(), write(), mkdir(), kill() ...
Operatin
g System
Process
Device Mgmt
Mgmt File Network
ProtectioSystem Comm. Kernel
Security
n
CPU Memory
Video Card Network
Monitor Disk Printer
Why is abstraction important? 41
Without OSs and abstract interfaces, application writers must
program all device access directly
load device command codes into device registers
understand physical characteristics of the devices
Applications suffer!
Very complicated maintenance and upgrading
No portability
Concept of Process 42
Process
Program loaded in memory and in execution.
Program is a passive whereas process is an active entity
Process Management Activities 43
The operating system is responsible for the following activities
in connection with process management:
Initiating and Terminating Processes
To pause and resume processes
Process scheduling
Mechanism for:
Process synchronization, communication and
deadlock handling.
R1 P1 R1 P1
R2 P2 R2 P2
Resource 44
OS acts an interface between hardware and software.
Resources are objects that can be allocated in a computer . Examples:
Processors,
Devices: Both input and output devices,
Memory,
Files
Influence of Security 45
Other Security Issues
Program Threats
Trojans
Trap Door
System Threats
Worms
Viruses
Denial of Services
46
Networking and OS
Multimedia OS 47
Demand on the applications 48
References
49
Silberschatz, Gagne, Galvin: Operating System Concepts, 6th Edition
Remzi H. Arpaci-Dusseau, Andrea C. Arpaci-Dusseau - Operating
Systems_ Three Easy Pieces
Ramez Elmasri, A Carrick, David Levine - Operating Systems_ A
Spiral Approach (2009, McGraw-Hill Science_Engineering_Math)
https://www2.eecs.berkeley.edu/Courses/CS162/
50