Professional Documents
Culture Documents
Question 1: -
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: -
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.
2. The size of each partition of the main memory may or may not be the same
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.
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 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.
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.
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.
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
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.