You are on page 1of 9

Operating Systems: - End Term Examination

Name: - Aditya Ojha Rollo: - E19CSE139 Batch:EB09

Question 1: -

Memory Management is one of the most important functions of an operating system it


helps the operating system to manage the whole of the memory and processes related to
it. With the knowledge, you have on the topic of memory management answer the
following questions with sufficient text and diagrammatic explanations.

RAM is considered one of the most important parts of memory management explain
why? Explain with a numerical example how a higher RAM improves efficiency.

Keeping in mind the above question explain what degree of Multi Programming is and
how it’s an essential part of Memory Management.

What are the ways programs are stored in RAM what are the different management
techniques used , also show with concrete examples why is fixed partitioning not used
nowadays?

Answer 1: -

Memory Management is a method/functionality to manage various types of memory


resources like RAM, hard disk, registers present in an operating system in a more and
more efficient manner is job of the operating system. The most important function of
memory management is to manage the primary memory (RAM) which occupies the
majority part of the memory which is RAM. CPU is an important part of the operating
system and the main function of the CPU is to execute instructions.

The CPU is directly connected to the registers the cache and the primary memory which
is RAM. This secondary memory is not connected directly to the CPU because the
secondary memory is very slow and the CPU is very fast hence a faster memory is
connected directly to the CPU which is RAM. All the programs are sitting idle in the
secondary memory and to be executed they are transferred to the RAM/primary
memory where the CPU executes them. Because RAM is such an important component
of how your computer works if one storage space out of a million is destroyed, your
entire system might crash. The sync of RAM and CPU will predict how well our computer
will perform.
The more RAM your CPU has, the easier it is for it to execute its job, and the faster your
computer will be. As a result, RAM is regarded as one of the most critical parts of
memory management. Now let's take an example to see why a higher RAM makes your
computer more efficient.

let's take a RAM of size 4 MB and process of size 8 MB. Now to calculate the total
number of processors, we divide the RAM size by the process size and we will get the
number of processors that is equal to 1. Now let's take a variable K that symbolizes the
amount of time a process takes to do input-output operation hence for CPU it will
execute for (K-1) time let's assume the value of K to be 70% hence the computer
utilization will come out to be 30%. So we are getting 30% CPU utilization with 4 MB
RAM now let's increase the RAM size and check what happens.

Now when we increase the RAM to 8 MB we can see that the total number of processes
increase to 2 hence the time taken by a process for input and output operations will
increase to (K^2) now we check CPU utilization through the formula we can see that the
CPU utilization come out to be 76%.

Hence we can see that with an increase in RAM there is an increase in CPU utilization
which makes a computer faster.
The concept of multiprogramming says that to bring more and more programs from the
secondary memory to the primary memory so that the CPU can execute them and does
not sit idle at any moment to have the highest amount of efficiency it can have. The
degree of multiprogramming is directly proportional to the CPU utilization hence higher
the value degree of multiprogramming higher the CPU is being utilized. We all know that
a process is executed in two ways either by the CPU or by the input-output devices

Now let's assume data process p1 has entered RAM and is being executed by the CPU
and in between the process p1 has signaled for some input-output devices hence the
CPU forwarded it to the input and the output devices respectively now as there was only
one process that was entered in the CPU, it is now idle and this is the problem. If the
CPU is being idle the efficiency will go down and the performance will be also down
hence to keep more efficiency the concept of multiprogramming is used.

Now in respect to the above question, we saw that when the RAM was 4 MB the
number of processes for 1 and the efficiency was 30% now when we increase the RAM
to 8 MB the number of processes increases to 2, and the efficiency increase to 76% now
as we have studied the concept of multiprogramming we can see that that increasing
RAM increases the processes and hence the CPU becomes more efficient that's the right
degree of multiprogramming is essentially in operating systems

The operating system uses various memory management methods to manage the
primary memory that is RAM and we also know that degree of multiprogramming is very
important which suggests keeping more and more programs in the main memory so that
when the CPU asks for the program we have plenty at hand.
Now we know that the memory is an area of bytes and every byte has an address So
what we do is divide the memory into multiple partitions so it can keep the programs to
be executed in a running state. They are two types of memory management techniques
contiguous and non-contiguous memory management.

contiguous memory management: -


As the name suggests contagious memory management means the contiguous
allocation of memory in RAM .we try to keep the consecutive programs in continuous
addresses in the main memory. Contiguous memory management includes two types of
partitioning static or fixed partitioning and dynamic or variable partitioning. We split the
main memory into fixed-size partitions in fixed partitioning, and we split the memory
into variable-size partitions in variable partitioning.
Non-contiguous memory management: -
As the name suggests it does not do continuous memory allocation it divides memory
into different partitions and you can put a process into different parts of the memory. It
consists of paging, multi-level, paging, Inverted paging, segmentation, segmented paging
FIXED PARTITIONING
Fixed partitioning or static partitioning means dividing the main memory or RAM into
fixed partitions to store the runtime programs some important points to keep in mind
while doing fixed partitioning is –

1. the number of partitions should be fixed

2. The size of each partition of the main memory may or may not be the same

3. Contiguous allocation so panning is not allowed

Fixed partitioning was used in the 1960s and is not used nowadays because of the
following disadvantages you have when you use fixed partitioning

Internal fragmentation:-
When the size of the partition of the main memory is greater than the size of the
process that is being utilized in that partition then there is a bit of memory left that is
not utilized and this is known as internal fragmentation. We cannot use that leftover
memory for any kind of process as it is a continuous fragmentation and planning is not
have allowed.

Limitation in process size:-


Let's assume that the maximum size of the partition in memories of 16 MBs so we
cannot store a process of memory greater than that hence there is a limit on what size
of processors we can execute & hence we cannot store any size of the program in the
RAM, the size should be less than or equal to the size of the largest partition

Limitation on the degree of multiprogramming:-


As you know the degree of mult-iprogramming is essential for CPU utilization. Now
suppose we have partition our main memory into four parts so there is a cap on the max
number of the process we can store in the main memory which is 4 hence there is a limit
on the degree of multiprogramming and hence the efficiency of the computer is also
capped.

External fragmentation:-
Suppose due to internal fragmentation the total leftover space left in all of the partitions
added up to 6 MBS and suppose there is a new process P5of size 5 MB , we cannot store
this in our partitions even though there is space because we are having continuous
memory allocation and hence we cannot divide a process into parts and store them in
different locations that is non-contiguous memory management.
Question 2: -

There are 2 siblings Aditya and Arundhati in a household, now it’s time for the
afternoon show Aditya wants to watch Cartoon network but at the same time
Arundhati wants to watch nickelodeon Can you compare this to any operating system
phenomenon if yes then answer

Explain the above phenomenon briefly with more examples also state the necessary
conditions for this to happen.

What are the methods we can use to handle such a situation?

What are Resource Allocation Graphs? solve the following question and check
whether a deadlock is happening or not.

Answer 2: -
As we can see that the above problem is of a deadlock situation and operating system.
Deadlock is basically when two or more processes are or waiting on the happening of
some event but it does not happen, then we say that these two processes are in a
deadlock state. In our day-to-day life, there are a lot of situations where deadlock
happens I will be able to operate that on that with more examples. let's take an example
of a deadlock state through a diagram.
In the above diagram, we can see that there are two resources resource 1 and resource
2 and there are two processes process 1 and process 2. resource one has been allocated
to process 1 and process one needs resource two for execution whereas resource 2 is
allocated to process 2 and process 2 needs resource 1 for execution hence we can see
that non of the resources are available and hence process one and process two are in a
deadlock situation.

Some real-life examples are:-


1. You can't acquire a job unless you have (professional) experience, and you can't
obtain experience unless you have a job.

2. You must be professional in the creative process, showing up and doing your
work regularly. You must, however, be light-hearted, amusing, easy-going, and
childish.

3. If you stay up all night studying, you'll be too fatigued and distracted in class the
next day, and you'll have to make up for it by staying up another night.

Some of the major points for deadlock situation to happen are:-

Mutual exclusion:-
Suppose you are going up on the stairs and a guy is going down the and the stairs are
very narrow for only one person to either go up or go down, this condition arises the
point of that only one person (process) can go either up or down the stairs (resource) at
a particular time and not at the same time this is one of the most important conditions
for deadlock to happen.

Hold and wait:-


It is a well-known fact in crypto industry is that most of the people usually hold to their
crypto, they refuse to sell their share of the crypto currency , this is called holding one of
the second most important steps for a deadlock to happen.
no pre-emption:-
You can't stop a process in order for another process to happen things don't operate this
way in an operating system it fits for one task to complete and then only reallocates the
resource to the process.

Circular wait:-
Circular wait occurs when two persons refuse to recede and wait for each other to
recede so that they can accomplish their mission. It's the very final condition for a
stalemate to happen.

There are many ways to handle a deadlock situation but some of the most important
methods of handling a deadlock situation are:-

Ignorance:-
It is considered the best way to deal with deadlocks. The main concept behind ignorance
it's just to ignore the deadlock that occurred in the system and just simply restart your
system. The main concept is to why to write a full-fledged code for deadlock when it is
very rare and hardly occurs In the system. We are not writing any code to increase the
performance of the system as the operating system already consists of many programs
and adding more programs will just hinder this speed for the system

Prevention:-
It is based on the principle of prevention is better than cure it prevents a deadlock to be
formed by countering out one of the four necessary situations for a deadlock to happen
that include mutual exclusion hold and wait for no pre-emption sensor regular weight it.
It is the discards all of these situations or either one of them. If any one or all four of the
conditions get false then the deadlock will be prevented

Avoidance:-
In this method what we do is whenever we give resources to process we check whether
it is a safe situation or not. For every resource allocation, we check the safe and the
unsafe condition which is based on the banker's algorithm also known as a digital
algorithm

detection and recovery:-


In this method, we try to detect deadlock beforehand by making a resource allocation
graph and when we detect the deadlock we try to recover it from the system. One of the
ways to recover is to kill the processes that are included in creating deadlock we will
check whether after removing the process there is a deadlock or not if the deadlock
persists we remove it at the other program if it does not we stop.

Personally, I think the ignorance method is the best way to deal with deadlocks because
it does not add any pre-built programs to our system which is already loaded with
programs and hence keeps it fast and efficient.
The give RAG has a no of instances and also contains a cycle so it may or may not have a
deadlock.

Allocation Need

R1 R2 R3 R1 R2 R3

Process P0 1 0 1 0 1 1

Process P1 1 1 0 1 0 0

Process P2 0 1 0 0 0 1

Process P3 0 1 0 0 2 0

Available = [ R1 R2 R3 ] = [ 0 0 1 ]
The give RAG has a no of instances and also contains a cycle so it may or may not have a
deadlock.
1. Since we can see from the table that only process P2 is satisfied hence it is
executed and it frees up it’s resources. Available = [ 0 0 1 ] + [ 0 1 0 ] = [ 0 1
1]
2. We can see from the last step that instances available are [ 0 1 1 ] and with
this only process P0 is satisfied hence it is executed and it frees up its
resources. Available =[ 0 1 1 ] + [ 1 0 1 ] = [ 1 1 2 ]
3. We can see from the last step that instances available are [ 1 1 2 ] and with
this only process P1 is satisfied hence it is executed and it frees up its
resources. Available=[ 1 1 2 ] + [ 1 1 0 ] = [ 2 2 2 ]
4. We can see from the last step that instances available are [ 2 2 2 ] and with
this only process P3 is satisfied hence it is executed and it frees up its
resources.
Available

=[222]+[010]

=[232]

Thus We can see that there is a sequence of P2, P0, P1, P3 in which no deadlock
will be formed hence the system is secure.

You might also like