Os Unit-1 Introduction
Os Unit-1 Introduction
UNIT-1(INTRODUCTION)
Operating System Concepts – 9th Edition 1.3 Silberschatz, Galvin and Gagne
Introduction
Operating System Concepts – 9th Edition 1.4 Silberschatz, Galvin and Gagne
Why use an OS?
Operating System Concepts – 9th Edition 1.5 Silberschatz, Galvin and Gagne
OS with other Machines
Operating System Concepts – 9th Edition 1.6 Silberschatz, Galvin and Gagne
OS with other Machines
Operating System Concepts – 9th Edition 1.7 Silberschatz, Galvin and Gagne
Objectives
Operating System Concepts – 9th Edition 1.8 Silberschatz, Galvin and Gagne
What is an Operating System?
Operating System Concepts – 9th Edition 1.9 Silberschatz, Galvin and Gagne
Operating System Definition
Operating System Concepts – 9th Edition 1.10 Silberschatz, Galvin and Gagne
Operating System Definition (Cont.)
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
Operating System Concepts – 9th Edition 1.11 Silberschatz, Galvin and Gagne
What Operating System Do?
Operating System Concepts – 9th Edition 1.12 Silberschatz, Galvin and Gagne
What Operating System Do?
Operating System Concepts – 9th Edition 1.13 Silberschatz, Galvin and Gagne
What Operating Systems Do
Operating System Concepts – 9th Edition 1.14 Silberschatz, Galvin and Gagne
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
Operating System Concepts – 9th Edition 1.15 Silberschatz, Galvin and Gagne
Four Components of a Computer System
Operating System Concepts – 9th Edition 1.16 Silberschatz, Galvin and Gagne
Computer System Organization
Computer-system operation
One or more CPUs, device controllers connect
through common bus providing access to shared
memory
Concurrent execution of CPUs and devices
competing for memory cycles
Operating System Concepts – 9th Edition 1.17 Silberschatz, Galvin and Gagne
Computer System Organization
A device controller is in charge of a specific type of
device
System bus provides access to shared memory
Operating System Concepts – 9th Edition 1.18 Silberschatz, Galvin and Gagne
Computer-System Operation
Operating System Concepts – 9th Edition 1.19 Silberschatz, Galvin and Gagne
Operating System as a Resource
Controller
Operating System Concepts – 9th Edition 1.20 Silberschatz, Galvin and Gagne
Computer Startup
Operating System Concepts – 9th Edition 1.21 Silberschatz, Galvin and Gagne
Difference between Program and Process
Operating System Concepts – 9th Edition 1.22 Silberschatz, Galvin and Gagne
Interrupts
Operating System Concepts – 9th Edition 1.23 Silberschatz, Galvin and Gagne
Interrupt Timeline
Operating System Concepts – 9th Edition 1.24 Silberschatz, Galvin and Gagne
Storage Structure
Main memory(RAM) – only large storage media that the CPU
can access directly
Random access
Typically volatile
Secondary storage(HARD DISK) – extension of main memory
that provides large nonvolatile storage capacity
Hard disks is made up of rigid metal or glass platters
covered with magnetic recording material
Disk surface is logically divided into tracks, which are
subdivided into sectors
The disk controller determines the logical interaction between
the device and the computer
Solid-state disks(SSD) – faster than hard disks, nonvolatile
Various technologies
Becoming more popular
Widely used in mobile phones.
Operating System Concepts – 9th Edition 1.25 Silberschatz, Galvin and Gagne
Storage Structure (Non Voilatile)
Magnetic Tape : Sequential Floppy Disk: Sequential
Acess Media Acess Media
Operating System Concepts – 9th Edition 1.26 Silberschatz, Galvin and Gagne
Storage Hierarchy
Operating System Concepts – 9th Edition 1.27 Silberschatz, Galvin and Gagne
Storage-Device Hierarchy
Fastest/
costlier
Speed
increas
Cost es
increase
s
Size/capacity
increases
Operating System Concepts – 9th Edition 1.28 Silberschatz, Galvin and Gagne
Operating System Services
Operating System Concepts – 9th Edition 1.29 Silberschatz, Galvin and Gagne
Operating System Functions
Operating System Concepts – 9th Edition 1.30 Silberschatz, Galvin and Gagne
Classification/Types of Operating System
Operating System Concepts – 9th Edition 1.32 Silberschatz, Galvin and Gagne
Batch Operating System
Operating System Concepts – 9th Edition 1.33 Silberschatz, Galvin and Gagne
Multi Progrmming Operating System
Operating System Concepts – 9th Edition 1.34 Silberschatz, Galvin and Gagne
Multi Progrmming Operating System
Operating System Concepts – 9th Edition 1.35 Silberschatz, Galvin and Gagne
Multi Tasking/ Time Sharing Operating
System
time to each process and in this time the user can also interact
Operating System Concepts – 9th Edition 1.36 Silberschatz, Galvin and Gagne
Multi Tasking/ Time Sharing Operating
System
Operating System Concepts – 9th Edition 1.37 Silberschatz, Galvin and Gagne
Multi User Operating System
A multi-user operating system is an operating system that permits several users to access a single system
running to a single operating system. These systems are frequently quite complex, and they must manage
the tasks that the various users connected to them require. Users will usually sit at terminals or computers
connected to the system via a network and other system machines like printers. A multi-user operating
system varies from a connected single-user operating system in that each user accesses the same
Operating System Concepts – 9th Edition 1.38 Silberschatz, Galvin and Gagne
Types of Multi User Operating System
There are various types of multi-user operating systems. Some of them are as follows:
Distributed System
A distributed system is also known as distributed computing. It is a collection of multiple
components distributed over multiple computers that interact, coordinate, and seem like a
single coherent system to the end-user. With the aid of the network, the end-user would be
able to interact with or operate them.
Time-Sliced Systems
It's a system in which each user's job gets a specific amount of CPU time. In other words,
each work is assigned to a specific time period. These time slices look too small to the user's
eyes. An internal component known as the 'Scheduler' decides to run the next job. This
scheduler determines and executes the job that must perform based on the priority cycle.
Multiprocessor System
Multiple processors are used in this system, which helps to improve overall performance. If
one of the processors in this system fails, the other processor is responsible for completing its
assigned task.
Operating System Concepts – 9th Edition 1.39 Silberschatz, Galvin and Gagne
Difference Between Multi-Programming and Multi
Tasking/ Time Sharing Operating System
Multiprogramming System Time-Sharing System
Multiprogramming operating system allows Time-Sharing is the logical extension of
executing multiple processes by monitoring multiprogramming. In this time-sharing
their process states and switching between Operating system, many users/processes are
processes. allocated with computer resources in
respective time slots.
The processor and memory underutilization The processor's time is shared with multiple
problem is resolved, and multiple programs users. That's why it is called a time-sharing
run on the CPU. That's why it is called operating system.
multiprogramming.
In multiprogramming, the process can be In this process, two or more users can use a
executed by a single processor. processor in their terminal.
Multiprogramming OS has no fixed time slice. Time-sharing OS has a fixed time slice.
In a multiprogramming OS system, before In a time-sharing OS system, executive power
finishing a task, the executive power is not is taken off before finishing execution.
taken off.
Here the system does not take some time to Here the system works for the same or less
work on different processes. time on each process.
In Multiprogramming OS, the system depends In time-sharing, the OS system depends on
on devices to switch between tasks such as time to switch between different processes.
I/O interrupts.
The system model of a multiprogramming A system model of the time-sharing system is
system is multiple programs. multiple programs and multiple users.
Multiprogramming system maximizes The Time-sharing system maximizes response
response time. time.
Example: Mac OS, Window OS, Example: Windows NT server, Unix, Linux,
microcomputers such as MP/M, XENIX, and Multics, TOPS-10, TOPS-20
ESQview
Operating System Concepts – 9th Edition 1.40 Silberschatz, Galvin and Gagne
Real Time Operating System
A real-time operating
system (RTOS) is an OS
that guarantees real-time
applications a certain
capability within a specified
deadline. RTOSes are
designed for critical
systems and for devices like
microcontrollers that are
timing-specific. RTOS
processing time
requirements are measured
in milliseconds.
Operating System Concepts – 9th Edition 1.41 Silberschatz, Galvin and Gagne
Real Time Operating System
Operating System Concepts – 9th Edition 1.42 Silberschatz, Galvin and Gagne
Multi Processor/Multi Processing
Operating System
Operating System Concepts – 9th Edition 1.43 Silberschatz, Galvin and Gagne
Distributed Operating System
A distributed operating system is system software over a collection of independent
software, networked, communicating, and physically separate computational nodes.
They handle jobs which are serviced by multiple CPUs. Each individual node holds a
specific software subset of the global aggregate operating system
Operating System Concepts – 9th Edition 1.44 Silberschatz, Galvin and Gagne
Clustered Operating System
• Clustered operating systems are just the opposite of distributed
operating systems, here all the different machines are connected to
a local network.
• As different machines having their own hardware connected to a
local network it acts as a server or you can say as a
supercomputer.
• The computation power of different machines will be combined,
resulting in a total increase in the power of computation for a
single system.
• So, to manage this environment the operating system used is
known as the Clustered operating system.
Operating System Concepts – 9th Edition 1.45 Silberschatz, Galvin and Gagne
Clsutered Operating System
Operating System Concepts – 9th Edition 1.46 Silberschatz, Galvin and Gagne
Embedded Operating System
An embedded operating system is a specialized operating system (OS) designed
to perform a specific task for a device that is not a computer. The main job of an
embedded OS is to run the code that allows the device to do its job. The
embedded OS also makes the device's hardware accessible to software that is
running on top of the OS.
Operating System Concepts – 9th Edition 1.47 Silberschatz, Galvin and Gagne
Multi Threading Operating System
What is Thread ?
A thread is a sequential flow of tasks within a process. Each thread
has its own program counter, stack, and set of registers. But the
threads of a single process might share the same code and
data/file. Threads are also termed as lightweight processes as
they share common resources.
Operating System Concepts – 9th Edition 1.48 Silberschatz, Galvin and Gagne
Multi Threading Operating System
Operating System Concepts – 9th Edition 1.49 Silberschatz, Galvin and Gagne
Multi Threading Operating System
•Kernel Level Threads − Operating System managed threads acting on kernel, an operating
system core.
Operating System Concepts – 9th Edition 1.50 Silberschatz, Galvin and Gagne
Multi Threading Operating System
User Level Threads: In this case, the thread management kernel is not
aware of the existence of threads. The thread library contains code for
creating and destroying threads, for passing message and data between
threads, for scheduling thread execution and for saving and restoring
thread contexts. The application starts with a single thread.
Operating System Concepts – 9th Edition 1.51 Silberschatz, Galvin and Gagne
Multi Threading Operating System
Kernel Level Threads: In this case, thread management is done by the Kernel.
There is no thread management code in the application area. Kernel threads are
supported directly by the operating system. Any application can be programmed to
be multithreaded.
The Kernel maintains context information for the process as a whole and for
individuals threads within the process. Scheduling by the Kernel is done on a
thread basis. The Kernel performs thread creation, scheduling and management in
Kernel space. Kernel threads are generally slower to create and manage than the
user threads.
Operating System Concepts – 9th Edition 1.52 Silberschatz, Galvin and Gagne
Multi Threading Operating System
Types of Thread
Operating System Concepts – 9th Edition 1.53 Silberschatz, Galvin and Gagne
Multi Threading Operating System
Multi Threading: Multithreading allows many parts of a program to run
simultaneously. These parts are referred to as threads, and they are lightweight
processes that are available within the process. As a result, multithreading
increases CPU utilization through multitasking.
Operating System Concepts – 9th Edition 1.54 Silberschatz, Galvin and Gagne
Multi Threading Operating System
Many to Many Relationship: Multithreading allows many parts of a program to run
simultaneously. In this model, we have multiple user threads multiplex to same or lesser number of
kernel level threads. Number of kernel level threads are specific to the machine, advantage of this
model is if a user thread is blocked we can schedule others user thread to other kernel thread. Thus,
System doesn’t block if a particular thread is blocked.
Operating System Concepts – 9th Edition 1.55 Silberschatz, Galvin and Gagne
Multi Threading Operating System
Many to One Relationship: In this model, we have multiple user threads mapped to one kernel
thread. In this model when a user thread makes a blocking system call entire process blocks. As we
have only one kernel thread and only one user thread can access kernel at a time, so multiple
threads are not able access multiprocessor at the same time. The thread management is done on the
user level so it is more efficient.
Operating System Concepts – 9th Edition 1.56 Silberschatz, Galvin and Gagne
Multi Threading Operating System
One to One Relationship: In this model, one to one relationship between kernel and
user thread. In this model multiple thread can run on multiple processor. Problem with
this model is that creating a user thread requires the corresponding kernel thread.
As each user thread is connected to different kernel , if any user thread makes a
blocking system call, the other user threads won’t be blocked
Operating System Concepts – 9th Edition 1.57 Silberschatz, Galvin and Gagne
Structures of Operating System
1. Simple Structure: Such operating systems do not have well defined structure and are
small, simple and limited systems. The interfaces and levels of functionality are not well
separated. MS-DOS is an example of such operating system. In MS-DOS application
programs are able to access the basic I/O routines. These types of operating system cause
the entire system to crash if one of the user programs fails.
Diagram of the structure of MS-DOS is shown below
Operating System Concepts – 9th Edition 1.58 Silberschatz, Galvin and Gagne
Structures of Operating System
1. Simple Structure:
Operating System Concepts – 9th Edition 1.59 Silberschatz, Galvin and Gagne
Structures of Operating System
2. Mono Lithic Structure:
•Monolithic Kernel is another classification of Kernel.
•It manages system resources between application and hardware, but user
services and kernel services are implemented under the same address space.
•It increases the size of the kernel, thus increasing the size of the operating system as well.
•This kernel provides CPU scheduling, memory management, file management, and other
The entire operating system needs modification if the user adds a new service.
Operating System Concepts – 9th Edition 1.60 Silberschatz, Galvin and Gagne
Structures of Operating System
2. Mono Lithic Structure:
And
system
programs
Hardware
Operating System Concepts – 9th Edition 1.61 Silberschatz, Galvin and Gagne
Structures of Operating System
2. Mono Lithic Structure:
Operating System Concepts – 9th Edition 1.62 Silberschatz, Galvin and Gagne
Structures of Operating System
2. Mono Lithic Structure:
Advantages
•One of the major advantages of having a monolithic kernel is that it provides
CPU scheduling, memory management, file management, and other operating
system functions through system calls.
•The other one is that it is a single large process running entirely in a single
address space.
•It is a single static binary file. Examples of some Monolithic Kernel-based OSs
are Unix, Linux, Open VMS, XTS-400, z/TPF.
Disadvantages
•One of the major disadvantages of a monolithic kernel is that if anyone service
fails it leads to an entire system failure.
•If the user has to add any new service. The user needs to modify the entire
operating system.
Operating System Concepts – 9th Edition 1.63 Silberschatz, Galvin and Gagne
Structures of Operating System
3. Layered Structure:
•To eliminate the diadvatages of simple structure from MS-DOS and mono lithic
structure from UNIX, Layered structure comes into a picture.
•An OS can be broken into pieces and retain much more control on
system.
•In this structure the OS is broken into number of layers (levels).
•The bottom layer (layer 0) is the hardware and the topmost layer
(layer N) is the user interface.
•These layers are so designed that each layer uses the functions of
the lower level layers only.
•This simplifies the debugging process as if lower level layers are
debugged and an error occurs during debugging then the error must be
on that layer only as the lower level layers have already been
debugged.
•The main disadvantage of this structure is that at each layer, the data
needs to be modified and passed on which adds overhead to the
system. Moreover careful planning of the layers is necessary as a layer
can use only lower level layers. UNIX is an example of this structure
Operating System Concepts – 9th Edition 1.64 Silberschatz, Galvin and Gagne
Structures of Operating System
3. Layered Structure:
Operating System Concepts – 9th Edition 1.65 Silberschatz, Galvin and Gagne
Structures of Operating System
3. Layered Structure:
Advantages :
•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 :
•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.
Operating System Concepts – 9th Edition 1.66 Silberschatz, Galvin and Gagne
Structures of Operating System
4. Micro Kernel Structure:
Operating System Concepts – 9th Edition 1.67 Silberschatz, Galvin and Gagne
Structures of Operating System
4. Micro Kernel Structure:
System
programs
Operating System Concepts – 9th Edition 1.68 Silberschatz, Galvin and Gagne
Structures of Operating System
4. Micro Kernel Structure:
Advantages
The advantages of microkernel are as follows −
•This is small and isolated so as better functioning
•These are more secure due to space division
•Can add new features without recompiling
•This architecture is more flexible and can coexist in the system
•Fewer system crashes as compared to monolithic system
Disadvantages
The disadvantages of microkernel are as follows −
•It is expensive as compared to the monolithic system architecture.
•Function calls needed when drivers are implemented as processes.
•Performance of the microkernel system can be indifferent and may sometimes cause problems
Operating System Concepts – 9th Edition 1.69 Silberschatz, Galvin and Gagne
Structures of Operating System
Modular Structure:
Operating System Concepts – 9th Edition 1.70 Silberschatz, Galvin and Gagne
Structures of Operating System
Difference Between Mono Lithic and Micro Kernel Structure:
Terms Monolithic Kernel microkernel
Definition A monolithic kernel is a type of kernel in A microkernel is a kernel type that provides
operating systems where the entire operating low-level address space management, thread
system works in the kernel space. management, and interprocess
communication to implement an operating
system.
Address space In a monolithic kernel, both user services and In microkernel user services and kernel,
kernel services are kept in the same address services are kept in separate address spaces.
space.
Size The monolithic kernel is larger than the The microkernel is smaller in size.
microkernel.
Execution It has fast execution. It has slow execution.
OS services In a monolithic kernel system, the kernel In a microkernel-based system, the OS
contains the OS services. services and kernel are separated.
Extendible The monolithic kernel is quite complicated to The microkernel is easily extendible.
extend.
Security If a service crashes, then the whole system If a service crashed, it does not affect the
crashes in a monolithic kernel. working of the microkernel.
Customization It is difficult to add new functionalities to the It is easier to add new functionalities to the
monolithic kernel. Therefore, it is not microkernel. Therefore, it is more
customizable. customizable.
Code Less coding is required to write a monolithic A microkernel is required more coding.
kernel.
Example Linux, FreeBSD, OpenBSD, NetBSD, QNX, Symbian, L4L.inux, Singularity, K42,
Microsoft Windows (95, 98, Me), Solaries, Mac OS X, Integrity, PikeOS, HURD, Minix,
Operating System Concepts – 9th Edition 1.71 Silberschatz, Galvin and Gagne
Re-entrant Kernel
• As the name suggests, a re-entrant kernel is the one which allows multiple
processes to be executing in the kernel mode at any given point of time and that
too without causing any consistency problems(burden of doing out weight)
among the kernel data structures.
• Well, we know that in a single processor system only one process can execute at
any given instant but there could be other processes blocked in kernel mode
waiting to be executed.
• For example, in a re-entrant kernel a process waiting on a ‘read()’ call may decide
to release CPU to a process which is waiting for execution in kernel mode.
• Now, one might get a question in mind about why a kernel is made re-entrant?
Well, lets start with a example where a kernel is not re-entrant and see what if it
allows multiple processes to execute in kernel mode.
Operating System Concepts – 9th Edition 1.72 Silberschatz, Galvin and Gagne
Re-entrant Kernel
Lets assume that a process is executing in kernel mode and accessing a kernel data structure
and some global values associated with it.
•Suppose the process name is ‘A’.
•Now ‘A’ accesses a global variable to see if the value is non zero (so that it can do some
calculations etc) and just before it tries to use this value in some of its logic, a context switch to
process ‘B’ happens.
•Now this process ‘B’ tries to access the value of the same global variable and decrements it.
•Another context switch happens and process ‘A’ comes back into execution.
•Since ‘A’ does not know that ‘B’ has already decremented the value, it tries to use this value
again.
•So here is the catch, process ‘A’ sees two different values of the global variable as the value was
Operating System Concepts – 9th Edition 1.73 Silberschatz, Galvin and Gagne
Re-entrant Kernel
On a basic note, following points could be considered for making a kernel re-entrant
:
•Write kernel functions that modify only the local (stack) variables and do not alter
the global variables or data structures. Such type of functions are also known as re-
entrant functions.
•Strictly adhering to the use of only re-entrant functions in a kernel is not a feasible
Operating System Concepts – 9th Edition 1.74 Silberschatz, Galvin and Gagne
System Call
A system call is a mechanism that provides the interface between a process and the
operating system. It is a programmatic method in which a computer program requests a
service from the kernel of the OS.
System call offers the services of the operating system to the user programs via API
(Application Programming Interface). System calls are the only entry points for the kernel
system.
Operating System Concepts – 9th Edition 1.75 Silberschatz, Galvin and Gagne
System Call
Operating System Concepts – 9th Edition 1.76 Silberschatz, Galvin and Gagne
System Call
Operating System Concepts – 9th Edition 1.77 Silberschatz, Galvin and Gagne
System Call
Operating System Concepts – 9th Edition 1.78 Silberschatz, Galvin and Gagne
System Call
Operating System Concepts – 9th Edition 1.79 Silberschatz, Galvin and Gagne