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

Operating System

Gghhhbb

Uploaded by

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

Operating System

Gghhhbb

Uploaded by

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

Unit- 1: Introduction of operating

system
An Operating System (OS) is an interface between a computer user and
computer hardware. An operating system is a software which performs all the
basic tasks like file management, memory management, process management,
handling input and output, and controlling peripheral devices such as disk drives
and printers.

Some popular Operating Systems include Linux Operating System, Windows


Operating System, VMS, OS/400, AIX, z/OS, etc.

Following are some of important functions of an operating System

•. Memory management • Device management • security

Applications of Operating System


Following are some of the important activities that an Operating System
performs −

 Security − By means of password and similar other techniques, it


prevents unauthorized access to programs and data.
 Control over system performance − Recording delays between
request for a service and response from the system.
 Job accounting − Keeping track of time and resources used by
various jobs and users.
 Error detecting aids − Production of dumps, traces, error
messages, and other debugging and error detecting aids.
 Coordination between other softwares and users −
Coordination and assignment of compilers, interpreters, assemblers
and other software to the various users of the computer systems.

Simple Batch operating system


The users of a simple batch operating system do not interact with the
computer directly. Each user prepares his job on an off-line device like
punch cards and submits it to the computer operator. To speed up
processing, jobs with similar needs are batched together and run as a
group. The programmers leave their programs with the operator and the
operator then sorts the programs with similar requirements into batches..

Some examples of batch-processing operating systems include:


 IBM’s z/OS
 Unisys MCP
 and Burroughs MCP/BCS

Advantages of Batch Operating System


The benefits of batch-processing operating systems include:
 Resource Efficiency: These systems improve the use of
computation resources by processing jobs in groups and
scheduling them during stages of resource accessibility.
 High Throughput: Batch processing systems can handle
and complete a large number of tasks quickly, confirming
quick turnaround times and high throughput.
 Error Reduction: Since these systems work without
requiring user interference, they minimize the risk of faults
that can occur with manual processing.
 Simplified Management: They restructure job
management by automating the submission, scheduling,
and implementation of tasks.
 Cost Efficiency: By producing well-organized use of
resources and reducing processing time and errors, batch
processing systems can be a cost-effective option.
 Scalability: These classifications can manage a huge
number of tasks, making them scalable and appropriate for
large organizations with significant data processing needs.
Disadvantages of Batch Operating System :
 Limited functionality: It can solve only simple tasks not
solve more complex tasks. this can make them difficult to
use for certain tasks, like managing files or software.
 Security issues:This is not more secure because they are
not typically used for day-to-day tasks, so they are not as
secure as more common operating systems.This can lead
to security risks if the system is used by people who should
not have access to it.
 Interruptions Batch systems can be interrupted
frequently, which can lead to missed deadlines or mistakes.
 Inefficiency: Batch systems are often slow and difficult to
use, which can lead to inefficiency in the workplace.
Multiprogramming batch operating
system. It allows to execute multiple processes by
monitoring their process states and switching in between
processes. It executes multiple programs to avoid CPU and memory
under utilization. It is also called as Multiprogram Task System.
Advantages of Multiprogramming :
 CPU never becomes idle
 Efficient resources utilization
 Response time is shorter
 Short time jobs completed faster than long time jobs
 Increased Throughput
Disadvantages of Multiprogramming :
 Long time jobs have to wait long
 Tracking all processes sometimes difficult
 CPU scheduling is required
 Requires efficient memory management
 User interaction not possible during program execution
Difference between Batch Processing OS and
Multiprogramming OS :
S.No
. BATCH PROCESSING MULTIPROGRAMMING
01.. A series of jobs are executed Multiprogramming operating system
without any human allows to execute multiple processes by
intervention in Batch monitoring their process states and
processing system. In this set
of jobs with similar needs are
batched together and switching in between processes. It executes
inputted to the computer for multiple programs to avoid CPU and
execution. memory underutilization.
Batch processing system is
02. slower in processing. Multiprogramming System is faster..
03.. CPU needs to stand idle. CPU needs not stand idle.
In this the processes have to
04.. wait in a queue. In this the process has to wait in a queue.
05.. process starts batch wise. process starts as it centers the processor.
In Batch processing system In multiprogramming system the CPU
06. the CPU utilization is less. utilization is more.

Time Sharing Operating System


A time-shared operating system uses CPU scheduling and multi-
programming to provide each user with a small portion of a shared
computer at once. Each user has at least one separate program in
memory. A program is loaded into memory and executes, it
performs a short period of time either before completion or to
complete I/O. This short period of time during which the user gets
the attention of the CPU is known as time slice, time slot, or
quantum. It is typically of the order of 10 to 100 milliseconds. This
is more complex than multiprogrammed operating systems. In
both, multiple jobs must be kept in memory simultaneously, so the
system must have memory management and security. To achieve a
good response time, jobs may have to swap in and out of disk from
the main memory which now serves as a backing store for the main
memory. A common method to achieve this goal is virtual memory,
a technique that allows the execution of a job that may not be
completely in memory.
Requirements of Time Sharing Operating System: An alarm
clock mechanism to send an interrupt signal to the CPU after
every time slice.
1. Active State – The user’s program is under the control of
the CPU. Only one program is available in this state.
2. Ready State – The user program is ready to execute but it
is waiting for its turn to get the CPU. More than one user
can be in a ready state at a time.
3. Waiting State – The user’s program is waiting for some
input/output operation. More than one user can be in a
waiting state at a time.
Advantages
1. Each task gets an equal opportunity.
2. Fewer chances of duplication of software.
3. CPU idle time can be reduced.
Disadvantages
1. Reliability problem.
2. One must have to take of the security and integrity of user
programs and data.
3. Data communication problem.

Personal Computer Operating System


A personal computer's operating system provides a good interface for a
single user.It is widely used for word processing, spreadsheets, and
Internet access.These are made only for personal use.

You can say that your laptops, computer systems, tablets, etc. are your
personal computers, and the operating systems such as Windows 7,
Windows 10, Android, etc. are your personal computer operating systems.

And you can use your personal computer operating system for your
personal purposes, for example, chatting with your friends using some
social media sites, reading some articles from the internet, making some
projects through Microsoft PowerPoint or any other program, designing
your website, programming something, watching some videos and
movies, listening to some songs, and many more.
Examples of Personal Computer Operating Systems:
 Android

 Windows

 iOS

 Mac OS X

 Linux Mint

 Ubuntu

 Fedora

The first of the above-mentioned personal computer operating systems,


"Android," is the most well-known and widely used operating system
worldwide. This operating system is used in smartphones.It’s market is 71%
among all users.

In terms of smartphone OS, iOS (by Apple) controls approximately 28% of


the global market.

Others, such as Windows (by Microsoft) and Mac OS X (by Apple), are used
on laptops or desktop computers.

When it comes to desktop computers, Windows 10 is the most popular


operating system. "Windows 10," like Android, is used by nearly 71% of
Windows desktop and laptop users. I only compared Windows PCs or
laptops because I was discussing a specific version of "Windows," namely
"Windows 10."

And, when it comes to all devices, "Android" is the most well-known,


accounting for approximately 42% of the global market, followed by
Windows (30%), iOS (18%), macOS (6%), and Linux (1%).

To be honest, the Linux operating system is the most secure, fast, and
best for professionals, hackers, and administrators. People prefer the
"Windows" operating system as their primary operating system because it
is so simple to use. However, if you understand Linux, believe me when I
say that you will never switch to another operating system, whether it is
for a desktop or a laptop.
Parallel Systems
It designed to speed up the execution of programs by dividing the
programs into multiple fragments and processing these fragments
at the same time. Flynn has classified computer systems into four
types based on parallelism in the instructions and in the data
streams.
1. Single Instruction stream, single data stream
2. Single Instruction stream, multiple data stream
3. Multiple Instruction stream, single data stream
4. Multiple Instruction stream, multiple data stream
Advantages of Parallel Systems:
 High Performance: Parallel systems can execute
computationally intensive tasks more quickly compared to
single processor systems.
 Cost Effective: Parallel systems can be more cost-effective
compared to distributed systems, as they do not require
additional hardware for communication.
Disadvantages of Parallel Systems:
 Limited Scalability: Parallel systems have limited scalability
as the number of processors or cores in a single computer
is finite.
 Complexity: Parallel systems are more complex to program
and debug compared to single processor systems.
 Synchronization Overhead: Synchronization between
processors in a parallel system can add overhead and
impact performance.
Distributed operating system
These types of operating system is a recent advancement
in the world of computer technology and are being widely
accepted all over the world and, that too, at a great pace.
Various autonomous interconnected computers
communicate with each other using a shared
communication network. Independent systems possess
their own memory unit and CPU. These are referred to
as loosely coupled systems or distributed systems . These
systems’ processors differ in size and function. The major
benefit of working with these types of the operating system
is that it is always possible that one user can access the
files or software which are not actually present on his
system but some other system connected within this
network i.e., remote access is enabled within the devices
connected in that network.
Advantages of Distributed Operating System
 Failure of one will not affect the other network
communication, as all systems are independent of each
other.
 Electronic mail increases the data exchange speed.
 Since resources are being shared, computation is highly
fast and durable.
 Load on host computer reduces.
 These systems are easily scalable as many systems can be
easily added to the network.
 Delay in data processing reduces.

Disadvantages of Distributed Operating System


 Failure of the main network will stop the entire
communication.
 To establish distributed systems the language is used not
well-defined yet.
 Hi These types of systems are not readily available as they
are very expensive. Not only that the underlying software
is highly complex and not understood well yet.
Real-Time Operating System
These types of OSs serve real-time systems. The time interval
required to process and respond to inputs is very small. This time
interval is called response time. Real-time systems are used
when there are time requirements that are very strict like missile
systems, air traffic control systems, robots, etc.
Types of Real-Time Operating Systems
 Hard Real-Time Systems: Hard Real-Time OSs are meant
for applications where time constraints are very strict and
even the shortest possible delay is not acceptable. These
systems are built for saving life like automatic parachutes
or airbags which are required to be readily available in case
of an accident. Virtual memory is rarely found in these
systems.
 Soft Real-Time Systems: These OSs are for applications
where time-constraint is less strict.
Advantages of RTOS
 Maximum Consumption: Maximum utilization of devices
and systems, thus more output from all the resources.
 Task Shifting: The time assigned for shifting tasks in
these systems is very less. For example, in older systems,
it takes about 10 microseconds in shifting from one task to
another, and in the latest systems, it takes 3 microseconds.
 Focus on Application: Focus on running applications and
less importance on applications that are in the queue.
 Real-time operating system in the embedded
system: Since the size of programs is small, RTOS can also
be used in embedded systems like in transport and others.
 Error Free: These types of systems are error-free.
 Memory Allocation: Memory allocation is best managed
in these types of systems.
Disadvantages of RTOS
 Limited Tasks: Very few tasks run at the same time and
their concentration is very less on a few applications to
avoid errors.
 Use heavy system resources:Sometimes the system
resources are not so good and they are expensive as well.
 Complex Algorithms: The algorithms are very complex
and difficult for the designer to write on.
 Device driver and interrupt signals: It needs specific
device drivers and interrupts signal to respond earliest to
interrupts.
 Thread Priority: It is not good to set thread priority as
these systems are very less prone to switching tasks.
Examples of Real-Time Operating Systems are Scientific
experiments, medical imaging systems, industrial control systems,
weapon systems, robots, air traffic control systems, etc.
SEGMENTATION

A process is divided into Segments. The chunks that a program is


divided into which are not necessarily all of the exact sizes are
called segments. Segmentation gives the user’s view of the process
which paging does not provide. Here the user’s view is mapped to
physical memory.
Types of Segmentation in Operating
Systems
 Virtual Memory Segmentation: Each process is divided
into a number of segments, but the segmentation is not
done all at once. This segmentation may or may not take
place at the run time of the program.
 Simple Segmentation: Each process is divided into a
number of segments, all of which are loaded into memory
at run time, though not necessarily contiguously.
There is no simple relationship between logical addresses and
physical addresses in segmentation. A table stores the information
about all such segments and is called Segment Table.
What is Segment Table?
It maps a two-dimensional Logical address into a one-dimensional
Physical address. It’s each table entry has:
 Base Address: It contains the starting physical address
where the segments reside in memory.
 Segment Limit: Also known as segment offset. It
specifies the length of the segment.

Segmentation

Translation of Two-dimensional Logical Address to Dimensional


Physical Address.
Translation

The address generated by the CPU is divided into:


 Segment number (s): Number of bits required to
represent the segment.
 Segment offset (d): Number of bits required to represent
the position of data within a segment.
Advantages of Segmentation in Operating
System
 Internal Fragmentation: It occurs only when unused
space arises, because the memory can be divided into
fixed size parts. But a process can’t use entire divided part.
 Segment Table consumes less space in comparison to Page
table in paging.
 As a complete module is loaded all at once, segmentation
improves CPU utilization.
 The user’s perception of physical memory is quite similar to
segmentation. Users can divide user programs into
modules via segmentation. These modules are nothing
more than separate processes’ codes.
 The user specifies the segment size, whereas, in paging,
the hardware determines the page size.
 Segmentation is a method that can be used to segregate
data from security operations.
 Flexibility: Segmentation provides a higher degree of
flexibility than paging. Segments can be of variable size,
and processes can be designed to have multiple segments,
allowing for more fine-grained memory allocation.
 Sharing: Segmentation allows for sharing of memory
segments between processes. This can be useful for inter-
process communication or for sharing code libraries.
 Protection: Segmentation provides a level of protection
between segments, preventing one process from accessing
or modifying another process’s memory segment. This can
help increase the security and stability of the system.
Disadvantages of Segmentation in
Operating System
 External Fragmentation: As processes are loaded and
removed from memory, the free memory space is broken
into little pieces, causing external fragmentation. This is a
notable difference from paging, where external
fragmentation is significantly lesser.
 Overhead is associated with keeping a segment table for
each activity.
 Due to the need for two memory accesses, one for the
segment table and the other for main memory, access time
to retrieve the instruction increases.
 Fragmentation: As mentioned, segmentation can lead to
external fragmentation as memory becomes divided into
smaller segments. This can lead to wasted memory and
decreased performance.
 Overhead: Using a segment table can increase overhead
and reduce performance. Each segment table entry
requires additional memory, and accessing the table to
retrieve memory locations can increase the time needed
for memory operations.
 Complexity: Segmentation can be more complex to
implement and manage than paging. In particular,
managing multiple segments per process can be
challenging, and the potential for segmentation faults can
increase as a result.
VIRTUAL MEMORY
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 available not by the actual
number of main storage locations.
Demand Paging: The process of loading the page into memory on
demand (whenever a page fault occurs) is known as demand
paging. The process includes the following steps are as follows:
Demand Paging

 If the CPU tries to refer to a page that is currently not


available in the main memory, it generates an interrupt
indicating a memory access fault.
 The OS puts the interrupted process in a blocking state. For
the execution to proceed the OS must bring the required
page into the memory.
 The OS will search for the required page in the logical
address space.
 The required page will be brought from logical address
space to physical address space. The page replacement
algorithms are used for the decision-making of replacing
the page in physical address space.
 The page table will be updated accordingly.
 The signal will be sent to the CPU to continue the program
execution and it will place the process back into the ready
state.

FIFO Page Replacement Algorithm in OS

FIFO (First In First Out) page replacement algorithm is a simple


page replacement algorithm that replaces the page that has been
in memory for the longest time.

In FIFO, the page that was brought into the memory first will be
the first one to be replaced when a page fault occurs and a new
page needs to be loaded. The operating system keeps track of all
pages that are currently loaded in memory and adds new pages
to the end of the queue as they are loaded. When a page fault
occurs, the operating system simply replaces the oldest page in
the queue.

FIFO is a straightforward and easy-to-implement algorithm, but it


can result in suboptimal performance in some cases. For example,
if there are pages that are frequently used together, they will end
up being replaced one by one, causing many page faults. This is
known as the "Belady’s Anomaly".

Despite its limitations, FIFO is still used in some cases, especially


when the operating system has limited resources and needs to
keep the algorithm implementation simple.

Advantages of the FIFO Page Replacement Algorithm

Here are some of the advantages of the FIFO Page Replacement


Algorithm:

 Easy to understand and implement: The FIFO page


replacement algorithm is very straightforward and easy to
understand, making it a simple algorithm to implement.
 Low overhead: The algorithm has low overhead and does
not require any additional data structures to maintain
information about page references.

Disadvantages of FIFO Page Replacement Algorithm

FIFO Page Replacement Algorithm suffers from the following


disadvantages:

 Poor performance: FIFO page replacement algorithm can


suffer from poor performance, especially when the number
of page faults is high.
 Belady’s Anomaly: FIFO page replacement algorithm can
result in a situation known as Belady’s Anomaly, where the
number of page faults can increase as the number of frames
increases.
 Does not consider page usage frequency:The FIFO
algorithm does not take into account how frequently a page
is used, and thus, pages that are heavily used may be
replaced by pages that are rarely used.
Optimal Page Replacement Algorithms in OS

The Optimal page replacement algorithm, also known as the MIN


(MINimum) page replacement algorithm, is a page replacement
algorithm that aims to minimize the number of page faults by
always replacing the page that will not be used for the longest
time in the future.

In other words, the Optimal page replacement algorithm replaces


the page that will not be used until the farthest time in the future.
This is achieved by analyzing the future use of the pages and
selecting the page that will not be used for the longest time as
the next page to be replaced.

While the Optimal page replacement algorithm provides the best


possible performance, it is not practical to implement in a real
operating system, as it requires knowledge of future page
accesses. In practice, the operating system does not have this
information and must use heuristics, such as LRU or FIFO, to
estimate the future use of the pages.

However, the Optimal page replacement algorithm is often used


as a benchmark to evaluate the performance of other page
replacement algorithms, as it provides a lower bound for the
number of page faults that can occur.

Advantages of Optimal Page Replacement Algorithms in


OS

Here are some of the advantages of Optimal Page Replacement


Algorithm:

 Good performance: Optimal page replacement algorithm


tends to provide the best performance in terms of reducing
page faults, as it replaces the page that will not be used for
the longest time in the future.
 Avoids Belady’s Anomaly: Optimal page replacement
algorithm avoids Belady’s Anomaly, a situation where the
number of page faults can increase as the number of frames
increases, which is a problem that occurs with the FIFO page
replacement algorithm.
 Considers future page usage: Optimal page replacement
algorithm takes into account future page usage, providing
an accurate prediction of which pages are likely to be used
in the future.

Disadvantages of Optimal Page Replacement Algorithm in


OS

The optimal Page Replacement Algorithm has the following


disadvantages:

 Impossible to implement: Optimal page replacement


algorithm is impossible to implement in practice, as it
requires knowledge of future page usage, which is not
available.
 Theoretical algorithm only: Optimal page replacement
algorithm is a theoretical algorithm used primarily for
performance comparison and evaluation purposes, rather
than as a practical algorithm for use in operating systems.
 No real-world implementation: The Optimal page
replacement algorithm does not have a real-world
implementation and is used only for comparison purposes
with other page replacement algorithms.
LRU Page Replacement Algorithm in OS

The LRU (Least Recently Used) page replacement algorithm is a


more sophisticated page replacement algorithm that attempts to
minimize the number of page faults by replacing the page that
has not been used for a longest time.

In LRU, the operating system keeps track of when each page was
last accessed and replaces the page that has not been used for
the longest time. This approach assumes that a page that has not
been used for a long time is less likely to be used in the near
future.

To implement LRU, the operating system can use a data


structure, such as a stack or a queue, to keep track of the pages
that are currently loaded in memory. When a page is accessed, it
is moved to the top of the stack or the head of the queue,
indicating that it has been recently used. When a page fault
occurs and a new page needs to be loaded, the operating system
replaces the page at the bottom of the stack or the tail of the
queue, which is the page that has not been used for the longest
time.

LRU provides better performance compared to the FIFO page


replacement algorithm, as it minimizes the number of page faults.
However, it can be more complex to implement compared to
FIFO, as the operating system needs to keep track of the access
times for each page and update the data structure accordingly.

Advantages of LRU Page Replacement Algorithms in OS

Here are some of the advantages of using the LRU page


replacement algorithm:

 Good performance: LRU page replacement algorithm


tends to perform well in most cases and provides good
results in reducing page faults.
 Avoids Belady’s Anomaly: LRU page replacement
algorithm avoids Belady’s Anomaly, a situation where the
number of page faults can increase as the number of frames
increases, which is a problem that occurs with the FIFO page
replacement algorithm.
 Reflects page usage frequency: LRU page replacement
algorithm takes into account the frequency of page usage,
replacing pages that are least frequently used.

Disadvantages of LRU Page Replacement Algorithms in OS

Some of the disadvantages of the LRU page replacement


algorithm:

 Complex implementation: LRU page replacement


algorithm can be complex to implement, especially when
implemented using linked lists or stacks, which may require
additional data structures to maintain information about
page references.
 High overhead: LRU page replacement algorithm may
have higher overhead compared to other page replacement
algorithms, due to the need to keep track of page usage
information.
 Poor performance in some cases: In some cases, LRU
page replacement algorithm may not perform as well as
other algorithms, such as the Optimal page replacement
algorithm, when page access patterns are not consistent.
LIFO Page Replacement Algorithms in OS

LIFO (Last In First Out) page replacement algorithm is a page


replacement algorithm that is similar to the FIFO page
replacement algorithm, with the difference being that it replaces
the page that was brought into memory most recently, instead of
the page that has been in memory the longest.

In LIFO, the operating system keeps a stack of the pages that are
currently loaded in memory, and adds new pages to the top of the
stack as they are loaded. When a page fault occurs and a new
page needs to be loaded, the operating system simply replaces
the page at the top of the stack, which is the page that was
brought into memory most recently.

LIFO is a straightforward and easy-to-implement algorithm, but it


can result in suboptimal performance in some cases. For example,
if there are pages that are frequently used together, they will end
up being replaced one by one, causing many page faults.

Despite its limitations, LIFO is not widely used in practice, as it


often results in worse performance compared to other page
replacement algorithms, such as FIFO or LRU.

Advantages of the LIFO Page Replacement Algorithm in OS

Here are some of the advantages of the LIFO Page Replacement


Algorithm:

 Simple implementation: LIFO page replacement algorithm


is simple to understand and implement, as it only requires a
stack to keep track of page references.
 Low overhead: LIFO page replacement algorithm has low
overhead, as it does not require additional data structures to
maintain information about page references.

Disadvantages of the LIFO Page Replacement Algorithm in


OS
LIFO Page Replacement Algorithm has the following
disadvantages:

 Poor performance: LIFO page replacement algorithm can


suffer from poor performance, as it does not take into
account the frequency of page usage, which can result in
frequently used pages being replaced by less frequently
used pages.
 May result in page thrashing: LIFO page replacement
algorithm can result in a situation known as page thrashing,
where the pages are frequently swapped in and out of
memory, leading to high page fault rates and poor system
performance.
 Unpredictable results: The results of the LIFO page
replacement algorithm can be unpredictable, as the
performance of the algorithm depends on the order in which
pages are added to the memory.

 What is Thrashing?
 Thrashing is the term used to describe a state in which
excessive paging activity takes place in computer systems,
especially in operating systems that use virtual memory,
severely impairing system performance. Thrashing occurs
when a system’s high memory demand and low physical
memory capacity cause it to spend a large amount of time
rotating pages between main memory (RAM) and secondary
storage, which is typically a hard disc.
 It is caused due to insufficient physical memory, overloading
and poor memory management. The operating system may
use a variety of techniques to lessen thrashing, including
lowering the number of running processes, adjusting paging
parameters, and improving memory allocation algorithms.
Increasing the system’s physical memory (RAM) capacity can
also lessen thrashing by lowering the frequency of page
swaps between RAM and the disc.

Allocation of Frames in OS
The main memory of the operating system is divided into various frames.
The process is stored in these frames, and once the process is saved as a
frame, the CPU may run it. As a result, the operating system must set
aside enough frames for each process. As a result, the operating system
uses various algorithms in order to assign the frame.
Demand paging is used to implement virtual memory, an essential
operating system feature. It requires the development of a page
replacement mechanism and a frame allocation system. If you have
multiple processes, the frame allocation techniques are utilized to define
how many frames to allot to each one. A number of factors constrain the
strategies for allocating frames:

1. You cannot assign more frames than the total number of frames
available.
2. A specific number of frames should be assigned to each process.
This limitation is due to two factors. The first is that when the
number of frames assigned drops, the page fault ratio grows,
decreasing the process's execution performance. Second, there
should be sufficient frames to hold all the multiple pages that any
instruction may reference.

There are mainly five ways of frame allocation algorithms in the OS. These
are as follows:

1. Equal Frame Allocation


2. Proportional Frame Allocation
3. Priority Frame Allocation
4. Global Replacement Allocation
5. Local Replacement Allocation

Equal Frame Allocation


In equal frame allocation, the processes are assigned equally among the
processes in the OS. For example, if the system has 30 frames and 7
processes, each process will get 4 frames. The 2 frames that are not
assigned to any system process may be used as a free-frame buffer pool
in the system.

Disadvantage

In a system with processes of varying sizes, assigning equal frames to


each process makes little sense. Many allotted empty frames will be
wasted if many frames are assigned to a small task.

Proportional Frame Allocation


The proportional frame allocation technique assigns frames based on the
size needed for execution and the total number of frames in memory.
The allocated frames for a process pi of size si are ai = (si/S)*m, in
which S represents the total of all process sizes, and m represents the
number of frames in the system.

The only drawback of this algorithm is that it doesn't allocate frames based on
priority. Priority frame allocation solves this problem

Priority Frame Allocation


Priority frame allocation assigns frames based on the number of frame
allocations and the processes. Suppose a process has a high priority and
requires more frames that many frames will be allocated to it. Following
that, lesser priority processes are allocated.

Global Replacement Allocation


When a process requires a page that isn't currently in memory, it may put
it in and select a frame from the all frames sets, even if another process is
already utilizing that frame. In other words, one process may take a frame
from another.

Advantages

Process performance is not hampered, resulting in higher system


throughput.

Disadvantages

The process itself may not solely control the page fault ratio of a process.
The paging behavior of other processes also influences the number of
pages in memory for a process.

Local Replacement Allocation


When a process requires a page that isn't already in memory, it can bring
it in and assign it a frame from its set of allocated frames.

Advantages

The paging behavior of a specific process has an effect on the pages in


memory and the page fault ratio.

Disadvantages

A low priority process may obstruct a high priority process by refusing to


share its frames.

You might also like