0% found this document useful (0 votes)
16 views

Operating System Concepts (2)

TYBCS operating system notes

Uploaded by

devyanibotre2004
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Operating System Concepts (2)

TYBCS operating system notes

Uploaded by

devyanibotre2004
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 64

1.

Overview

1.1. Overview of operating systems

An operating system acts as an intermediary between the user of a computer and


computer hardware. The purpose of an operating system is to provide an environment
in which a user can execute programs in a convenient and efficient manner.

An operating system is a software that manages the computer hardware. The hardware
must provide appropriate mechanisms to ensure the correct operation of the computer
system and to prevent user programs from interfering with the proper operation of the
system.

1.2 Functionalities and Characteristics of OS

Operating system performs three functions:

1. Convenience: An OS makes a computer more convenient to use.


2. Efficiency: An OS allows the computer system resources to be used in an efficient
manner.
3. Ability to Evolve: An OS should be constructed in such a way as to permit the
effective development, testing and introduction of new system functions at the same
time without interfering with service.

Operating system has the following characteristics:

1. Provides the facilities to create, modification of programs and data files using an
editor.
2. Access to the compiler for translating the user program from high level language to
machine language.
3. Provide a loader program to move the compiled program code to the computer’s
memory for execution.
4. Provide routines that handle the details of I/O programming.

1.3 Hardware concepts related to OS


Every general-purpose computer consists of the hardware, operating system, system
programs, and application programs. The hardware consists of memory, CPU, ALU, and I/O
devices, peripheral device, and storage device. System program consists of compilers,
loaders, editors, OS, etc. The application program consists of business programs, database
programs.

Figure 1.1 Conceptual view of a computer

Every computer must have an operating system to run other programs. The operating system
coordinates the use of the hardware among the various system programs and application
programs for various users. It simply provides an environment within which other programs
can do useful work.

The operating system is a set of special programs that run on a computer system that allows it
to work properly. It performs basic tasks such as recognizing input from the keyboard,
keeping track of files and directories on the disk, sending output to the display screen and
controlling peripheral devices.
OS is designed to serve two basic purposes:

1. It controls the allocation and use of the computing System’s resources among the
various user and tasks.
2. It provides an interface between the computer hardware and the programmer that
simplifies and makes feasible for coding, creation, debugging of application
programs.

1.4 CPU states

A process is a program in execution and it is more than a program code called as text section
and this concept works under all the operating system because all the task perform by the
operating system needs a process to perform the task
The process executes when it changes the state. The state of a process is defined by the
current activity of the process.
Each process may be in any one of the following states −
 New − The process is being created.
 Running − In this state the instructions are being executed.
 Waiting − The process is in waiting state until an event occurs like I/O
operation completion or receiving a signal.
 Ready − The process is waiting to be assigned to a processor.
 Terminated − the process has finished execution.
It is important to know that only one process can be running on any processor at any instant.
Many processes may be ready and waiting.
Now let us see the state diagram of these process states −

Explanation
Step 1 − Whenever a new process is created, it is admitted into ready state.
Step 2 − If no other process is present at running state, it is dispatched to running based on
scheduler dispatcher.
Step 3 − If any higher priority process is ready, the uncompleted process will be sent to the
waiting state from the running state.
Step 4 − Whenever I/O or event is completed the process will send back to ready state based
on the interrupt signal given by the running state.
Step 5 − Whenever the execution of a process is completed in running state, it will exit to
terminate state, which is the completion of process.
1.5 I/O channels
I/O Channel is an extension of the DMA concept. It has ability to execute I/O instructions
using special-purpose processor on I/O channel and complete control over I/O operations.
Processor does not execute I/O instructions itself. Processor initiates I/O transfer by
instructing the I/O channel to execute a program in memory.
Program specifies – Device or devices, Area or areas of memory, Priority, and Error
condition actions
Types of I/O Channels:

1. Selector Channel:
Selector channel controls multiple high-speed devices. It is dedicated to the transfer
of data with one of the devices. In selector channel, each device is handled by a
controller or I/O module. It controls the I/O controllers shown in the figure.

2. Multiplexer Channel
Multiplexer channel is a DMA controller that can handle multiple devices at the same
time. It can do block transfers for several devices at once.
1.6 Memory Management

Memory is the important part of the computer that is used to store the data. Its
management is critical to the computer system because the amount of main memory
available in a computer system is very limited. At any time, many processes are
competing for it. Moreover, to increase performance, several processes are executed
simultaneously. For this, we must keep several processes in the main memory, so it is
even more important to manage them effectively.

1.6.1 Memory Management Techniques

The memory management techniques can be classified into following main categories:

o Contiguous memory management schemes


o Non-Contiguous memory management schemes

Classification of memory management schemes

1.6.2 Contiguous memory management schemes:

In a Contiguous memory management scheme, each program occupies a single contiguous


block of storage locations, i.e., a set of memory locations with consecutive addresses.

Single contiguous memory management schemes:

The Single contiguous memory management scheme is the simplest memory management
scheme used in the earliest generation of computer systems. In this scheme, the main memory
is divided into two contiguous areas or partitions. The operating systems reside permanently
in one partition, generally at the lower memory, and the user process is loaded into the other
partition.

Advantages of Single contiguous memory management schemes:


o Simple to implement.
o Easy to manage and design.
o In a Single contiguous memory management scheme, once a process is loaded, it is
given full processor's time, and no other processor will interrupt it.

Disadvantages of Single contiguous memory management schemes:

o Wastage of memory space due to unused memory as the process is unlikely to use all
the available memory space.
o The CPU remains idle, waiting for the disk to load the binary image into the main
memory.
o It can not be executed if the program is too large to fit the entire available main
memory space.
o It does not support multiprogramming, i.e., it cannot handle multiple programs
simultaneously.

Non-Contiguous memory management schemes:

In a Non-Contiguous memory management scheme, the program is divided into different


blocks and loaded at different portions of the memory that need not necessarily be adjacent to
one another. This scheme can be classified depending upon the size of blocks and whether the
blocks reside in the main memory or not.

1.6.3 Logical & Physical Memory, conversion of logical to physical memory


Logical Address is generated by CPU while a program is running. The logical address is
virtual address as it does not exist physically, therefore, it is also known as Virtual Address.
This address is used as a reference to access the physical memory location by CPU. The
term Logical Address Space is used for the set of all logical addresses generated by a
program’s perspective.
The hardware device called Memory-Management Unit is used for mapping logical address
to its corresponding physical address.

Physical Address identifies a physical location of required data in a memory. The user
never directly deals with the physical address but can access by its corresponding logical
address. The user program generates the logical address and thinks that the program is
running in this logical address but the program needs physical memory for its execution,
therefore, the logical address must be mapped to the physical address by MMU before they
are used. The term Physical Address Space is used for all physical addresses corresponding
to the logical addresses in a Logical address space.
Logical to Physical address conversion

1.7 Paging

In Operating Systems, Paging is a storage mechanism used to retrieve processes from the
secondary storage into the main memory in the form of pages.

The main idea behind the paging is to divide each process in the form of pages. The main
memory will also be divided in the form of frames.

One page of the process is to be stored in one of the frames of the memory. The pages can be
stored at the different locations of the memory but the priority is always to find the
contiguous frames or holes.

Pages of the process are brought into the main memory only when they are required
otherwise, they reside in the secondary storage.

Paging Example
1.7.1 Demand Paging
Every process in the virtual memory contains lots of pages and in some cases, it might not be
efficient to swap all the pages for the process at once. Because it might be possible that the
program may need only a certain page for the application to run. Let us take an example here,
suppose there is a 500 MB application and it may need as little as 100MB pages to be
swapped, so in this case, there is no need to swap all pages at once.

The demand paging system is somehow similar to the paging system with swapping where
processes mainly reside in the main memory(usually in the hard disk). Thus demand paging
is the process that solves the above problem only by swapping the pages on Demand. This is
also known as lazy swapper( It never swaps the page into the memory unless it is needed).

Swapper that deals with the individual pages of a process are referred to as Pager.

Demand Paging is a technique in which a page is usually brought into the main memory only
when it is needed or demanded by the CPU. Initially, only those pages are loaded that are
required by the process immediately. Those pages that are never accessed are thus never
loaded into the physical memory.

Figure: Transfer of a Paged Memory to the contiguous disk space.

1.7.2 Page Replacement Concept

Page replacement is needed in the operating systems that use virtual memory using Demand
Paging. As we know that in Demand paging, only a set of pages of a process is loaded into
the memory. This is done so that we can have more processes in the memory at the same
time.

When a page that is residing in virtual memory is requested by a process for its execution, the
Operating System needs to decide which page will be replaced by this requested page. This
process is known as page replacement and is a vital component in virtual memory
management.

To understand why we need page replacement algorithms, we first need to know about page
faults. Let’s see what is a page fault.

Page Fault: A Page Fault occurs when a program running in CPU tries to access a page that
is in the address space of that program, but the requested page is currently not loaded into the
main physical memory, the RAM of the system.

Since the actual RAM is much less than the virtual memory the page faults occur. So
whenever a page fault occurs, the Operating system has to replace an existing page
in RAM with the newly requested page. In this scenario, page replacement algorithms help
the Operating System in deciding which page to replace. The primary objective of all the
page replacement algorithms is to minimize the number of page faults.

1.8 Segmentation - Segment with paging

Major Limitation of Single Level Paging


A big challenge with single level paging is that if the logical address space is large, then the
page table may take up a lot of space in main memory. For instance, consider that logical
address is 32 bit and each page is 4 KB, the number of pages will be 2^20 pages. The page
table without additional bits will be of the size 20 bits * 2 20 or 2.5 MB. Since each process
has its own page table, a lot of memory will be consumed when single level paging is used.
For a system with 64-bit logical address even a page table of single process will not fit in
main memory. For a process with a large logical address space, a lot of its page table
entries are invalid as a lot of the logical address space goes unused.
Page table with invalid entries

Segmented Paging
A solution to the problem is to use segmentation along with paging to reduce the size of
page table. Traditionally, a program is divided into four segments, namely code segment,
data segment, stack segment and heap segment.

Segments of a process

The size of the page table can be reduced by creating a page table for each segment. To
accomplish this hardware support is required. The address provided by CPU will now be
partitioned into segment no., page no. and offset.

1.9 Virtual Memory Concept


Virtual Memory is a storage allocation scheme in which secondary memory can be
addressed as though it were part of the main memory. The addresses a program may use to
reference memory are distinguished from the addresses the memory system uses to identify
physical storage sites, and program-generated addresses are translated automatically to the
corresponding machine addresses.
The size of virtual storage is limited by the addressing scheme of the computer system and
the amount of secondary memory is available not by the actual number of the main storage
locations.
It is a technique that is implemented using both hardware and software. It maps memory
addresses used by a program, called virtual addresses, into physical addresses in computer
memory.
1. All memory references within a process are logical addresses that are
dynamically translated into physical addresses at run time. This means that a
process can be swapped in and out of the main memory such that it occupies
different places in the main memory at different times during the course of
execution.
2. A process may be broken into a number of pieces and these pieces need not be
continuously located in the main memory during execution. The combination of
dynamic run-time address translation and use of page or segment table permits
this.
If these characteristics are present then, it is not necessary that all the pages or segments are
present in the main memory during execution. This means that the required pages need to
be loaded into memory whenever required. Virtual memory is implemented using Demand
Paging or Demand Segmentation.
1.10 Thrashing
At any given time, only a few pages of any process are in the main memory and therefore
more processes can be maintained in memory. Furthermore, time is saved because unused
pages are not swapped in and out of memory. However, the OS must be clever about how it
manages this scheme. In the steady-state practically, all of the main memory will be
occupied with process pages, so that the processor and OS have direct access to as many
processes as possible. Thus when the OS brings one page in, it must throw another out. If it
throws out a page just before it is used, then it will just have to get that page again almost
immediately. Too much of this leads to a condition called Thrashing. The system spends
most of its time swapping pages rather than executing instructions. So a good page
replacement algorithm is required.
In the given diagram, the initial degree of multiprogramming up to some extent of
point(lambda), the CPU utilization is very high and the system resources are utilized 100%.
But if we further increase the degree of multiprogramming the CPU utilization will
drastically fall down and the system will spend more time only on the page replacement and
the time is taken to complete the execution of the process will increase. This situation in the
system is called thrashing.
Causes of Thrashing :
1. High degree of multiprogramming : If the number of processes keeps on
increasing in the memory then the number of frames allocated to each process
will be decreased. So, fewer frames will be available for each process. Due to
this, a page fault will occur more frequently and more CPU time will be wasted
in just swapping in and out of pages and the utilization will keep on decreasing.
For example:
Let free frames = 400
Case 1: Number of process = 100
Then, each process will get 4 frames.
Case 2: Number of processes = 400
Each process will get 1 frame.
Case 2 is a condition of thrashing, as the number of processes is increased,
frames per process are decreased. Hence CPU time will be consumed in just
swapping pages.

2. Lacks of Frames: If a process has fewer frames then fewer pages of that process
will be able to reside in memory and hence more frequent swapping in and out
will be required. This may lead to thrashing. Hence sufficient amount of frames
must be allocated to each process in order to prevent thrashing.
Recovery of Thrashing:
 Do not allow the system to go into thrashing by instructing the long-term
scheduler not to bring the processes into memory after the threshold.
 If the system is already thrashing then instruct the mid-term scheduler to
suspend some of the processes so that we can recover the system from thrashing.
2 Process Management and Synchronization
2.1 PCB
While creating a process the operating system performs several operations. To identify the
processes, it assigns a process identification number (PID) to each process. As the
operating system supports multi-programming, it needs to keep track of all the processes.
For this task, the process control block (PCB) is used to track the process’s execution
status. Each block of memory contains information about the process state, program
counter, stack pointer, status of opened files, scheduling algorithms, etc. All these
information is required and must be saved when the process is switched from one state to
another. When the process makes a transition from one state to another, the operating
system must update information in the process’s PCB.
A process control block (PCB) contains information about the process, i.e. registers,
quantum, priority, etc. The process table is an array of PCB’s, that means logically contains
a PCB for all of the current processes in the system.

Process Control Block


The process scheduling is the activity of the process manager that
handles the removal of the running process from the CPU and the
selection of another process on the basis of a particular strategy.
Process scheduling is an essential part of a Multiprogramming
operating systems. Such operating systems allow more than one
process to be loaded into the executable memory at a time and the
loaded process shares the CPU using time multiplexing.
There are three types of process scheduler.

1. Long Term or job scheduler :


It brings the new process to the ‘Ready State’. It controls Degree
of Multi-programming, i.e., number of process present in ready
state at any point of time. It is important that the long-term
scheduler make a careful selection of both I/O and CPU-bound
processes. I/O bound tasks are which use much of their time in
input and output operations while CPU bound processes are which
spend their time on CPU. The job scheduler increases efficiency
by maintaining a balance between the two.

2. Short term or CPU scheduler :


It is responsible for selecting one process from ready state for
scheduling it on the running state. Note: Short-term scheduler
only selects the process to schedule it doesn’t load the process
on running. Here is when all the scheduling algorithms are used.
The CPU scheduler is responsible for ensuring there is no
starvation owing to high burst time processes.
Dispatcher is responsible for loading the process selected by
Short-term scheduler on the CPU (Ready to Running State)
Context switching is done by dispatcher only. A dispatcher does
the following:
1. Switching context.
2. Switching to user mode.
3. Jumping to the proper location in the newly loaded program.
3. Medium-term scheduler :
It is responsible for suspending and resuming the process. It
mainly does swapping (moving processes from main memory to
disk and vice versa). Swapping may be necessary to improve the
process mix or because a change in memory requirements has
overcommitted available memory, requiring memory to be freed
up. It is helpful in maintaining a perfect balance between the I/O
bound and the CPU bound. It reduces the degree of
multiprogramming.

2.3 Scheduling Concept


In computing, a process is the instance of a computer program that is
being executed by one or many threads. It contains the program code and
its activity. Depending on the operating system (OS), a process may be
made up of multiple threads of execution that execute instructions
concurrently.
How is process memory used for efficient operation?
The process memory is divided into four sections for efficient operation:
 The text category is composed of integrated program code, which is
read from fixed storage when the program is launched.
 The data class is made up of global and static variables, distributed and
executed before the main action.
 Heap is used for flexible, or dynamic memory allocation and is managed
by calls to new, delete, malloc, free, etc.
 The stack is used for local variables. The space in the stack is reserved
for local variables when it is announced.
To know further, you can refer to our detailed article on States of a Process
in Operating system.
What is Process Scheduling?
Process Scheduling is the process of the process manager handling the
removal of an active process from the CPU and selecting another process
based on a specific strategy.
Process Scheduling is an integral part of Multi-programming applications.
Such operating systems allow more than one process to be loaded into
usable memory at a time and the loaded shared CPU process uses repetition
time.
There are three types of process schedulers:
 Long term or Job Scheduler
 Short term or CPU Scheduler
 Medium-term Scheduler
Why do we need to schedule processes?
 Scheduling is important in many different computer environments. One of
the most important areas is scheduling which programs will work on the
CPU. This task is handled by the Operating System (OS) of the computer
and there are many different ways in which we can choose to configure
programs.
 Process Scheduling allows the OS to allocate CPU time for each
process. Another important reason to use a process scheduling system is
that it keeps the CPU busy at all times. This allows you to get less
response time for programs.
 Considering that there may be hundreds of programs that need to work,
the OS must launch the program, stop it, switch to another program, etc.
The way the OS configures the system to run another in the CPU is called
“context switching”. If the OS keeps context-switching programs in and
out of the provided CPUs, it can give the user a tricky idea that he or she
can run any programs he or she wants to run, all at once.
 So now that we know we can run 1 program at a given CPU, and we
know we can change the operating system and remove another one using
the context switch, how do we choose which programs we need. run, and
with what program?
 That’s where scheduling comes in! First, you determine the metrics,
saying something like “the amount of time until the end”. We will define
this metric as “the time interval between which a function enters the
system until it is completed”. Second, you decide on a metrics that
reduces metrics. We want our tasks to end as soon as possible.
What is the need for CPU scheduling algorithm?
CPU scheduling is the process of deciding which process will own the CPU
to use while another process is suspended. The main function of the CPU
scheduling is to ensure that whenever the CPU remains idle, the OS has at
least selected one of the processes available in the ready-to-use line.
In Multiprogramming, if the long-term scheduler selects multiple I / O binding
processes then most of the time, the CPU remains an idle. The function of an
effective program is to improve resource utilization.
If most operating systems change their status from performance to waiting
then there may always be a chance of failure in the system. So in order to
minimize this excess, the OS needs to schedule tasks in order to make full
use of the CPU and avoid the possibility of deadlock.
Objectives of Process Scheduling Algorithm:
 Utilization of CPU at maximum level. Keep CPU as busy as possible.
 Allocation of CPU should be fair.
 Throughput should be Maximum. i.e. Number of processes that
complete their execution per time unit should be maximized.
 Minimum turnaround time, i.e. time taken by a process to finish
execution should be the least.
 There should be a minimum waiting time and the process should not
starve in the ready queue.
 Minimum response time. It means that the time when a process
produces the first response should be as less as possible.
What are the different terminologies to take care of in any CPU Scheduling
algorithm?
 Arrival Time: Time at which the process arrives in the ready queue.
 Completion Time: Time at which process completes its execution.
 Burst Time: Time required by a process for CPU execution.
 Turn Around Time: Time Difference between completion time and arrival
time.
Turn Around Time = Completion Time – Arrival Time
 Waiting Time(W.T): Time Difference between turn around time and burst
time.
Waiting Time = Turn Around Time – Burst Time
Things to take care while designing a CPU Scheduling algorithm?
Different CPU Scheduling algorithms have different structures and the
choice of a particular algorithm depends on a variety of factors. Many
conditions have been raised to compare CPU scheduling algorithms.
The criteria include the following:
 CPU utilization: The main purpose of any CPU algorithm is to keep the
CPU as busy as possible. Theoretically, CPU usage can range from 0 to
100 but in a real-time system, it varies from 40 to 90 percent depending
on the system load.
 Throughput: The average CPU performance is the number of processes
performed and completed during each unit. This is called throughput. The
output may vary depending on the length or duration of the processes.
 Turn round Time: For a particular process, the important conditions are
how long it takes to perform that process. The time elapsed from the time
of process delivery to the time of completion is known as the conversion
time. Conversion time is the amount of time spent waiting for memory
access, waiting in line, using CPU, and waiting for I / O.
 Waiting Time: The Scheduling algorithm does not affect the time
required to complete the process once it has started performing. It only
affects the waiting time of the process i.e. the time spent in the waiting
process in the ready queue.
 Response Time: In a collaborative system, turn around time is not the
best option. The process may produce something early and continue to
computing the new results while the previous results are released to the
user. Therefore another method is the time taken in the submission of the
application process until the first response is issued. This measure is
called response time.
What are the different types of CPU Scheduling Algorithms?
There are mainly two types of scheduling methods:
 Preemptive Scheduling : Preemptive scheduling is used when a process
switches from running state to ready state or from the waiting state to the
ready state.
 Non-Preemptive Scheduling : Non-Preemptive scheduling is used when a
process terminates , or when a process switches from running state to
waiting state.

Different types of CPU Scheduling Algorithms

Let us now learn about these CPU scheduling algorithms in operating


systems one by one:
1. First Come First Serve:
FCFS considered to be the simplest of all operating system scheduling algorithms. First come
first serve scheduling algorithm states that the process that requests the CPU first is allocated
the CPU first and is implemented by using FIFO queue.
Characteristics of FCFS:
 FCFS supports non-preemptive and preemptive CPU scheduling algorithms.
 Tasks are always executed on a First-come, First-serve concept.
 FCFS is easy to implement and use.
 This algorithm is not much efficient in performance, and the wait time is quite high.
Advantages of FCFS:
 Easy to implement
 First come, first serve method
Disadvantages of FCFS:
 FCFS suffers from Convoy effect.
 The average waiting time is much higher than the other algorithms.
 FCFS is very simple and easy to implement and hence not much efficient.
To learn about how to implement this CPU scheduling algorithm, please refer to our detailed
article on First come, First serve Scheduling.
2. Shortest Job First(SJF):
Shortest job first (SJF) is a scheduling process that selects the waiting process with the
smallest execution time to execute next. This scheduling method may or may not be
preemptive. Significantly reduces the average waiting time for other processes waiting to be
executed. The full form of SJF is Shortest Job First.

Characteristics of SJF:
 Shortest Job first has the advantage of having a minimum average waiting time among
all operating system scheduling algorithms.
 It is associated with each task as a unit of time to complete.
 It may cause starvation if shorter processes keep coming. This problem can be solved
using the concept of ageing.
Advantages of Shortest Job first:
 As SJF reduces the average waiting time thus, it is better than the first come first serve
scheduling algorithm.
 SJF is generally used for long term scheduling
Disadvantages of SJF:
 One of the demerit SJF has is starvation.
 Many times it becomes complicated to predict the length of the upcoming CPU request
To learn about how to implement this CPU scheduling algorithm, please refer to our detailed
article on Shortest Job First.
3. Longest Job First(LJF):
Longest Job First(LJF) scheduling process is just opposite of shortest job first (SJF), as the
name suggests this algorithm is based upon the fact that the process with the largest burst
time is processed first. Longest Job First is non-preemptive in nature.
Characteristics of LJF:
 Among all the processes waiting in a waiting queue, CPU is always assigned to the
process having largest burst time.
 If two processes have the same burst time then the tie is broken using FCFS i.e. the
process that arrived first is processed first.
 LJF CPU Scheduling can be of both preemptive and non-preemptive types.
Advantages of LJF:
 No other task can schedule until the longest job or process executes completely.
 All the jobs or processes finish at the same time approximately.
Disadvantages of LJF:
 Generally, the LJF algorithm gives a very high average waiting time and average turn-
around time for a given set of processes.
 This may lead to convoy effect.
To learn about how to implement this CPU scheduling algorithm, please refer to our detailed
article on the Longest job first scheduling.
4. Priority Scheduling:
Preemptive Priority CPU Scheduling Algorithm is a pre-emptive method of CPU
scheduling algorithm that works based on the priority of a process. In this algorithm, the
editor sets the functions to be as important, meaning that the most important process must be
done first. In the case of any conflict, that is, where there are more than one processor with
equal value, then the most important CPU planning algorithm works on the basis of the FCFS
(First Come First Serve) algorithm.
Characteristics of Priority Scheduling:
 Schedules tasks based on priority.
 When the higher priority work arrives while a task with less priority is executed, the
higher priority work takes the place of the less priority one and
 The latter is suspended until the execution is complete.
 Lower is the number assigned, higher is the priority level of a process.
Advantages of Priority Scheduling:
 The average waiting time is less than FCFS
 Less complex
Disadvantages of Priority Scheduling:
 One of the most common demerits of the Preemptive priority CPU scheduling algorithm
is the Starvation Problem. This is the problem in which a process has to wait for a longer
amount of time to get scheduled into the CPU. This condition is called the starvation
problem.
To learn about how to implement this CPU scheduling algorithm, please refer to our detailed
article on Priority Preemptive Scheduling algorithm.
5. Round robin:
Round Robin is a CPU scheduling algorithm where each process is cyclically assigned a
fixed time slot. It is the preemptive version of First come First Serve CPU Scheduling
algorithm. Round Robin CPU Algorithm generally focuses on Time Sharing technique.
Characteristics of Round robin:
 It’s simple, easy to use, and starvation-free as all processes get the balanced CPU
allocation.
 One of the most widely used methods in CPU scheduling as a core.
 It is considered preemptive as the processes are given to the CPU for a very limited time.
Advantages of Round robin:
 Round robin seems to be fair as every process gets an equal share of CPU.
 The newly created process is added to the end of the ready queue.
To learn about how to implement this CPU scheduling algorithm, please refer to our detailed
article on the Round robin Scheduling algorithm.

6. Shortest Remaining Time First:


Shortest remaining time first is the preemptive version of the Shortest job first which we
have discussed earlier where the processor is allocated to the job closest to completion. In
SRTF the process with the smallest amount of time remaining until completion is selected to
execute.
Characteristics of Shortest remaining time first:
 SRTF algorithm makes the processing of the jobs faster than SJF algorithm, given it’s
overhead charges are not counted.
 The context switch is done a lot more times in SRTF than in SJF and consumes the
CPU’s valuable time for processing. This adds up to its processing time and diminishes
its advantage of fast processing.
Advantages of SRTF:
 In SRTF the short processes are handled very fast.
 The system also requires very little overhead since it only makes a decision when a
process completes or a new process is added.
Disadvantages of SRTF:
 Like the shortest job first, it also has the potential for process starvation.
 Long processes may be held off indefinitely if short processes are continually added.
To learn about how to implement this CPU scheduling algorithm, please refer to our detailed
article on the shortest remaining time first.
7. Longest Remaining Time First:
The longest remaining time first is a preemptive version of the longest job first scheduling
algorithm. This scheduling algorithm is used by the operating system to program incoming
processes for use in a systematic way. This algorithm schedules those processes first which
have the longest processing time remaining for completion.
Characteristics of longest remaining time first:
 Among all the processes waiting in a waiting queue, the CPU is always assigned to the
process having the largest burst time.
 If two processes have the same burst time then the tie is broken using FCFS i.e. the
process that arrived first is processed first.
 LJF CPU Scheduling can be of both preemptive and non-preemptive types.
Advantages of LRTF:
 No other process can execute until the longest task executes completely.
 All the jobs or processes finish at the same time approximately.
Disadvantages of LRTF:
 This algorithm gives a very high average waiting time and average turn-around time for a
given set of processes.
 This may lead to a convoy effect.
To learn about how to implement this CPU scheduling algorithm, please refer to our detailed
article on the longest remaining time first.
8. Highest Response Ratio Next:
Highest Response Ratio Next is a non-preemptive CPU Scheduling algorithm and it is
considered as one of the most optimal scheduling algorithms. The name itself states that we
need to find the response ratio of all available processes and select the one with the highest
Response Ratio. A process once selected will run till completion.
Characteristics of Highest Response Ratio Next:
 The criteria for HRRN is Response Ratio, and the mode is Non-Preemptive.
 HRRN is considered as the modification of Shortest Job First to reduce the problem
of starvation.
 In comparison with SJF, during the HRRN scheduling algorithm, the CPU is allotted to
the next process which has the highest response ratio and not to the process having less
burst time.
Response Ratio = (W + S)/S
Here, W is the waiting time of the process so far and S is the Burst time of the process.
Advantages of HRRN:
 HRRN Scheduling algorithm generally gives better performance than the shortest job
first Scheduling.
 There is a reduction in waiting time for longer jobs and also it encourages shorter jobs.
Disadvantages of HRRN:
 The implementation of HRRN scheduling is not possible as it is not possible to know the
burst time of every job in advance.
 In this scheduling, there may occur an overload on the CPU.
To learn about how to implement this CPU scheduling algorithm, please refer to our detailed
article on Highest Response Ratio Next.
9. Multiple Queue Scheduling:
Processes in the ready queue can be divided into different classes where each class has its
own scheduling needs. For example, a common division is a foreground
(interactive) process and a background (batch) process. These two classes have different
scheduling needs. For this kind of situation Multilevel Queue Scheduling is used.

The description of the processes in the above diagram is as follows:


 System Processes: The CPU itself has its process to run, generally termed as System
Process.
 Interactive Processes: An Interactive Process is a type of process in which there should
be the same type of interaction.
 Batch Processes: Batch processing is generally a technique in the Operating system that
collects the programs and data together in the form of a batch before
the processing starts.
Advantages of multilevel queue scheduling:
 The main merit of the multilevel queue is that it has a low scheduling overhead.
Disadvantages of multilevel queue scheduling:
 Starvation problem
 It is inflexible in nature
To learn about how to implement this CPU scheduling algorithm, please refer to our detailed
article on Multilevel Queue Scheduling.
10. Multilevel Feedback Queue Scheduling::
Multilevel Feedback Queue Scheduling (MLFQ) CPU Scheduling is like Multilevel
Queue Scheduling but in this process can move between the queues. And thus, much more
efficient than multilevel queue scheduling.
Characteristics of Multilevel Feedback Queue Scheduling:
 In a multilevel queue-scheduling algorithm, processes are permanently assigned to a
queue on entry to the system, and processes are not allowed to move between queues.
 As the processes are permanently assigned to the queue, this setup has the advantage of
low scheduling overhead,
 But on the other hand disadvantage of being inflexible.
Advantages of Multilevel feedback queue scheduling:
 It is more flexible
 It allows different processes to move between different queues
Disadvantages of Multilevel feedback queue scheduling:
 It also produces CPU overheads
 It is the most complex algorithm.
To learn about how to implement this CPU scheduling algorithm, please refer to our detailed
article on Multilevel Feedback Queue Scheduling.
Comparison between various CPU Scheduling algorithms
Here is a brief comparison between different CPU scheduling algorithms:

Average
waiting
Allocatio Complexi time Preempti Starvatio Performan
Algorithm n is ty (AWT) on n ce

Accordin
g to the
arrival
time of
the
processes Simple
, the CPU and easy Slow
is to performan
FCFS allocated. implement Large. No No ce

Based on
the
lowest
CPU Minimum
burst More Smaller Average
time complex than Waiting
SJF (BT). than FCFS FCFS No Yes Time

Dependin
g on
some
Based on measures
the e.g.,
highest arrival
CPU More time, Big turn-
burst complex process around
LJFS time (BT) than FCFS size, etc. No Yes time

LRTF Same as More Dependi Yes Yes The


Average
waiting
Allocatio Complexi time Preempti Starvatio Performan
Algorithm n is ty (AWT) on n ce

LJFS the
allocation
of the
CPU is
based on
the
highest ng on
CPU some
burst measures
time e.g.,
(BT). But arrival preference
it is time, is given to
preempti complex process the longer
ve than FCFS size, etc. jobs

Same as
SJF the
allocation
of the
CPU is
based on
the Dependin
lowest g on
CPU some
burst measures
time e.g., The
(BT). But arrival preference
it is More time, is given to
preempti complex process the short
SRTF ve. than FCFS size, etc Yes Yes jobs

RR Accordin The Large as Yes No Each


g to the complexit compare process
order of y depends d to SJF has given
the on Time and a fairly
process Quantum Priority fixed time
arrives size schedulin
with
Average
waiting
Allocatio Complexi time Preempti Starvatio Performan
Algorithm n is ty (AWT) on n ce

fixed
time
quantum
(TQ) g.

Accordin
g to the
priority.
The
Well
bigger performan
priority ce but
task This type Smaller contain a
Priority Pre- executes is less than starvation
emptive first complex FCFS Yes Yes problem

Accordin
g to the
priority
with This type
monitorin is less
g the new complex Preempti
incoming than ve Most
higher Priority Smaller beneficial
Priority non- priority preemptiv than with batch
preemptive jobs e FCFS No Yes systems

Accordin
g to the
process
that More
Good
resides in complex performan
the than the ce but
bigger priority Smaller contain a
queue scheduling than starvation
MLQ priority algorithms FCFS No Yes problem
Average
waiting
Allocatio Complexi time Preempti Starvatio Performan
Algorithm n is ty (AWT) on n ce

It is the
most
Accordin Complex
g to the but its Smaller
process complexit than all
of a y rate schedulin
bigger depends g types in Good
priority on the TQ many performan
MFLQ queue. size cases No No ce

2.4 Process hierarchies


In some systems, when a process creates another process, the parent process and child
process continue to be associated in certain ways. The child process can itself create
more processes, forming a process hierarchy. Note that unlike plants and animals that
use sexual reproduction, a process has only one parent (but zero, one, two, or more
children). So a process is more like a hydra than like, say, a cow.

In UNIX, a process and all of its children and further descendants together form a
process group. When a user sends a signal from the keyboard, the signal is delivered
to all members of the process group currently associated with the keyboard (usually
all active processes that were created in the current window). Individually, each
process can catch the signal, ignore the signal, or take the default action, which is to
be killed by the signal.

As another example of where the process hierarchy plays a key role, let us look at
how UNIX initializes itself when it is started, just after the computer is booted. A
special process, called init, is present in the boot image. When it starts running, it
reads a file telling how many terminals there are. Then it forks off a new process per
terminal. These processes wait for someone to log in. If a login is successful, the
login process executes a shell to accept commands. These commands may start up
more processes, and so forth. Thus, all the processes in the whole system belong to a
single tree, with init at the root.
In contrast, Windows has no concept of a process hierarchy. Al processes are equal.
The only hint of a process hierarchy is that when a process is created, the parent is
given a special token (called a handle) that it can use to control the child. However, it
is free to pass this token to some other process, thus invalidating the
hierarchy.Processes in UNIX cannot disinherit their children.
2.5 Problems of concurrent processes
Concurrency is the execution of the multiple instruction sequences at the same time. It
happens in the operating system when there are several process threads running in parallel.
The running process threads always communicate with each other through shared memory
or message passing. Concurrency results in sharing of resources result in problems like
deadlocks and resources starvation.
It helps in techniques like coordinating execution of processes, memory allocation and
execution scheduling for maximizing throughput.
Principles of Concurrency :
Both interleaved and overlapped processes can be viewed as examples of concurrent
processes, they both present the same problems.
The relative speed of execution cannot be predicted. It depends on the following:
 The activities of other processes
 The way operating system handles interrupts
 The scheduling policies of the operating system
Problems in Concurrency :
 Sharing global resources –
Sharing of global resources safely is difficult. If two processes both make use of a
global variable and both perform read and write on that variable, then the order in
which various read and write are executed is critical.
 Optimal allocation of resources –
It is difficult for the operating system to manage the allocation of resources optimally.
 Locating programming errors –
It is very difficult to locate a programming error because reports are usually not
reproducible.
 Locking the channel –
It may be inefficient for the operating system to simply lock the channel and prevents
its use by other processes.
Advantages of Concurrency :
 Running of multiple applications –
It enable to run multiple applications at the same time.
 Better resource utilization –
It enables that the resources that are unused by one application can be used for other
applications.
 Better average response time –
Without concurrency, each application has to be run to completion before the next one
can be run.
 Better performance –
It enables the better performance by the operating system. When one application uses
only the processor and another application uses only the disk drive then the time to run
both applications concurrently to completion will be shorter than the time to run each
application consecutively.
Drawbacks of Concurrency :
 It is required to protect multiple applications from one another.
 It is required to coordinate multiple applications through additional mechanisms.
 Additional performance overheads and complexities in operating systems are required
for switching among applications.
 Sometimes running too many applications concurrently leads to severely degraded
performance.
Issues of Concurrency :
 Non-atomic –
Operations that are non-atomic but interruptible by multiple processes can cause
problems.
 Race conditions –
A race condition occurs of the outcome depends on which of several processes gets to a
point first.
 Blocking –
Processes can block waiting for resources. A process could be blocked for long period
of time waiting for input from a terminal. If the process is required to periodically
update some data, this would be very undesirable.
 Starvation –
It occurs when a process does not obtain service to progress.
 Deadlock –
It occurs when two processes are blocked and hence neither can proceed to execute.

2.6 Critical sections


The critical section need to must enforce all three rules:

 Mutual Exclusion: Mutual Exclusion is a special type of binary semaphore which is


used for controlling access to the shared resource. It includes a priority inheritance
mechanism to avoid extended priority inversion problems. Not more than one process
can execute in its critical section at one time.
 Progress: This solution is used when no one is in the critical section, and someone
wants in. Then those processes not in their reminder section should decide who should
go in, in a finite time.
 Bound Waiting: When a process makes a request for getting into critical section,
there is a specific limit about number of processes can get into their critical section.
So, when the limit is reached, the system must allow request to the process to get into
its critical section.

2.6 Mutual exclusion

Mutual exclusion is a basic synchronization primitive used to ensure thread safety when
accessing shared variables. The mutual exclusion programming interfaces available in the
five programming environments are reviewed, underlining the common basic features and
the different additional features proposed by each one of them. Then, atomic operations
are introduced as an efficient alternative to mutual exclusion in some specific cases, and
the way they operate in OpenMP is reviewed. Finally, some utilities proposed by
Threading Building Blocks (TBB)—basically, extensions of the Standard Template
Library containers having internally built in thread safety—are introduced.

Mutual exclusion locks are a commonly used mechanism for synchronizing processes or
threads that need access to some shared resource in parallel programs. They work as their
name suggests: if a thread “locks” a resource, another thread that wishes to access it will
need to wait till the first thread unlocks it. Once that happens, the second one would then
proceed to lock it till it is processing it. The program’s threads must be disciplined to unlock
it as soon as they are done using the shared resource to keep the program execution flowing
smoothly.
2.7 Synchronization

Processes Synchronization or Synchronization is the way by which processes that


share the same memory space are managed in an operating system. It helps maintain
the consistency of data by using variables or hardware so that only one process can
make changes to the shared memory at a time. There are various solutions for the
same such as semaphores, mutex locks, synchronization hardware, etc.

An operating system is a software that manages all applications on a device and


basically helps in the smooth functioning of our computer. Because of this reason, the
operating system has to perform many tasks, and sometimes simultaneously. This isn't
usually a problem unless these simultaneously occurring processes use a common
resource.

For example, consider a bank that stores the account balance of each customer in the
same database. Now suppose you initially have x rupees in your account. Now, you
take out some amount of money from your bank account, and at the same time,
someone tries to look at the amount of money stored in your account. As you are
taking out some money from your account, after the transaction, the total balance left
will be lower than x. But, the transaction takes time, and hence the person reads x as
your account balance which leads to inconsistent data. If in some way, we could make
sure that only one process occurs at a time, we could ensure consistent data.

Let us take a look at why exactly we need Process Synchronization. For example, If
a process1 is trying to read the data present in a memory location while
another process2 is trying to change the data present at the same location, there is a
high chance that the data read by the process1 will be incorrect.

How Process Synchronization Works


Let us look at different elements/sections of a program:

 Entry Section: The entry Section decides the entry of a process.


 Critical Section: Critical section allows and makes sure that only one process is
modifying the shared data.
 Exit Section: The entry of other processes in the shared data after the execution of
one process is handled by the Exit section.
 Remainder Section: The remaining part of the code which is not categorized as
above is contained in the Remainder section.

2.8 Deadlock
A process in operating system uses resources in the following way.
1. Requests a resource
2. Use the resource
3. Releases the resource
Deadlock is a situation where a set of processes are blocked
because each process is holding a resource and waiting for another
resource acquired by some other process.
Consider an example when two trains are coming toward each other
on the same track and there is only one track, none of the trains can
move once they are in front of each other. A similar situation occurs
in operating systems when there are two or more processes that
hold some resources and wait for resources held by other(s). For
example, in the below diagram, Process 1 is holding Resource 1 and
waiting for resource 2 which is acquired by process 2, and process 2
is waiting for resource 1.

Deadlock can arise if the following four conditions hold


simultaneously (Necessary Conditions)
Mutual Exclusion: Two or more resources are non-shareable (Only
one process can use at a time)
Hold and Wait: A process is holding at least one resource and
waiting for resources.
No Preemption: A resource cannot be taken from a process unless
the process releases the resource.
Circular Wait: A set of processes are waiting for each other in
circular form.

Methods for handling deadlock

There are three ways to handle deadlock


1) Deadlock prevention or avoidance:
Prevention:
The idea is to not let the system into a deadlock state. This system
will make sure that above mentioned four conditions will not arise.
These techniques are very costly so we use this in cases where our
priority is making a system deadlock-free.
One can zoom into each category individually, Prevention is done by
negating one of above mentioned necessary conditions for deadlock.
Prevention can be done in four different ways:
1. Eliminate mutual exclusion 3. Allow
preemption
2. Solve hold and Wait 4. Circular
wait Solution
Avoidance:
Avoidance is kind of futuristic. By using the strategy of “Avoidance”,
we have to make an assumption. We need to ensure that all
information about resources that the process will need is known to
us before the execution of the process. We use Banker’s algorithm
(Which is in turn a gift from Dijkstra) to avoid deadlock.
In prevention and avoidance, we get correctness of data but
performance decreases.
2) Deadlock detection and recovery: If Deadlock prevention or
avoidance is not applied to the software then we can handle this by
deadlock detection and recovery. which consist of two phases:
1. In the first phase, we examine the state of the process and check
whether there is a deadlock or not in the system.
2. If found deadlock in the first phase then we apply the algorithm
for recovery of the deadlock.
In Deadlock detection and recovery, we get the correctness of data
but performance decreases.
3) Deadlock ignorance: If a deadlock is very rare, then let it happen and reboot the
system. This is the approach that both Windows and UNIX take. we use the ostrich
algorithm for deadlock ignorance.
In Deadlock, ignorance performance is better than the above two methods but the

4) Bankers Algorithm
Let us consider the following snapshot for understanding the banker's algorithm:

Processes Allocation A B C Max A B C Available A B C

P0 112 433 210

P1 212 322

P2 401 902

P3 020 753

P4 112 112

1. calculate the content of the need matrix?


2. Check if the system is in a safe state?
3. Determine the total sum of each type of resource?

Solution:

1. The Content of the need matrix can be calculated by using the formula given below:

Need = Max – Allocation

2. Let us now check for the safe state.

Safe sequence:

1. For process P0, Need = (3, 2, 1) and

Available = (2, 1, 0)
Need <=Available = False

So, the system will move to the next process.

2. For Process P1, Need = (1, 1, 0)

Available = (2, 1, 0)

Need <= Available = True

Request of P1 is granted.

Available = Available +Allocation

= (2, 1, 0) + (2, 1, 2)

= (4, 2, 2) (New Available)

3. For Process P2, Need = (5, 0, 1)

Available = (4, 2, 2)

Need <=Available = False

So, the system will move to the next process.

4. For Process P3, Need = (7, 3, 3)

Available = (4, 2, 2)

Need <=Available = False

So, the system will move to the next process.

5. For Process P4, Need = (0, 0, 0)

Available = (4, 2, 2)

Need <= Available = True

Request of P4 is granted.

Available = Available + Allocation

= (4, 2, 2) + (1, 1, 2)

= (5, 3, 4) now, (New Available)

6. Now again check for Process P2, Need = (5, 0, 1)


Available = (5, 3, 4)

Need <= Available = True

Request of P2 is granted.

Available = Available + Allocation

= (5, 3, 4) + (4, 0, 1)

= (9, 3, 5) now, (New Available)

7. Now again check for Process P3, Need = (7, 3, 3)

Available = (9, 3, 5)

Need <=Available = True

The request for P3 is granted.

Available = Available +Allocation

= (9, 3, 5) + (0, 2, 0) = (9, 5, 5)

8. Now again check for Process P0, = Need (3, 2, 1)

= Available (9, 5, 5)

Need <= Available = True

So, the request will be granted to P0.

Safe sequence: < P1, P4, P2, P3, P0>

The system allocates all the needed resources to each process. So, we can say that the
system is in a safe state.

3. The total amount of resources will be calculated by the following formula:

The total amount of resources= sum of columns of allocation + Available

= [8 5 7] + [2 1 0] = [10 6 7]

2.10 . Device and File Management

Device management in an operating system means controlling the Input/Output devices like
disk, microphone, keyboard, printer, magnetic tape, USB ports, camcorder, scanner, other
accessories, and supporting units like supporting units control channels. A process may
require various resources, including main memory, file access, and access to disk drives, and
others. If resources are available, they could be allocated, and control returned to the CPU.
Otherwise, the procedure would have to be postponed until adequate resources become
available. The system has multiple devices, and in order to handle these physical or virtual
devices, the operating system requires a separate program known as an ad device controller.
It also determines whether the requested device is available.

2.10.1. The fundamentals of I/O devices may be divided into three categories:

1. Boot Device
2. Character Device
3. Network Device

Boot Device

It stores data in fixed-size blocks, each with its unique address. For example- Disks.

Character Device

It transmits or accepts a stream of characters, none of which can be addressed individually.


For instance, keyboards, printers, etc.

Network Device

It is used for transmitting the data packets.

Functions of the device management in the operating system

The operating system (OS) handles communication with the devices via their drivers. The OS
component gives a uniform interface for accessing devices with various physical features.
There are various functions of device management in the operating system. Some of them are
as follows:

1. It keeps track of data, status, location, uses, etc. The file system is a term used to
define a group of facilities.
2. It enforces the pre-determined policies and decides which process receives the device
when and for how long.
3. It improves the performance of specific devices.
4. It monitors the status of every device, including printers, storage drivers, and other
devices.
5. It allocates and effectively deallocates the device. De-allocating differentiates the
devices at two levels: first, when an I/O command is issued and temporarily freed.
Second, when the job is completed, and the device is permanently release
2.10.2. Types of devices

There are three types of Operating system peripheral devices: dedicated, shared, and virtual.
These are as follows:

1. Dedicated Device

In device management, some devices are allocated or assigned to only one task at a time until
that job releases them. Devices such as plotters, printers, tape drivers, and other similar
devices necessitate such an allocation mechanism because it will be inconvenient if multiple
people share them simultaneously. The disadvantage of such devices is the inefficiency
caused by allocating the device to a single user for the whole duration of task execution, even
if the device is not used 100% of the time.

2. Shared Devices

These devices could be assigned to a variety of processes. By interleaving their requests,


disk-DASD could be shared by multiple processes simultaneously. The Device Manager
carefully controls the interleaving, and pre-determined policies must resolve all difficulties.

3. Virtual Devices

Virtual devices are a hybrid of the two devices, and they are dedicated devices that have been
transformed into shared devices. For example, a printer can be transformed into a shareable
device by using a spooling program that redirects all print requests to a disk. A print job is
not sent directly to the printer; however, it is routed to the disk until it is fully prepared with
all of the required sequences and formatting, at which point it is transmitted to the printers.
The approach can transform a single printer into numerous virtual printers, improving
performance and ease of use.

Features of Device Management

Here, you will learn the features of device management in the operating system. Various
features of the device management are as follows:

1. The OS interacts with the device controllers via the device drivers while allocating the
device to the multiple processes executing on the system.
2. Device drivers can also be thought of as system software programs that bridge
processes and device controllers.
3. The device management function's other key job is to implement the API.
4. Device drivers are software programs that allow an operating system to control the
operation of numerous devices effectively.
5. The device controller used in device management operations mainly contains three
registers: command, status, and data.
2.10.3 File Systems

File attributes are configuration and information related to files. These attributes grant/deny
requests of a user/process for access, modifying, relocating, or deleting it. Some common
examples of file attributes are:

 Read-only: Allows a file to be only read.


 Read-Write: Allows a file to be read and written to.
 Hidden: File is made invisible during non-privileged regular operations.
 Execute: Allows a file to be executed like a program. Other than these there are
several attributes. Many of them are platform-specific.

File Access Mechanisms in OS

Following are the 3 types of file accessing mechanisms in an operating system:

1. Direct

This method represents a file's disk model. Just like a disk, direct access mechanism allows
random access to any file block. A file is divided into a number of blocks. These blocks are
of the same size. The file is viewed as an ordered sequence of these blocks. Thus the OS can
do a read-write operation upon any random block. Following are the three operations under
direct mechanism:

1. Read x: read contents of block x


2. Write x: write to block x
3. Goto x: jump to block x

2. Sequential Access

This is a simple way to access the information in a file. Contents of a file are accessed
sequentially (one record after another). This method is used by editors and compilers. Tape
drives use a sequential method, processing a memory block at a time. They were a form of
the storage medium in computers used in earlier times. Following are the 3 operations in
sequential access:

1. Read next: read the next portion of the file.


2. Write next: add a node to the end of the file and move the pointer to it.
3. Reset: move the pointer to the starting of the file.

3. Indexed Access Method

This method is a variant of the direct access method. It maintains an index that contains the
addresses of the file blocks. To access a record, the OS will first search its address in the
index which will then point to the actual address of that block of the file that has the required
record.
File Types:

There are a large number of file types. Each has a particular purpose. The type of a file
indicates its use cases, contents, etc. Some common types are:

1. Media:

Media files store media data such as images, audio, icons, video, etc. Common
extensions: img, mp3, mp4, jpg, png, flac, etc.

2. Programs:

These files store code, markup, commands, scripts, and are usually executable. Common
extensions: c, cpp, java, xml, html, css, js, ts, py, sql, etc.

4. Operating System Level:

These files are present with the OS for its internal use. Common extensions: bin, sh, bat, dl,
etc.

5. Document:

These files are used for managing office programs such as documents, spreadsheets, etc.
Common extensions: xl, doc, docx, pdf, ppt, etc.

6. Miscellaneous:

Generic text file(.txt), canvas files, proprietary files, etc.

File Types in an OS

There are numerous file types that an operating system uses internally and are not generally
used or required by the system user. These files could be application software files, kernel
files, configuration files, metadata files, etc. Windows supports the following two file types:

1. Regular Files

Regular files consist of information related to the user. The files are usually either ASCII or
binary. ASCII files contain lines of text. The major benefit of an ASCII file is that it can be
displayed or printed as it is, and it can be edited using a text editor.

Binary files on printing may give some random junk content. Usually, a binary file would
have some sort of internal structure that is only known to the program that uses it. A binary
file is a sequence of bytes, which if is in the proper format, can be executed by the operating
system. Regular files are supported by both Windows as well as UNIX-based operating
systems.

2. Directories
A directory in the filesystem is a structure that contains references to other files and possibly
other directories. Files could be arranged by storing related files in the same directory.
Directories are supported by both Windows as well as UNIX-based operating systems.

3. Character Special Files

A character special file provides access to an I/O device. Examples of character special files
include a terminal file, a system console file, a NULL file, a file descriptor file, etc.

Each character special file has a device major number and a device minor number. The
device major number associated with a character special file identifies the device type. The
device minor number associated with a character special file identifies a specific device of a
given device type. Character special files are supported by UNIX-based operating systems.

4. Block Special Files

Block special files enable buffered access to hardware devices They also provide some
abstraction from their specifics. Unlike character special files, block special files always
allow the programmer to read and write a block of any size or alignment. Block special files
are supported by UNIX-based operating systems.

Functions of a File

 They are used for storing data in a computer.


 They enable the separation of data according to some criteria.
 They enable efficient, simple, organized access to data.
 They help in isolating sensitive or important data from the rest of the data.
 They enable locating particular data items in the storage medium.

Common Terms in Filesystem

1. File

A file is a logical unit of information created by processes that processes produce.

2. Directory

A location on the storage that stores several files within itself.

3. Partition

A part of the storage medium is virtually separate from the rest of the storage.

4. Access Mechanism

The process is followed by the OS to grant a user/process access to a file.

5. File Extension
A label appended to the name of a file after a dot. Gives information of the purpose of and
information in the file.

Space allocation

Following are the three methods of space allocation in an operating system:

1. Contiguous

In this method, every file occupies a set of consecutive addresses on the storage (secondary
memory/disk). Each entry in a directory contains a number of blocks, starting address of the
first block, and the file name. During writing, if the file size is expandable, then either extra
space is left, or the file is copied somewhere else leaving no extra space behind.

Contiguous Allocation

2. Indexed

A set of pointers is maintained in an index table. The index table is in turn stored in several
index blocks. In an index block, the ith entry (the pointer at position i) holds the disk address
of the ith file block.
Index Allocation

3. Linked

Each data block in the file contains the address of the next block. Each entry in a directory
contains file-name, block address, and (not necessarily) a pointer to the last block. In this file
allocation method, each file is treated as a linked list of disks blocks. In the linked space
allocation method, it is not necessary that disk blocks be assigned to a file in a contiguous
(consecutive) manner on the disk.
Linked Allocation
Directory Structure

For any particular file system, there is a starting point. From the starting point, we can
locate files and/or directories (folders). The directories themselves can also contain more
directories and files. This system of directories and files is known as a file tree. In nature,
trees begin with a root and grow to leaves. In the computing world, this is the same.
The root of a file tree is the beginning of the file system, and all other nodes trace back to it.
The only difference is that the root starts at the top and grows down from the root in a file
system. In the image below, the node labeled “A” is the root of the system.

Directory Structure
3 Multiprocessor and Multicore Operating Systems
3.1 Introduction
A multiprocessor system with multiple CPUs allows programs to be processed
simultaneously. On the other hand, the multicore system is a single processor with
multiple independent processing units called cores that may read and execute program
instructions.

3.1.1 Advantages and Disadvantages

There are various advantages and disadvantages of the multiprocessor system. Some
advantages and disadvantages of the multiprocessor system are as follows:

Advantages
There are various advantages of the multiprocessor system. Some advantages of the
multiprocessor system are as follows:

1. It is a very reliable system because multiple processors may share their work between
the systems, and the work is completed with collaboration.
2. It requires complex configuration.
3. Parallel processing is achieved via multiprocessing.
4. If multiple processors work at the same time, the throughput may increase.
5. Multiple processors execute the multiple processes a few times.

Disadvantages

There are various disadvantages of the multiprocessor system. Some disadvantages of the
multiprocessor system are as follows:

1. Multiprocessors work with different systems, so processors require memory space.


2. If one of the processors fails, the work is shared among the remaining processors.
3. These types of systems are very expensive.
4. If any processor is already utilizing an I/O device, additional processors may not
utilize the same I/O device that creates deadlock.
5. The operating system implementation is complicated because multiple processors
communicate with each other.

Advantages and disadvantages of Multicore System

There are various advantages and disadvantages of the multicore system. Some advantages
and disadvantages of the multicore system are as follows:

Advantages

There are various advantages of the multicore system. Some advantages of the multicore
system are as follows:

1. Multicore processors may execute more data than single-core processors.


2. When you are using multicore processors, the PCB requires less space.
3. It will have less traffic.
4. Multicores are often integrated into a single integrated circuit die or onto numerous
dies but packaged as a single chip. As a result, Cache Coherency is increased.
5. These systems are energy efficient because they provide increased performance while
using less energy.
Disadvantages

There are various disadvantages of the multicore system. Some disadvantages of the
multicore system are as follows:

1. Some OSs are still using the single-core processor.


2. These are very difficult to manage than single-core processors.
3. These systems use huge electricity.
4. Multicore systems become hot while doing the work.
5. These are much expensive than single-core processors.
6. Operating systems designed for multicore processors will run slightly slower on
single-core processors.

3.1.2 Multiprocessors Vs Multicore systems are as follows:

Features Multiprocessors Multicore

Definition It is a system with A multicore processor is a single processor that


multiple CPUs that contains multiple independent processing units
allows processing known as cores that may read and execute program
programs instructions.
simultaneously.

Execution Multiprocessors run The multicore executes a single program faster.


multiple programs
faster than a
multicore system.

Reliability It is more reliable It is not much reliable than the multiprocessors.


than the multicore
system. If one of any
processors fails in
the system, the other
processors will not
be affected.

Traffic It has high traffic It has less traffic than the multiprocessors.
than the multicore
system.

Cost It is more expensive These are cheaper than the multiprocessors system.
as compared to a
multicore system.
Configuration It requires complex It doesn't need to be configured.
configuration.

3.2 Types of Multiprocessors


Multiprocessing is the use of two or more central processing units within a single
computer system.
3.2.1 Symmetric Multiprocessing:
It involves a multiprocessor computer hardware and software architecture where two or
more identical processors are connected to a single, shared main memory, and have full
access to all input and output devices, In other words, Symmetric Multiprocessing is a
type of multiprocessing where each processor is self-scheduling.
For example, SMP applies multiple processors to that one problem, known as parallel
programming.

Symmetric Multiprocessing

3.2.2 Asymmetric Multiprocessing


Asymmetric Multiprocessing system is a multiprocessor computer system where not all
of the multiple interconnected central processing units (CPUs) are treated equally. In
asymmetric multiprocessing, only a master processor runs the tasks of the operating
system.
For example, AMP can be used in assigning specific tasks to the CPU based on the
priority and the importance of task completion.

Asymmetric Multiprocessing

Difference between Asymmetric and Symmetric Multiprocessing:


Sr. No. Symmetric Multiprocessing Asymmetric Multiprocessing
1 In symmetric multiprocessing, all In asymmetric multiprocessing, the
the processors are treated equally. processors are not treated equally.
2 Tasks of the operating system are Tasks of the operating system are done
done individual processor. by master processor.
3 All processors communicate with No Communication between Processors
another processor by a shared as they are controlled by the master
memory. processor.
4 In symmetric multiprocessing, the In asymmetric multiprocessing, process
process is taken from the ready scheduling approach used is master-
queue. slave.
5 Symmetric multiprocessing systems Asymmetric multiprocessing systems
are costlier are cheaper.
6 Symmetric multiprocessing systems Asymmetric multiprocessing systems
are complex to design. are easier to design.
7 The architecture of each processor All processors can exhibit different
is the same. architecture.
8 It is complex as synchronization is It is simple as here the master processor
required of the processors in order has access to the data, etc.
to maintain the load balance.
9 In case of processor failure, there is In case a master processor malfunctions
reduction in the system’s then slave processor continues the
computing capacity. execution which is turned to master
processor. When a slave processor fails
then other processors take over the task.
10 It is suitable for homogeneous It is suitable for homogeneous or
cores. heterogeneous cores.

3.3 Basic Multicore Concepts: Memory Sharing


A multi-core processor is a single computing component with two or more independent
processing units called cores, which read and execute program instructions. A shared-
memory multiprocessor is a computer system composed of multiple independent
processors that execute different instruction streams.
Multi-core is usually the term used to describe two or more CPUs working together on
the same chip. It is a type of architecture where a single physical processor contains the
core logic of two or more processors. Shared Memory Processor (SMP) follows multiple-
instruction multiple-data (MIMD) architecture. The processors share a common memory
address space and communicate with each other via memory. All the processors will have
dedicated cache memory. In a multiprocessor system all processes on the various CPUs
share a unique logical address space, which is mapped on a physical memory that can be
distributed among the processors. Each process can read and write a data item simply
using load and store operations, and process communication is through shared memory. It
isthe hardware that makes allCPUs access and use the same main memory. Since
allCPUsshare the addressspace, only a single instance ofthe operating system is required.
When a process terminates or goes into a wait state for whichever reason, the O.S. can
look in the processtable for another processto be dispatched to the idleCPU. On the
contrary, in systems with no shared memory, each CPU must have its own copy of the
operating system, and processes can only communicate through message passing. The
basic issue in shared memory multiprocessor systems is memory itself, since the larger
the number of processors involved, the more difficult to work on memory efficiently. All
modern OS support symmetric multiprocessing, with a scheduler running on every
processor the ready to run processes can be inserted into a single queue, that can be
accessed by every scheduler, alternatively there can be a ╉ ready to run╊ queue for each
processor. When a scheduler is activated in a processor, it chooses one of the ready to run
processes and dispatches it on its processor

3.3.1 Uniform Memory Access (UMA)

Here, all the processors share the physical memory in a centralized manner with equal
access time to all the memory words. Each processor may have a private cache memory.
Same rule is followed for peripheral devices. When all the processors have equal access
to all the peripheral devices, the system is called a symmetric multiprocessor. When only
one or a few processors can access the peripheral devices, the system is called an
asymmetric multiprocessor. When a CPU wants to access a memory location, it checks if
the bus is free, then it sends the request to the memory interface module and waits for the
requested data to be available on the bus. Multicore processors are small UMA
multiprocessor systems, where the first shared cache is actually the communication
channel. Fig 1 shows the uniform memory access model. Shared memory can quickly
become a bottleneck for system performances, since all processors must synchronize on
the single bus and memory access.

Uniform Memory Access Model

3.3.2 Non Uniform Memory Access (NUMA)

In NUMA multiprocessor model, the access time varies with the location of the memory
word. Here, the shared memory is physically distributed among all the processors, called
local memories. The collection of all local memories forms a global address space which
can be accessed by all the processors. NUMA systems also share CPUs and the address
space, but each processor has a local memory, visible to all other processors. In NUMA
systems access to local memory blocks is quicker than access to remote memory blocks.
Programs written for UMA systems run with no change in NUMA ones, possibly with
different performances because of slower access times to remote memory blocks. Single
bus UMA systems are limited in the number of processors, and costly hardware is
necessary to connect more processors. Current technology prevents building UMA
systems with more than 256 processors. To build larger processors, a compromise is
mandatory: not all memory blocks can have the same access time with respect to each
CPU. Since all NUMA systems have a single logical address space shared by all CPUs,
while physical memory is distributed among processors, there are two types of memories:
local and remote memory. Fig. represents the Non-uniform Memory Access Model.

Non- Uniform Process Model

3.3.3 No Remote Memory Access (NORMA)

No Remote Memory Access (abbreviated as NoRMA) is a computer memory


architecture for multiprocessor systems, given its name by Rashid (1987). In a NoRMA
architecture, the address space globally is not unique and the memory is not globally
accessible by the processors. Accesses to remote memory modules are only indirectly
possible by messages through the interconnection network to other processors, which in turn
possibly deliver the desired data in a reply message. The entire storage configuration is
partitioned statically among the processors.
The advantage of the NoRMA model is the ability to construct extremely large
configurations, which is achieved by shifting the problem to the user configuration. Programs
for NoRMA architectures need to evenly partitioning the data into local memory modules,
ensure consistency of software caches to enforce the desired consistency model, handle
transformations of data identifiers from one processor's address space to another, and realize
a message-passing system for remote access to data. The programming model of Norma
architecture is therefore extremely complicated.
3.4 Cache Coherence, Inter-Process (and intercore) Communication:

Caching can alleviate the problem due to remote data access, but brings the cache
coherency issue.
A method to enforce coherency is obviously bus snooping, but this techniques gets too
expensive beyond a certain number of CPUs, and it is much too difficult to implement in
systems that do not rely on bus-based interconnections.
The common approach in CC-NUMA systems with many CPUs to enforce cache coherency
is the directory-based protocol.
The basic idea is to associate each node in the system with a directory for its RAM blocks: a
database stating in which cache is located a block, and what is its state.
When a block of memory is addressed, the directory in the node where the block is located is
queried, to know if the block is in any cache and, if so, if it has been changed respect to the
copy in RAM.
Since a directory is queried at each access by an instruction to the corresponding memory
block, it must be implemented with very quick hardware, as an instance with an associative
cache, or at least with static RAM.

Cache-Coherent NUMA
3.4.1 Shared Memory

Shared memory system is the fundamental model of inter process communication. In a


shared memory system, in the address space region the cooperating communicate with each
other by establishing the shared memory region.
Shared memory concept works on fastest inter process communication.
If the process wants to initiate the communication and it has some data to share, then
establish the shared memory region in its address space. After that, another process wants to
communicate and tries to read the shared data, and must attach itself to the initiating
process’s shared address space.
Let us see the working condition of the shared memory system step by step.
Working
In the Shared Memory system, the cooperating processes communicate, to exchange the data
with each other. Because of this, the cooperating processes establish a shared region in their
memory. The processes share data by reading and writing the data in the shared segment of
the processes.
Let us discuss it by considering two processes. The diagram is shown below −
Shared Memory
Let the two cooperating processes P1 and P2. Both the processes P1 and P2, have their
different address spaces. Now let us assume, P1 wants to share some data with P2.
So, P1 and P2 will have to perform the following steps −
Step 1 − Process P1 has some data to share with process P2. First P1 takes initiative and
establishes a shared memory region in its own address space and stores the data or
information to be shared in its shared memory region.
Step 2 − Now, P2 requires the information stored in the shared segment of P1. So, process
P2 needs to attach itself to the shared address space of P1. Now, P2 can read out the data
from there.
Step 3 − The two processes can exchange information by reading and writing data in the
shared segment of the process.
The advantages of Shared Memory are as follows −
 Shared memory is a faster inter process communication system.
 It allows cooperating processes to access the same pieces of data concurrently.
 It speeds up the computation power of the system and divides long tasks into smaller
sub-tasks and can be executed in parallel.
 Modularity is achieved in a shared memory system.
 Users can perform multiple tasks at a time.

3.4.2 Message Passing

Message passing means how a message can be sent from one end to the other end. Either it
may be a client-server model or it may be from one node to another node. The formal
model for distributed message passing has two timing models one is synchronous and the
other is asynchronous.
The fundamental points of message passing are:
1. In message-passing systems, processors communicate with one another by sending and
receiving messages over a communication channel. So how the arrangement should be
done?
2. The pattern of the connection provided by the channel is described by some topology
systems.
3. The collection of the channels are called a network.
4. So by the definition of distributed systems, we know that they are geographically set of
computers. So it is not possible for one computer to directly connect with some other
node.
5. So all channels in the Message-Passing Model are private.
6. The sender decides what data has to be sent over the network. An example is, making a
phone call.
7. The data is only fully communicated after the destination worker decides to receive the
data. Example when another person receives your call and starts to reply to you.
8. There is no time barrier. It is in the hand of a receiver after how many rings he receives
your call. He can make you wait forever by not picking up the call.
9. For successful network communication, it needs active participation from both sides.

Message Passing Model


Advantages of Message Passing Model
1. Easier to implement.
2. Quite tolerant of high communication latencies.
3. Easier to build massively parallel hardware.
4. It is more tolerant of higher communication latencies.
5. Message passing libraries are faster and give high performance.
Disadvantages of Message Passing Model:
1. Programmer has to do everything.
2. Connection setup takes time that’s why it is slower.
3. Data transfer usually requires cooperative operations which can be difficult to achieve.
4. It is difficult for programmers to develop portable applications using this model because
message-passing implementations commonly comprise a library of subroutines that are
embedded in source code. Here again, the programmer has to do everything on his own.
3.5 Mobile Operating Systems

A mobile operating system (OS) is software that allows smartphones, tablet PCs (personal
computers) and other devices to run applications and programs.A mobile OS typically starts
up when a device powers on, presenting a screen with icons or tiles that present information
and provide application access. Mobile operating systems also manage cellular and wireless
network connectivity, as well as phone access.

3.5.1 Concept Need and Features

Concept and Features of Mobile Operating Systems

An operating system has many functions. Let us explore them. Some functions of operating
system OS is given below:

1. Device Management: The operations may require the use of gadgets. The operating
system is in charge of this. The Operating System:

 Maintain track of the gadgets.


 Determines how long each process can use each device.
 Devices are allocated and delegated to various operations.

2. Processor Management/Scheduling: When a system has multiple processes running, the


operating system determines that when and how each process uses the CPU. As a result, CPU
Scheduling is also the name. The Operating System:

 Processes are allocated and delegated to the processor.


 Keeps track of the CPU's state.

3. Memory Management: It is the administration of the major memory. Furthermore, any


code that is completed must be present in the main memory. As a result, multiple program
might be active at the same time. As a result, memory management is essential. The
Operating System:

 It allocates and releases memory.


 While multiprocessing, distributes memory.
 Keeps track of who uses which area of primary memory and how much.

4. File Management: On a computer, files are organised into folders. The Operating System:

 Maintains a log of files location and status.


 It allocates and releases memory.

5. Security: Through authentication, the OS maintains the system and programmes safe and
secure. The user's legitimacy is determined by their user id and password.
6. Other Functions: Other features of the operating system include:

 Detection of errors.
 Maintaining track on the system's performance
 Interaction between various software applications.

3.5.2 Types of Mobile OS

As we have discussed above there are lot of mobile operating systems existing in the market.
Some of them are listed below.

1. Android Operating System


2. Iphone Operating System/iOS
3. Bada Operating System
4. Symbian Operating System
5. Palm Operating System
6. MeeGo Operating System
7. Web Operating System

3.5.3 Overview of Android OS

Android is an open source and Linux-based Operating System for mobile devices such as
smartphones and tablet computers. Android was developed by the Open Handset Alliance,
led by Google, and other companies.
Android offers a unified approach to application development for mobile devices which
means developers need only develop for Android, and their applications should be able to run
on different devices powered by Android.
The first beta version of the Android Software Development Kit (SDK) was released by
Google in 2007 where as the first commercial version, Android 1.0, was released in
September 2008.
On June 27, 2012, at the Google I/O conference, Google announced the next Android
version, 4.1 Jelly Bean. Jelly Bean is an incremental update, with the primary aim of
improving the user interface, both in terms of functionality and performance.
The source code for Android is available under free and open source software licenses.
Google publishes most of the code under the Apache License version 2.0 and the rest, Linux
kernel changes, under the GNU General Public License version 2.
Features of Android
Android is a powerful operating system competing with Apple 4GS and supports great
features. Few of them are listed below −

Sr.No Feature & Description


.
1 Beautiful UI
Android OS basic screen provides a beautiful and intuitive user interface.

2 Connectivity
GSM/EDGE, IDEN, CDMA, EV-DO, UMTS, Bluetooth, Wi-Fi, LTE, NFC and
WiMAX.

3 Storage
SQLite, a lightweight relational database, is used for data storage purposes.

4 Media support
H.263, H.264, MPEG-4 SP, AMR, AMR-WB, AAC, HE-AAC, AAC 5.1, MP3, MIDI,
Ogg Vorbis, WAV, JPEG, PNG, GIF, and BMP.

5 Messaging
SMS and MMS

6 Web browser
Based on the open-source WebKit layout engine, coupled with Chrome's V8 JavaScript
engine supporting HTML5 and CSS3.

7 Multi-touch
Android has native support for multi-touch which was initially made available in
handsets such as the HTC Hero.

8 Multi-tasking
User can jump from one task to another and same time various application can run
simultaneously.

9 Resizable widgets
Widgets are resizable, so users can expand them to show more content or shrink them
to save space.

10 Multi-Language
Supports single direction and bi-directional text.
11 GCM
Google Cloud Messaging (GCM) is a service that lets developers send short message
data to their users on Android devices, without needing a proprietary sync solution.

12 Wi-Fi Direct
A technology that lets apps discover and pair directly, over a high-bandwidth peer-to-
peer connection.

13 Android Beam
A popular NFC-based technology that lets users instantly share, just by touching two
NFC-enabled phones together.

3.5.4 Applications of Mobile OS

1. Kernel

A kernel is the core/heart of an OS. It contains all the functions and operations to manage the
working of OS.

2. Process Execution

The OS executes various process so that the statements will execute and connect the application
program to the hardware. Whenever a process executes it uses memory, space and other
resources as well.

3. Interrupt

Interrupts are basically used be the hardware devices to communicate with the CPU. It is
basically a signal which the device generates to request the CPU. Moreover, whenever an
interrupt occurs the CPU temporarily stops executing its current process.

4. Memory Management

It is the management of the main or primary memory. Furthermore, whatever program is


executed, it has to be present in the main memory. Therefore, there can be more than one
program present at a time. Hence, it is required to manage the memory.

The operating system:

 Allocates and deallocates the memory.


 Keeps a record of which part of primary memory is used by whom and how much.

 Distributes the memory while multiprocessing.

5. Multitasking

It is performing more than one tasks at a time. The OS allows the user to work with more than
one process at a time without any problem.

6. Security

The OS keeps the system and programs safe and secure through authentication. A user id and
password decide the authenticity of the user.

7. User Interface

GUI stands for Graphical User Interface. As the name suggests, it provides a graphical interface
for the user to interact with the computer. It uses icons, menus, etc. to interact with the user.
Moreover, the user can easily interact by just clicking these items. Therefore, it is very user
friendly and there is no need to remember any commands.

3.6 Distributed Operating Systems

The distributed operating system consists of different computers which are connected with a
network within a virtual shell. A user interacts with the virtual shell in order to perform
different tasks as and when needs arises but the distributed operating system architecture
delegates the responsibility of performing a task to one or more computers within the virtual
shell.

The dotted circle (boundary) in the Figure gives an idea about the user’s view of distributed
operating system and the internal details are not visible to a user. However, the developer’s
view of the distributed operating system will be component available within the dotted circle.
The Figure 1.1 shows the availability of components from 1 up to N which can vary from one
scenario to other. The components within a distributed operating system can be computers of
different operating system which are located at different sites for execution. All the
components are connected using a strong local area network as the same plays a vital role in
execution of a task within a distributed architecture. The operating system generally provides
different functions like process management, input/ output management, memory
management, file organization, security & protection and network management. The
distributed operating system has different components which are responsible from different
functions of an operating system and all these components are connected with a network.
Whenever a user submits a command to a distributed operating system, the instruction may
require the services of one or more than one components of an operating system. The user
gets a feel as if the whole system is a single unit but internally the whole system consists of
sub systems which work in tandem in order to achieve the centralized objective of a
distributed operating system. Plain distributed processing shares the workload among
computers that can communicate with one another. True distributed processing has separate
computers to perform different tasks in such a way that their combined work can contribute
to a goal. The latter type of processing requires a highly structured environment that allows
hardware and software to communicate, share resources, and exchange information freely

View of Distributed Operating System

3.6.1 Concept Need and Features

Distributed systems provide scalability and improved performance in ways that


monolithic systems can't, and because they can draw on the capabilities of other computing
devices and processes, distributed systems can offer features that would be difficult or
impossible to develop on a single system.here are three types of Distributed OS.
 Client-Server Systems − It is a tightly coupled operating system. It is used for
multiprocessors and homogeneous multicomputer. Client-Server Systems works as a
centralized server because it provides the approval to all requests, which are generated
by the client systems side.
 Peer-to-Peer Systems − It is a loosely coupled system. It is implemented in the
computer network application because it contains a bunch of processors, and they are
not shareable memories or clocks as well. Every processor consists of its own local
memory, and these processors communicate with each other through various
communication media such as high-speed buses or telephone lines.
 Middleware − It allows the interoperability in the between of all applications, which
are running on other operating systems. By using these services those applications are
capable of transferring all data to each other. It allows distribution transparency.

Distributed Operating System depicted here

Features of Distributed Operating systems


1. Connecting Users and Resources :
The main goal of a distributed system is to make it easy for users to access remote
resources, and to share them with other users in a controlled manner. Resources can be
virtually anything, typical examples of resources are printers, storage facilities, data,
files, web pages, and networks. There are many reasons for sharing resources. One
reason is economics.

2. Transparency :
An important goal of a distributed system is to hide the fact that its process and
resources are physically distributed across multiple computers. A distributed system
that is capable of presenting itself to users and applications such that it is only a single
computer system is called transparent.
The concept of transparency can be applied to many aspects of a distributed system as
shown in table.
Different Forms of Transparency –

S.No Transparency Description


1 Access Hide data representation.
2 Location Hide location
3 Migration Move place information.
4 Relocation Hide moved place relocation.
5 Replication Hide that a resource is replication.
6 Concurrency Shared data bases access
7 Failure Hide fact about resource failure.
8 Persistence Hide fact about memory location.
.
1. Openness :
Another important goal of distributed systems is openness. An open distributed system
is a system that offers services in standards that describable the syntax and semantics of
those service instances, standard rules in computer networks control the format, content,
and meaning of messages sent and received. Such rules are formalized in the protocols.
In distributed systems, services are typically specified through interfaces, often called
interface definition languages (IDL). Interface definitions written in IDL almost always
capture only the syntax of services. They accurately specify the names of functions that
are available with the types of parameters, return values, possible exceptions that can be
raised and so on.

2. Scalability :
The uncertain trend in distributed systems is towards larger systems. This observation
has implications for distributed file system design. Algorithms that work well for
systems with 100 machines can work for systems with 1000 machines and none at all
for systems with 10, 000 machines. for starters, the centralized algorithm does not scale
well. If opening a file requires contacting a single centralized server to record the fact
that the file is open then the server will eventually become a bottleneck as the system
grows.

3. Reliability :
The main goal of building distributed systems was to make them more reliable than
single processor systems. The idea is that if some machine goes down, some other
machine gets used to it. In other words, theoretically the reliability of the overall system
can be a Boolean OR of the component reliability. For example, with four file servers,
each with a 0.95 chance of being up at any instant, the probability of all four being
down simultaneously is 0.000006, so the probability of at least one being available is
(1-0.000006)= 0.999994, far better than any individual server.

4. Performance :
Building a transparent, flexible, reliable distributed system is useless if it is slow like
molasses. In particular application on a distributed system, it should not deteriorate
better than running some application on a single processor. Various performance
metrics can be used. Response time is one, but so are throughput, system utilization,
and amount of network capacity consumed. Furthermore, The results of any benchmark
are often highly dependent on the nature of the benchmark. A benchmark involves a
large number of independent highly CPU-bound computations which give radically
different results than a benchmark that consists of scanning a single large file for same
pattern.

3.6.2 Examples of Distributed OS with brief introduction

There are numerous distributed operating system examples. Here are a few of them:
Solaris – Made for multiprocessor SUN workstations.
OSF/1 – Created by the very Open Foundation Software Company and is Unix compatible.
Micros – While allocating particular jobs to all nodes present in the system, the MICROS OS
ensures a balanced data load.
DYNIX – Created specifically for Symmetry multiprocessor systems.
Locus – It can access both local and distant files at the same time, regardless of location.
Mach – It has multithreading and multitasking capabilities.

3.6.3 Applications of Distributed OS


Some applications by their very nature are distributed across multiple computers because of
one or more of the following reasons: · The data used by the application are distributed · The
computation is distributed · The users of the application are distributed Data are Distributed
Some applications must execute on multiple computers because the data that the application
must access exist on multiple computers for administrative and ownership reasons. The
owner may permit the data to be accessed remotely but not stored locally. Or perhaps the data
cannot be co-located and must exist on multiple heterogeneous systems for historical reasons.
Computation is Distributed · Some applications execute on multiple computers in order to
take advantage of multiple processors computing in parallel to solve some problem. · Other
applications may execute on multiple computers in order to take advantage of some unique
feature of a particular system.
Users are Distributed Some applications execute on multiple computers because users of the
application communicate and interact with each other via the application. E.g. a banking
application where ATMs and PCs share access to the bank’s database. Each user executes a
piece of the distributed application on his or her computer, and shared remote objects,
typically execute on one or more servers. Prior to designing a distributed application, it is
essential to understand some of the fundamental realities of the distributed system on which it
will execute.
Communication · The communication between objects in the same process is orders of
magnitude faster than communication between objects on different machines. The
implication of this is that you should avoid designing distributed applications in which two or
more distributed objects have very tight interactions (i.e. have significant communication
between them). · If two objects have tight interactions, they should be co-located.
Failures · When two objects are co-located, they fail together; if the process in which they
execute fails, both objects fail. The designer of the objects need not be concerned with the
behavior of the application if one of the objects is available and the other one is not since that
will not happen. · But if two objects are distributed across process boundaries, the objects can
fail independently. In this case, the designer of the objects must be concerned with each of
the object's behavior in the event the other object has failed. · So also, in a distributed system
the network can partition and both objects can execute independently assuming the other has
failed.
Concurrent Access · The default mode for most local programs is to operate with a single
thread of control. Single threaded programming is easy. Objects are accessed in a well-
defined sequential order according to the program's algorithms, and you need not be
concerned with concurrent access. If you decide to introduce multiple threads of control
within a local program, you must consider the possible orderings of access to objects and use
synchronization mechanisms to control concurrent access to shared objects. · In a distributed
application, there are necessarily multiple threads of control. Each distributed object is
operating in a different thread of control. A distributed object may have multiple concurrent
clients. As the developer of the object and the developer of the clients, you must consider this
concurrent access to objects and use the necessary synchronization mechanisms.
Security · When two objects are co-located in the same process, you need not be concerned
about security. When the objects are on different machines, you need to use security
mechanisms to authenticate the identity of the other object.
Extra Reading : Virtual Machine
A virtual machine (VM) is a virtual environment which functions as a virtual computer
system with its own CPU, memory, network interface, and storage, created on a physical
hardware system.
VMs are isolated from the rest of the system, and multiple VMs can exist on a single piece of
hardware, like a server. That means, it as a simulated image of application software and
operating system which is executed on a host computer or a server.
It has its own operating system and software that will facilitate the resources to virtual
computers.
Characteristics of virtual machines
The characteristics of the virtual machines are as follows −
 Multiple OS systems use the same hardware and partition resources between virtual
computers.
 Separate Security and configuration identity.
 Ability to move the virtual computers between the physical host computers as
holistically integrated files.

Single OS with no VM Multiple OS with No. of VMs

Benefits
Let us see the major benefits of virtual machines for operating-system designers and users
which are as follows −
 The multiple Operating system environments exist simultaneously on the same
machine, which is isolated from each other.
 Virtual machine offers an instruction set architecture which differs from real
computer.
 Using virtual machines, there is easy maintenance, application provisioning,
availability and convenient recovery.
Virtual Machine encourages the users to go beyond the limitations of hardware to achieve
their goals.
The operating system achieves virtualization with the help of a specialized software called a
hypervisor, which emulates the PC client or server CPU, memory, hard disk, network and
other hardware resources completely, enabling virtual machines to share resources.
The hypervisor can emulate multiple virtual hardware platforms that are isolated from each
other allowing virtual machines to run Linux and window server operating machines on the
same underlying physical host.
Extra Reading: Load balancing
Load balancing is a core networking solution used to distribute traffic across multiple servers
in a server farm. Load balancers improve application availability and responsiveness and
prevent server overload. Each load balancer sits between client devices and backend servers,
receiving and then distributing incoming requests to any available server capable of fulfilling
them
How it Works
A load balancer may be:
 A physical device, a virtualized instance running on specialized hardware, or a software
process
 Incorporated into application delivery controllers (ADCs) designed to more broadly improve
the performance and security of three-tier web and micro services-based applications,
regardless of where they’re hosted
 Able to leverage many possible load balancing algorithms including round robin, server
response time, and the least connection method to distribute traffic in line with current
requirements

Load balancers detect the health of backend resources and do not send traffic to servers that
are not able to fulfil requests. Regardless of whether it’s hardware or software, or what
algorithm(s) it uses, a load balancer disburses traffic to different web servers in the resource
pool to ensure that no single server becomes overworked and subsequently unreliable. It
effectively minimizes server response time and maximizes throughput.
The role of a load balancer is sometimes likened to that of a traffic cop, as it is meant to
systematically route requests to the right locations at any given moment, thereby preventing
costly bottlenecks and unforeseen incidents. Load balancers should ultimately deliver the
performance and security necessary for sustaining complex IT environments, as well as the
intricate workflows occurring within them.
Load balancing is the most scalable methodology for handling the multitude of requests from
modern multi-application, multi-device workflows. In tandem with platforms that enable
seamless access to the numerous applications and desktops within today’s digital workspaces,
load balancing supports a more consistent and dependable end-user experience for
employees.

Hardware vs software-based load balancers


Hardware-based load balancers work as follows:
 They are typically high-performance appliances, capable of securely processing multiple
gigabits of traffic from various types of applications.
 These appliances may also contain built-in virtualization capabilities, which consolidate
numerous virtual load balancer instances on the same hardware.
 That allows for more flexible multi-tenant architectures and full isolation of tenants, among
other benefits.

In contrast, software-based load balancers:


 Can fully replace load balancing hardware while delivering analogous functionality and
superior flexibility
 May run on common hypervisors, in containers, or as Linux processes with minimal
overhead on bare-metal servers
 Are highly configurable depending on the use cases and technical requirements in question
 Can save space and reduce hardware expenditures

Common load balancing solutions


Round robin load balancing
Round robin is a simple load balancing solution for making sure that a virtual server forwards
each client request to a different server based on a rotating list. It’s easy for load balancers to
implement, but doesn’t take into account the load already on a server. There is a danger that a
server may receive a lot of processor-intensive requests and become overloaded.
Least connection method
Whereas round robin does not account for the current load on a server (only its place in the
rotation), the least connection method does make this evaluation and, as a result, it usually
delivers superior performance. Virtual servers following the least connection method will
seek to send requests to the server with the least number of active connections.
Least response time method
More sophisticated than the least connection method, the least response time method relies on
the time taken by a server to respond to a health monitoring request. The speed of the
response is an indicator of how loaded the server is and the overall expected user experience.
Some load balancers will take into account the number of active connections on each server
as well.
Least bandwidth method
A relatively simple algorithm, the least bandwidth method looks for the server currently
serving the least amount of traffic as measured in megabits per second (Mbps). Similarly the
least packets method selects the service that has received the fewest packets in a given time
period.
Hashing methods
Methods in this category make decisions based on a hash of various data from the incoming
packet. This includes connection or header information, such as source/destination IP
address, port number, URL, or domain name.
Custom load method
The custom load method enables the load balancer to query the load on individual servers via
SNMP. The administrator can define the server load of interest to query—CPU usage,
memory, and response time—and then combine them to suit their requests.
4. Real Time OS
4.1 Introduction and use of RTOS

Real-time operating system (RTOS) is an operating system with two key features:
predictability and determinism. In an RTOS, repeated tasks are performed within a tight time
boundary, while in a general-purpose operating system, this is not necessarily so.
Predictability and determinism, in this case, go hand in hand: We know how long a task will
take, and that it will always produce the same result.

RTOSes are subdivided into “soft” real-time and “hard” real- time systems. Soft real-time
systems operate within a few hundred milliseconds, at the scale of a human reaction. Hard
real-time systems, however, provide responses that are predictable within tens of
milliseconds or less.

An RTOS is a type of operating system, but it is vastly different from the kind most
consumers are familiar with. Operating systems in phones or personal computers are,
comparatively, bloated with apps and features; they must be able to support anything the user
might want to do today. An RTOS, on the other hand, is streamlined, meant to execute its
tasks quickly and effectively. It is a fraction of the size, sometimes only a few megabytes (vs.
more than 20 gigabytes), with a simple graphical interface, and it lacks many familiar
features, such as a web browser.

Characteristics of an RTOS

 Determinism: repeating an input will result in the same output.

 High performance: rtos systems are fast and responsive, often executing actions
within a small fraction of the time needed by a general os.

 Safety and security: rtoses are frequently used in critical systems when failures can
have catastrophic consequences, such as robotics or flight controllers. To protect
those around them, they must have higher security standards and more reliable safety
features.

 Priority-based scheduling: priority scheduling means that actions assigned a high


priority are executed first, and those with lower priority come after. This means that
an rtos will always execute the most important task.

 Small footprint: versus their hefty general os counterparts, rtoses weigh in at just a
fraction of the size. for example, windows 10, with post-install updates, takes up
approximately 20 gb. vxworks®, on the other hand, is approximately 20,000 times
smaller, measured in the low single-digit megabytes.
Use of RTOS

Due to its benefits, a real-time operating system is most often used in an embedded system —
that is, a system that operates behind the scenes of a larger operation. The RTOS usually has
no graphical interface. Occasionally, multiple OSes are integrated simultaneously, to provide
operational capability coupled with the usability of a general-purpose OS.

RTOSes are often in intelligent edge devices, also known as electromechanical edge or cyber-
physical systems. This means that the device is both producing and operating upon data. So a
car, for example, would be able to monitor its surroundings and act upon them
instantaneously on its own. Such devices often couple artificial intelligence or machine
learning, or both, with real-time components to increase the capabilities of the underlying
structure.

Some companies try to produce their own RTOS in house, tailor-made for their project,
instead of buying a commercial off-the-shelf operating system. This has some advantages:
The operating system is designed specifically for the use case, and the company understands
its mechanics and inner workings. However, this approach is often more expensive and more
time-consuming, and developers who are not used to working on operating systems take a
great deal of time to produce one. Using a commercial system is faster, easier, and brings the
benefit of an experienced technical team that can answer questions and provide support. An
operating system is a tool, much like a hammer or a drill. While you could make one — one
that you would thoroughly understand and that might fit your project better — it would take a
lot of time, without guarantees of performance or capability.

You might also like