2. Types of Operating Systems.
â˘Batch Operating System
â˘Time-Sharing Operating Systems
â˘Distributed Operating System
â˘Network Operating System
â˘Real-Time Operating System
3. Functions of Operating Systems
⢠An Operating System acts as a communication bridge (interface) between the
user and computer hardware. The purpose of an operating system is to provide a
platform on which a user can execute programs in a convenient and efficient
manner.
⢠An operating system is a piece of software that manages the allocation of
computer hardware. The coordination of the hardware must be appropriate to
ensure the correct working of the computer system and to prevent user programs
from interfering with the proper working of the system.
Example: Just like a boss gives orders to his employee, in a similar way we request
or pass our orders to the Operating System. The main goal of the Operating
System is to thus make the computer environment more convenient to use and
the secondary goal is to use the resources in the most efficient manner.
4. Types of Operating Systems.
⢠An operating system is a program on which application
programs are executed and acts as a communication bridge
(interface) between the user and the computer hardware.
⢠The main task an operating system carries out is the allocation
of resources and services, such as the allocation of memory,
devices, processors, and information. The operating system
also includes programs to manage these resources, such as a
traffic controller, a scheduler, memory management module, I/O
programs, and a file system.
5. Important functions of an operating System
1.Security â
The operating system uses password protection to protect user
data and similar other techniques. it also prevents unauthorized
access to programs and user data.
2.Control over system performance â
Monitors overall system health to help improve performance.
records the response time between service requests and
system response to having a complete view of the system
health. This can help improve performance by providing
important information needed to troubleshoot problems.
6. Important functions of an operating System
3-Job accounting
Operating system Keeps track of time and resources used by various
tasks and users, this information can be used to track resource usage
for a particular user or group of users.
4-Error detecting aids
The operating system constantly monitors the system to detect errors
and avoid the malfunctioning of a computer system.
5-Coordination between other software and users
Operating systems also coordinate and assign interpreters, compilers,
assemblers, and other software to the various users of the computer
systems.
7. Important functions of an operating System
6-Memory Management
The operating system manages the Primary Memory or Main Memory.
Main memory is made up of a large array of bytes or words where
each byte or word is assigned a certain address. Main memory is fast
storage and it can be accessed directly by the CPU. For a program to
be executed, it should be first loaded in the main memory. An
Operating System performs the following activities for memory
management: It keeps track of primary memory, i.e., which bytes of
memory are used by which user program. The memory addresses that
have already been allocated and the memory addresses of the
memory that has not yet been used. In multiprogramming, the OS
decides the order in which processes are granted access to memory,
and for how long. It Allocates the memory to a process when the
process requests it and deallocates the memory when the process has
terminated or is performing an I/O operation
8. Important functions of an operating System
7-Processor Management
In a multi-programming environment, the OS decides the order in
which processes have access to the processor, and how much
processing time each process has. This function of OS is called
process scheduling. An Operating System performs the following
activities for processor management. Keeps track of the status of
processes. The program which performs this task is known as a
traffic controller. Allocates the CPU that is a processor to a
process. De-allocates processor when a process is no more
required.
9. Important functions of an operating System
8-Device Management
An OS manages device communication via their respective drivers. It
performs the following activities for device management. Keeps track of all
devices connected to the system. designates a program responsible for
every device known as the Input/Output controller. Decides which process
gets access to a certain device and for how long. Allocates devices in an
effective and efficient way. Deallocates devices when they are no longer
required.
9-File Management
A file system is organized into directories for efficient or easy navigation and
usage. These directories may contain other directories and other files. An
Operating System carries out the following file management activities. It
keeps track of where information is stored, user access settings and status
of every file, and more⌠These facilities are collectively known as the file
system.
10. Important functions of an operating System
⢠Moreover, Operating System also provides certain services to the computer
system in one form or the other.
The Operating System provides certain services to the users which can be listed
in the following manner
1.Program Execution: The Operating System is responsible for the execution of
all types of programs whether it be user programs or system programs. The
Operating System utilizes various resources available for the efficient running of
all types of functionalities.
2.Handling Input/Output Operations: The Operating System is responsible for
handling all sorts of inputs, i.e, from the keyboard, mouse, desktop, etc. The
Operating System does all interfacing in the most appropriate manner regarding
all kinds of Inputs and Outputs.
For example, there is a difference in the nature of all types of peripheral devices
such as mice or keyboards, the Operating System is responsible for handling
data between them.
3.Manipulation of File System: The Operating System is responsible for making
decisions regarding the storage of all types of data or files, i.e, floppy disk/hard
disk/pen drive, etc. The Operating System decides how the data should be
manipulated and stored.
11. Important functions of an operating System
4.Error Detection and Handling: The Operating System is responsible for
the detection of any type of error or bugs that can occur while any task. The
well-secured OS sometimes also acts as a countermeasure for preventing
any sort of breach to the Computer System from any external source and
probably handling them.
5.Resource Allocation: The Operating System ensures the proper use of
all the resources available by deciding which resource to be used by whom
for how much time. All the decisions are taken by the Operating System.
6.Accounting: The Operating System tracks an account of all the
functionalities taking place in the computer system at a time. All the details
such as the types of errors that occurred are recorded by the Operating
System.
7.Information and Resource Protection: The Operating System is
responsible for using all the information and resources available on the
machine in the most protected way. The Operating System must foil an
attempt from any external resource to hamper any sort of data or
information.
12. State diagram and their process
We are going to discuss about process, process state diagram and process control block
(PCB).A process is a program which is currently in execution. A program by itself is not a
process but it is a passive entity just like content of a file stored on disk, while a process is
an active entity .A process also includes the process stack, which contains temporary data
(such as local variables, function parameters, return address), and a data section, which
contains global variables and a heap-memory allocated to a process to run and
process state that defines its current state. A process changes its state during its execution.
Each process may be in one of the following states:
1.New: when a new process is being created.
2.Running: A process is said to be in running state when instructions are being executed.
3.Waiting: The process is waiting for some event to occur (such as an I/O operation).
4.Ready: The process is waiting for processor.
5.Terminated: The process has finished execution.
14. Process Control Block (PCB):
⢠Operating system maintains one special data structure called Process Control Block (PCB).
⢠All the information about each process is stored in the process control block (PCB) which is maintained by
operating system. It contains following information associated with a specific process.
⢠Process state: It represents current status of the process. It may be new, ready, running or waiting.
⢠Program counter: It indicates the address of the next instruction to be executed for this process.
⢠CPU Registers: They include index registers, stack pointer and general purpose registers. It is used to save
process state when an interrupt occurs, so that it can resume from that state.
⢠CPU-scheduling information: it includes process priority, pointer to scheduling queue.
⢠Memory management information: value of the base and limit registers, page tables depending on the
memory system.
⢠Accounting information: it contains an amount of CPU and real time used, time limits process number and
so on.
⢠I/O status information: It includes a list of I/O devices allocated to the process, a list of open files and so on.
⢠Normally, operating system stores PCBs of processes into the ready queue for the process scheduling instead
of the process itself .
15. Banker Algorithms
⢠It is a banker algorithm used to avoid deadlock and allocate
resources safely to each process in the computer system. The
'S-State' examines all possible tests or activities before
deciding whether the allocation should be allowed to each
process. It also helps the operating system to successfully
share the resources between all the processes. The banker's
algorithm is named because it checks whether a person should
be sanctioned a loan amount or not to help the bank system
safely simulate allocation resources. In this section, we will
learn the Banker's Algorithm in detail. Also, we will solve
problems based on the Banker's Algorithm. To understand the
Banker's Algorithm first we will see a real word example of it.
16. Banker Algorithms
⢠Suppose the number of account holders in a particular bank is 'n', and the
total money in a bank is 'T'. If an account holder applies for a loan; first, the
bank subtracts the loan amount from full cash and then estimates the cash
difference is greater than T to approve the loan amount. These steps are
taken because if another person applies for a loan or withdraws some
amount from the bank, it helps the bank manage and operate all things
without any restriction in the functionality of the banking system.
⢠Similarly, it works in an operating system. When a new process is created
in a computer system, the process must provide all types of information to
the operating system like upcoming processes, requests for their
resources, counting them, and delays. Based on these criteria, the
operating system decides which process sequence should be executed or
waited so that no deadlock occurs in a system. Therefore, it is also known
as deadlock avoidance algorithm or deadlock detection in the operating
system.
17. Banker Algorithms
⢠When working with a banker's algorithm, it requests to know
about three things:
1.How much each process can request for each resource in the
system. It is denoted by the [MAX] request.
2.How much each process is currently holding each resource in a
system. It is denoted by the [ALLOCATED] resource.
3.It represents the number of each resource currently available in
the system. It is denoted by the [AVAILABLE] resource.
18. Banker Algorithms
⢠Suppose n is the number of processes, and m is the number of each type of resource
used in a computer system.
1.Available: It is an array of length 'm' that defines each type of resource available in the
system. When Available[j] = K, means that 'K' instances of Resources type R[j] are
available in the system.
2.Max: It is a [n x m] matrix that indicates each process P[i] can store the maximum number
of resources R[j] (each type) in a system.
3.Allocation: It is a matrix of m x n orders that indicates the type of resources currently
allocated to each process in the system. When Allocation [i, j] = K, it means that process
P[i] is currently allocated K instances of Resources type R[j] in the system.
4.Need: It is an M x N matrix sequence representing the number of remaining resources for
each process. When the Need[i] [j] = k, then process P[i] may require K more instances of
resources type Rj to complete the assigned work.
Nedd[i][j] = Max[i][j] - Allocation[i][j].
5.Finish: It is the vector of the order m. It includes a Boolean value (true/false) indicating
whether the process has been allocated to the requested resources, and all resources
have been released after finishing its task.
19. Pre-emptive Scheduling Algorithms
Preemptive scheduling is used when a process switches from running
state to ready state or from the waiting state to ready state. The
resources (mainly CPU cycles) are allocated to the process for a
limited amount of time and then taken away, and the process is again
placed back in the ready queue if that process still has CPU burst time
remaining. That process stays in the ready queue till it gets its next
chance to execute.
Algorithms based on preemptive scheduling are:
⢠Round Robin (RR)
⢠Shortest Remaining Time First (SRTF)
⢠Priority (preemptive version)
21. Non-Preemptive Scheduling:
⢠Non-preemptive Scheduling is used when a
process terminates, or a process switches from
running to the waiting state. In this scheduling, once
the resources (CPU cycles) are allocated to a
process, the process holds the CPU till it gets
terminated or reaches a waiting state. In the case of
non-preemptive scheduling does not interrupt a
process running CPU in the middle of the
execution. Instead, it waits till the process
completes its CPU burst time, and then it can
allocate the CPU to another process.
22. Difference Between Pre-emptive and Non-Preemptive
Scheduling
1.In preemptive scheduling, the CPU is allocated to the processes for
a limited time whereas, in Non-preemptive scheduling, the CPU is
allocated to the process till it terminates or switches to the waiting
state.
2.The executing process in preemptive scheduling is interrupted in the
middle of execution when higher priority one comes whereas, the
executing process in non-preemptive scheduling is not interrupted in
the middle of execution and waits till its execution.
3.In Preemptive Scheduling, there is the overhead of switching the
process from the ready state to running state, vise-verse and
maintaining the ready queue. Whereas in the case of non-
preemptive scheduling has no overhead of switching the process
from running state to ready state.
23. Difference Between Pre-emptive and Non-Preemptive
Scheduling
4.In preemptive scheduling, if a high-priority process frequently arrives
in the ready queue then the process with low priority has to wait for a
long, and it may have to starve. , in the non-preemptive scheduling, if
CPU is allocated to the process having a larger burst time then the
processes with small burst time may have to starve.
5.Preemptive scheduling attains flexibility by allowing the critical
processes to access the CPU as they arrive into the ready queue, no
matter what process is executing currently. Non-preemptive
scheduling is called rigid as even if a critical process enters the ready
queue the process running CPU is not disturbed.
6.Preemptive Scheduling has to maintain the integrity of shared data
thatâs why it is cost associative which is not the case with Non-
preemptive Scheduling.
24. Comparison Chart
Parameter PREEMPTIVE SCHEDULING NON-PREEMPTIVE SCHEDULING
Basic
In this resources(CPU Cycle) are allocated to a process for a
limited time.
Once resources(CPU Cycle) are allocated to a process, the
process holds it till it completes its burst time or switches to
waiting state.
Interrupt Process can be interrupted in between.
Process can not be interrupted until it terminates itself or
its time is up.
Starvation
If a process having high priority frequently arrives in the
ready queue, a low priority process may starve.
If a process with a long burst time is running CPU, then later
coming process with less CPU burst time may starve.
Overhead It has overheads of scheduling the processes. It does not have overheads.
Flexibility flexible rigid
Cost cost associated no cost associated
CPU Utilization In preemptive scheduling, CPU utilization is high. It is low in non preemptive scheduling.
Examples
Examples of preemptive scheduling are Round Robin and
Shortest Remaining Time First.
Examples of non-preemptive scheduling are First Come First
Serve and Shortest Job First.
25. Dead Lock
⢠Deadlock is a situation where two or more processes are waiting for
each other. For example, let us assume, we have two processes P1
and P2. Now, process P1 is holding the resource R1 and is waiting for
the resource R2. At the same time, the process P2 is having the
resource R2 and is waiting for the resource R1. So, the process P1 is
waiting for process P2 to release its resource and at the same time,
the process P2 is waiting for process P1 to release its resource. And
no one is releasing any resource. So, both are waiting for each other
to release the resource. This leads to infinite waiting and no work is
done here. This is called Deadlock.
27. Necessary Conditions of Deadlock
⢠There are four different conditions that result in Deadlock. These
four conditions are also known as Coffman conditions and these
conditions are not mutually exclusive. Let's look at them one by one.
⢠Mutual Exclusion: A resource can be held by only one process at a
time. In other words, if a process P1 is using some resource R at a
particular instant of time, then some other process P2 can't hold or
use the same resource R at that particular instant of time. The process
P2 can make a request for that resource R but it can't use that
resource simultaneously with process P1.
28. Necessary Conditions of Deadlock
Mutual Exclusion: A resource can be held by only one process at a time. In other words, if a process P1 is using
some resource R at a particular instant of time, then some other process P2 can't hold or use the same resource R
at that particular instant of time. The process P2 can make a request for that resource R but it can't use that
resource simultaneously with process P1
29. Necessary Conditions of Deadlock
⢠Hold and Wait: A process can hold a number of resources at a time
and at the same time, it can request for other resources that are being
held by some other process. For example, a process P1 can hold two
resources R1 and R2 and at the same time, it can request some
resource R3 that is currently held by process P2.
30. Necessary Conditions of Deadlock
⢠No preemption: A resource can't be preempted from the process by another
process, forcefully. For example, if a process P1 is using some resource R,
then some other process P2 can't forcefully take that resource. If it is so,
then what's the need for various scheduling algorithm. The process P2 can
request for the resource R and can wait for that resource to be freed by the
process P1.
⢠Circular Wait: Circular wait is a condition when the first process is
waiting for the resource held by the second process, the second process is
waiting for the resource held by the third process, and so on. At last, the
last process is waiting for the resource held by the first process. So, every
process is waiting for each other to release the resource and no one is
releasing their own resource. Everyone is waiting here for getting the
resource. This is called a circular wait.
31. The Shortest Remaining First Algorithm.
⢠Shortest Remaining Time First is a scheduling algorithm used in
Operating Systems, which can also be called as the preemptive
version of the SJF scheduling algorithm. The process which has the
least processing time remaining is executed first. As it is a preemptive
type of schedule, it is claimed to be better than SJF scheduling
Algorithm.
⢠Let's understand this with the help of an example. Suppose we
have the following 3 processes with process ID's P1, P2,
and P3 and they arrive into the CPU in the following manner:
32. The Shortest Remaining First Algorithm.
Explanation:
â˘At the 0th unit of the CPU, we have only process P1, so it gets executed for the 1-time unit.
â˘At the 1st unit of the CPU, the Process P2 also arrives. Now, the P1 needs 7 more units more to be executed,
and P2 needs only 2 units. So, P2 is executed by preempting P1.
â˘P2 gets completed at time unit 3, and unit now no new process has arrived. So, after the completion of P2,
again P1 is sent for execution.
â˘Now, P1 has been executed for one unit only, and we have an arrival of new process P3 at time unit 4. Now,
the P1 needs 6-time units more and P3 needs only 3-time units. So, P3 is executed by preempting P1.
â˘P1 gets completed at time unit 7, and after that, we have the arrival of no other process. So again, P1 is sent for
execution, and it gets completed at 13th unit.
34. Compare SRTF , Pre-emptive priority and
Round Robin Algorithms
SRTF Pre-emptive priority Round Robin Algorithms
Shortest Remaining Time
First is a scheduling algorithm
used in Operating Systems,
which can also be called as the
preemptive version of the SJF
scheduling algorithm. The
process which has the least
processing time remaining is
executed first. As it is a
preemptive type of schedule, it
is claimed to be better than SJF
scheduling Algorithm
In Preemptive Priority
Scheduling, at the time of
arrival of a process in the ready
queue, its Priority is compared
with the priority of the other
processes present in the ready
queue as well as with the one
which is being executed by the
CPU at that point of time.
Round-robin (RR) is one of the
algorithms employed by
process and network
schedulers in computing. As
the term is generally used, time
slices (also known as time
quanta) are assigned to each
process in equal portions and in
circular order, handling all
processes without priority (also
known as cyclic executive).
35. Comparison Pre-emptive and Non-Preemptive type
of Priority Algorithm.
Pre-emptive Priority Algorithm Non-Preemptive Priority Algorithm
In preemptive priority scheduling
algorithm, every time a process with
higher priority arrives in the waiting
queue, the CPU cycle is shifted to the
process with the highest priority. This is
preemptive because a process that's
already being executed can be stopped
to execute a process with higher priority.
Priority scheduling is a non-preemptive
algorithm and one of the most common
scheduling algorithms in batch systems.
Each process is assigned first arrival time
(less arrival time process first) if two
processes have same arrival time, then
compare to priorities (highest process
first)
36.
37. Multithreading
⢠Multithreading is a function of the CPU that permits multiple threads
to run independently while sharing the same process resources. A
thread is a conscience sequence of instructions that may run in the
same parent process as other threads.
⢠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. In
multithreading, a computer may execute and process multiple tasks
simultaneously.
⢠Multithreading needs a detailed understanding of these two terms:
process and thread. A process is a running program, and a process
can also be subdivided into independent units called threads.
38. Benefits of Multithreading
Learn about the benefits of multithreading in the operating
system. But before discussing the benefits of multithreading, you
must know about multithreading.
ď§ Responsiveness
ď§ Resource Sharing
ď§ Economy
ď§ Scalability
ď§ Better Communication
40. Protection and Security in Operating systems.
⢠Protection and security requires that computer resources such as CPU, softwares, memory etc. are protected. This
extends to the operating system as well as the data in the system. This can be done by ensuring integrity, confidentiality
and availability in the operating system. The system must be protect against unauthorized access, viruses, worms etc.
⢠Threats to Protection and Security
⢠A threat is a program that is malicious in nature and leads to harmful effects for the system. Some of the common
threats that occur in a system are â
⢠Virus
⢠Viruses are generally small snippets of code embedded in a system. They are very dangerous and can corrupt files,
destroy data, crash systems etc. They can also spread further by replicating themselves as required.
⢠Trojan Horse
⢠A trojan horse can secretly access the login details of a system. Then a malicious user can use these to enter the
system as a harmless being and wreak havoc.
⢠Trap Door
⢠A trap door is a security breach that may be present in a system without the knowledge of the users. It can be exploited
to harm the data or files in a system by malicious people.
⢠Worm
⢠A worm can destroy a system by using its resources to extreme levels. It can generate multiple copies which claim all
the resources and don't allow any other processes to access them. A worm can shut down a whole network in this way.
41. Protection and Security in Operating systems
⢠Denial of Service
⢠These type of attacks do not allow the legitimate users to access a system. It overwhelms
the system with requests so it is overwhelmed and cannot work properly for other user.
⢠Protection and Security Methods
⢠The different methods that may provide protect and security for different computer
systems are â
⢠Authentication
⢠This deals with identifying each user in the system and making sure they are who they
claim to be. The operating system makes sure that all the users are authenticated before
they access the system. The different ways to make sure that the users are authentic are:
⢠Username/ PasswordEach user has a distinct username and password combination and
they need to enter it correctly before they can access the system.
42. Protection and Security in Operating systems
⢠User Key/ User Card:The users need to punch a card into the card slot or use they
individual key on a keypad to access the system.
⢠User Attribute Identification:Different user attribute identifications that can be used are
fingerprint, eye retina etc. These are unique for each user and are compared with the
existing samples in the database. The user can only access the system if there is a
match.
⢠One Time Password
These passwords provide a lot of security for authentication purposes. A one time password
can be generated exclusively for a login every time a user wants to enter the system. It
cannot be used more than once. The various ways a one time password can be
implemented are â
⢠Random Numbers:The system can ask for numbers that correspond to alphabets that
are pre arranged. This combination can be changed each time a login is required.
⢠Secret Key:A hardware device can create a secret key related to the user id for login.
This key can change each time.