0% found this document useful (0 votes)
28 views23 pages

OS - Unit 3 - Digital Content - 2024

Uploaded by

memowe8980
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views23 pages

OS - Unit 3 - Digital Content - 2024

Uploaded by

memowe8980
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Operating

Systems

MODULE-3: Concurrency: Deadlock and


Memory Management

Compiled by: Prof. Maitreyi Joglekar


[email protected]

Vidyalankar School of
Information Technology
Wadala (E), Mumbai
www.vsit.edu.in
Certificate

This is to certify that the e-book titled “Operating Systems” comprises all elementary learning tools
for a better understating of the relevant concepts. This e-book is comprehensively compiled as per
the predefined eight parameters and guidelines.

Signature
Date: 03-09-2024
Ms. Maitreyi Joglekar
Assistant Professor

Department of IT & DS

DISCLAIMER: The information contained in this e-book is compiled and distributed for
educational purposes only. This e-book has been designed to help learners understand
relevant concepts with a more dynamic interface. The compiler of this e-book and
Vidyalankar Institute of Technology give full and due credit to the authors of the
contents, developers and all websites from wherever information has been sourced. We
acknowledge our gratitude towards the websites YouTube, Wikipedia, and Google
search engine. No commercial benefits are being drawn from this project.
Unit 3 Concurrency- Deadlock and Memory Management

Contents:
Concurrency:
Principles of Deadlock, Deadlock Detection, Deadlock Prevention, Deadlock Avoidance, Safe
and Unsafe states, Bankers Algorithm
Memory Management
Virtual Memory, Swapping, Paging, Segmentation, Page replacement algorithms, Issues with
paging

Recommended Books:
1. Modern Operating Systems, Edition 4 by Andrew Tanenbaum, Pearson Publications
2. Operating Systems-Internals and Design Principles, Edition 8 by William Stallings,
Pearson publishing House
3. Operating Systems Concept, Edition 8 by Silberschatz, Wiley Publications
4. Operating Systems: By Godbole and Kahate, Tata McGraw-Hill

• Prerequisites and Linking


UNIT-III Pre-requisites Linkage
Sem 1 Sem 2 Sem 4 Sem 5 Sem 6
Concurrency- Principles of Object Introduction Linux System Service
Deadlock and Programming Oriented to Administration Management
Memory Language Programming Embedded
Management with C++ Systems
Unit 3- Concurrency Deadlock and Memory Management

Deadlock
Q.1 List two types of resources. Explain with suitable example
1. A preemptable resource - is one that can be taken away from the process
owning it with no ill effects.
E.g.
• Memory and CPU cycles is an example of a preemptable resource.
• Consider, a system with 1 GB of memory, one printer, and two 1-GB
processes that each want to print something.
• Currently process A is in main memory. Process A requests and gets the
printer, then starts to compute the values to print. Before it has finished the
computation, its quantum is up and is swapped out to disk.
• Process B now is swapped in main memory and tries to acquire the printer.
• Now we have a deadlock situation, because A has the printer and B has the
memory, and neither one can proceed without the resource held by the
other.
• It is possible to preempt (take away) the memory from B by swapping it out
and swapping A in. Now A can run, do its printing, and then release the
printer. No deadlock occurs.

2. A non-preemptable resource- is one that cannot be taken away from its current
owner without potentially causing failure.
E.g.
• DVD/CD recorder is non-preemptable.
• If a process has begun to burn a CD, suddenly taking the CD recorder away
from it and giving it to another process will result in a garbled/distorted CD.
Q. Define Deadlock and explain the same with an example.
2
Deadlock is a set of blocked processes each holding a resource and waiting to
acquire a resource held by another process.
The cause of deadlocks: Each process needing what another process has.

Source- https://www.youtube.com/shorts/DGU8LT6fSSg
Example-
• Two processes A and B, each want to record a scanned document on a Blu-
ray disc.
• So resources required are scanner and Blu-ray recorder.
• Process A requests to use the scanner and acquires it.
• Process B is programmed differently and requests the Blu-ray recorder first
and is also granted it.
• Now A asks for the Blu-ray recorder, but the request is suspended until B
releases it. Unfortunately, instead of releasing the Blu-ray recorder, B asks
for the scanner.
• At this point both processes are blocked and will remain so forever.
• This situation is called a deadlock.

Q.3 What is deadlock? What are necessary conditions for occurrence of deadlock?
Deadlock is a set of blocked processes each holding a resource and waiting to
acquire a resource held by another process.
The cause of deadlocks: Each process needing what another process has.
Conditions for deadlock-
1) Mutual exclusion‐ Resources are non-sharable. Resource should be used by
a single process at a time.

2) Hold‐and‐wait‐ Processes currently holding resources can request new


resources that are being held by other processes.

3) No‐preemption‐ Resources previously granted cannot be forcibly taken


away from a process. They must be released by the process holding them.
4) Circular wait condition- There must be a circular list of two or more
processes, each of which is waiting for a resource held by the next member
of the chain.

Q.4 Write a short note on deadlock detection with one resource of each type.
Consider a system with one resource of each type.
E.g. System with 1 printer, 1 scanner, 1 plotter and 1 CD recorder.

Steps to detect deadlock-


1. Construct a resource graph.
2. If this graph contains one or more cycles, a deadlock exists.
3. If no cycle exists, the system is not deadlocked.
Example-
 Process A holds R and wants S.
 Process B holds U and wants S and T.
 Process C holds T and wants V.
 Process D holds V and wants U.

Conclusion-
In above grapg, there exists a cycle as shown above.
Processes B, C and D are deadlocked, as they are in circular wait.
Process A can is not in deadlocked state.
Q.5 Write a short note on deadlock detection with multiple resources of each type.
• It is a matrix‐based algorithm for detecting deadlock.
• Let total P processes want to run and m resource classes are available.
• E is the existing resource vector with E1 resourcesof class 1, E2 resources of
class 2, Em resources of class m.
E= (E1, E2, E3, ....., Em)
E.g. Consider system with 3 processes and 4 resource classes with 4 tape
drives, 2 plotters, 3 scanners and 1 Blu‐ray.
P= 3 processes (P1,P2,P3)
m=4 resource classes
• Let C be current allocation matrix, Cij is
the number of instances of resource j that
are held by process i.
• Let A be the available resource vector,
with A1 unallocated resources of class 1,
upto Am unallocated resources of class m.
A= (A1, A2, A3, ...., Am)
• Let R be the request matrix. Rij is the number of
instances of resource j that Process i
wants.

The deadlock detection algorithm can now


be given as follows.
• Look for process Pi , for which the ith row of R is less than or equal to A.
• If such a process is found, add the ith row of C to A, mark the process, and go
back to step 1.
• If no such process exists, the algorithm terminates.
Consider request matrix 1, request of P3 will be fulfilled. So no deadlock in system.
Consider request matrix 2, request of neither of the processes will be fulfilled. So all
processes are stuck and there is a deadlock in system.
Q.6 Write a note on deadlock recovery.
Recovery through Preemption‐

• Temporarily take away a resource from its current owner and give it to
another process.
• Take a resource away from a process, give it to another process and then give
it back without the process noticing it.
• The process which has acquired the resources but currently doing some other
tasks are chosen in this case.
Recovery through Rollback‐
• Check which resources are needed to recover a deadlock.
• A process that has a needed resource is rolled back in time to the point
before it has taken that resource.
• In effect, the process is reset to an earlier moment when it did not have the
resource.
• Periodic check pointing is used here. Checkpointing a process means that its
state is written to a file periodically so that it can be restarted later.
Recovery through Killing Processes‐
• The crudest but simplest way to break a deadlock is to kill one or more
processes.
• Kill one process in the cycle.
• In this approach, the process to be killed is carefully chosen because it is
holding resources that some process in the cycle needs.
• If this does not help, it can be repeated until the cycle is broken.
Q.7 Explain deadlock prevention in detail.
Attacking The Mutual Exclusion Condition‐
• Make resources sharable.
• E.g read only file can be accessed by many users at a time.
• But printer cannot be shared, because its dedicated device.
• By spooling printer, several processes can generate output at the same time.
Attacking The Hold and Wait Condition‐
• To avoid hold and wait, allocate all the resources needed for a process before
the start of execution.
• If all resources are available, process will start its execution.
• If one or more resources are busy, then process will go into waiting state.
• Problem ‐ many processes do not know how many resources they will need
until they have started running.
• Resources will not be used optimally with this approach.
Attacking The No Preemption Condition‐
• Resources assigned to the process can be taken away to prevent deadlock
situation.
• If a process is holding some resources and requests another resource that
cannot be immediately allocated to it (that is, the process must wait), then
all resources the process is currently holding are preempted.
• Some resources can be virtualized to avoid this situation.
Attacking The Circular Wait Condition‐
• One way is to have a rule that a process can have only one resource at any
moment. If it needs a second one, it must release the first one.
• Second way is assign a unique number to each resource type. Each process
request the resources in increasing order of assigned numbers.
• It should release any resources with number less than the requested value.

Q8 Deadlock Avoidance- What is safe and unsafe state?


Safe and Unsafe State-
• At any instant of time, there is a current state consisting of E, A, C, and R.
• A state is said to be safe if there is some scheduling order in which every
process can run to completion even if all of them suddenly request their
maximum number of resources immediately
• A has three instances of the resource but may need as many as nine
eventually.
• B currently has two and may need four altogether.
• C also has two but may need an additional five.
• A total of 10 instances of the resource exist, so with seven resources
already allocated, three are still free.

• The state of (a) is safe because there exists a sequence of allocations that
allows all processes to complete.
• Namely, the scheduler can simply run B exclusively, until it asks for and gets
two more instances of the resource, leading to the state of (b). When B
completes, the state moves of (c). Then the scheduler can run C, leading to
(d).
• When C completes the state moves (e).
• Now A can get the six instances of the resource it needs and also complete.
• Thus, the state of (a) is safe because the system, by careful scheduling, can
avoid deadlock.

Q.9 Deadlock prevention-Explain Banker’s algorithm.


• The algorithm checks to see if granting the request leads to an unsafe state.
If so, the request is denied. If granting the request leads to a safe state, it is
carried out.

• Processes A, B, C, and D, each of whom has been granted a certain


number of resources.
• The banker knows that not all customers will need their maximum
credit immediately
• The situation is like (b) at a certain moment. This state is safe because with
two units left, the banker can delay any requests except C’s, thus letting C
finish and release all four of his resources.
• With four units in hand, the banker can let either D or B have the
necessary units, and so on
• Consider what would happen if a request from B for one more unit were
granted
• in (b). We would have situation (c), which is unsafe.
• The customers suddenly asked for their maximum loans, the banker could
not satisfy any of them, and we would have a deadlock.
• An unsafe state does not have to lead to deadlock, since a customer might
not need the entire credit line available, but the banker cannot count on
this behaviour.

Source- https://www.youtube.com/watch?v=lMNrmDUJ3GY

Q10 Explain 2-phase locking.


• If multiple processes try to access and update the database at the same time,
there is a possibility of deadlock.
• To avoid that, OS uses the concept of LOCKING.
• The process which wants to update the database, first it locks all the records so
that no other process can access it at the same time. Once the updating is
done, process unlocks the records.
• The process is carried out in two phases-
1. Phase 1- Process locks all the records it needs, one at a time.
2. Phase 2- Process updates the locked records and then releases the lock one
by one.
AS shown in figure, total 5 records are there in system.

Q.11Explain livelock.
• Imagine 2 processes A and B, both require 2 resources- resource 1 and resource
2 for execution.
• Processes are using polling method in order to acquire lock.
• Polling- Request for resource, if not available wait for few seconds and then
request again. The process continues till the resource is acquired.
• Suppose A first acquires resource 1 and B first acquires resource 2.
• Suppose process 1 wants to lock resource 2 and process 2 wants to lock
resource 1 at the same time, which is not possible.
• So both the processes will release the resources they already has, wait for some
time and follow the same process.
• This cycle will be repeated forever and no process can run, but neither of the
processes will be blocked.
• Each process will use time gap over and over without making progress.
• Here- no deadlock as no process is blocked.
• Livelock- Both processes are live but no process can run further.

Q12 Explain starvation.


• In computer system, multiple processes request for the same resource at
same time.
• So some algorithm is used to decide which process must get the resource.
• But this algorithm may lead starvation of some processes- i.e. some process
will never get the resource even though it is not deadlocked.


• Example- Suppose multiple processes have requested to access the Printer.
Algorithm used- print smallest file first
• If one process has a huge file, every time when printer if free it will choose a
process with shortest file. The process with huge file will never get printer
and will starve to death. (it won’t be blocked but postponed every time)
• The first come first serve algorithm is a good option to avoid starvation, but
it has some other disadvantages.
Memory Management

Q.1 Explain Swapping with example.


Ans: Swapping-
1. Swapping is exchanging data between the hard disk and the RAM without
splitting a process.
2. A process must be loaded into RAM in order to execute.
3. If there is not enough memory available to keep all running processes in RAM at
the same time, then some processes which are not currently using the CPU are
stored on Hard disk.

Example-

a. Only A in memory
b. Process B is swapped in from hard disk to memory
c. Process C is swapped in from hard disk to memory.
d. A goes in waiting state. So swapped out to hard disk.
e. D swapped in.
f. B goes in waiting state. So swapped out to hard disk.
g. A has come out of waiting state and ready to execute again. So swapped in
again to RAM
Characteristics-
1. Variable partitions
2. Number, location and size of partitions vary dynamically.
Memory Compaction-
Swapping creates multiple holes in memory. Combine all holes together to form big
one by moving all the processes downwards.

Q. 2 Explain the concept of base and limit register in memory management.


1. Memory abstraction- User doesn’t have to deal with actual physical memory
addresses.
Abstraction layer hides memory hierarchy and provides users with illusion of easily
accessible memory known as Virtual Memory.
2. Address space- Each process has its own set of addresses that always start from
zero. known as address space.The addresses are different for each program.
Address space is a logical address/Virtual address of a process.
3. Logical address-
Location which is seen by process. Starts from 0 for each process.
4. Physical address- Actual RAM location seen by OS.
5. Base and Limit Registers- In order to execute the processes, they must be
brought into physical memory from virtual memory. MMU uses base and limit
registers to convert logical address into actual physical address.
Base Register- Contains beginning RAM address of a process.
Limit Register- Contains length of a program.
The mapping is done as shown in diagram below.

Q. 3 What is paging in memory management? Explain with diagram.

1. Each process has its own address space called as Logical/ virtual address space.
2. In other words, processes are stored in Virtual address space.
3. Virtual Address space is divided into fixed size small units called pages.
4. Physical address space(RAM) is divided into small fix sized units call frames.
5. Size of Page= Size of frame
i.e. each frame can accommodate 1 page
6. Page table- In order run execute pages, they must be brought into physical
memory. Page table Maps pages from virtual memory into frames in RAM.
It is a table maintained by OS to indicate which page is mapped into which frame.
Page Fault-
No space in physical memory for new page. In order to add new page, one page
must be removed from RAM. Which page must be removed to make room for new
page is decided by Page replacement Algorithms.
Source- https://www.youtube.com/watch?v=c-BRg5wPceU

Q. 4 Explain optimal page replacement algorithm with example.


1. Replace the page that won’t be needed for longest time in the future.
2. Knowledge of future is required i.e. whole sequence has to be known in advance.
3. Not realizable in practice as algorithm the page on the basis of future use.
4. Has lowest page fault rates.
5. Example- Consider a page sequence as given below-

6. Pages 2,3,4 are initially brought into main memory causing page fault. Next 2
page is to be added, which is already there in main memory, so page hit.
7. In order to add page 1, replace the page 2 as it is not needed for long time in
future.
8. In above case, total page faults= 6, total hits=4
Q. 5 Explain FIFO page replacement algorithm with example.
1. The simplest page replacement algorithm and works on basis of first in first out.
2. It removes the pages out in the order in which they are brought in.
3. This algorithm chooses oldest page for the replacement.
4. A queue is maintained in order to hold pages.
5. Example- Consider sequence given below-

6. Pages 4,7,3 are initially brought into main memory causing page fault.
7. In order to add page0, replace the page 4 as it has come first into the RAM.
8. Next page 7 will be replaced as it is the oldest page in RAM.
9. Total page Faults=11 , total page hits= 1

Source- https://www.youtube.com/watch?v=RSOmQV0Wk3Q

Q.6 Write a short note on second chance page replacement algorithm


1. It is modification in FIFO.
2. This algorithm uses additional bit called as Reference bit (R). If page in main
memory is referenced again, reference bit is incremented by 1.
3. Before replacing the page, reference bit is checked,
• If R=0 ---page is unused and old, replace it
• If R=1 ---do not replace the page, a second chance is given to that page
4. After page gets second chance, its reference bit is made zero.
5. Example- Consider the page sequence given below

5. Initially bring page 2 in main memory causing page fault. R=0 for page 2 as it is
referenced single time.
6. Then bring page 3 in main memory causing page fault. R=0 as it is referenced
single time.
7. Now page 2 is already in RAM and is referenced again, so make R=1 for page 2.
8. Bring in page 1 with R=0.
9. In order to add 5, page 2 is supposed to be replaced as per FIFO policy. But page
2 has second chance (R=0), so it cannot be replaced. So page 2 will remain in RAM
with R=0. Then page 3 will be removed as per FIFO policy.
10. Total page faults=7 , total page hits= 5
Q.7 Write a short note on LRU page replacement algorithm.
1. Removes the page that has not been used for longest time.
2. In order to add new page, this algorithm replaces the page that was used far
back in past.
3. This algorithm looks backward in time, while optimal algorithm looks forward in
time.
4. Example- Consider following sequence-

5. Pages 4,7,3 are initially brought into 3 frames of main memory causing page
fault.
6. Next, page 2 is already in memory so it will lead to page hit.
7. In order to add page 1, algorithm checks 3 distinct pages in the past and removes
the page that is far away (i.e. 3rd page). Out of pages 2,4,3 , page 3 is far away in
past. So algorithm will remove page 3 and will add page 1 at the place of page 3.
8. Total page faults-8, total page hits- 2

Q.8 Explain clock page replacement algorithm with neat diagram.


1. Similar to second chance page replacement algorithm, only difference here is,
frames are arranged clockwise i.e. in circular manner as shown in diagram below.
2. The hand of clock points to the oldest page.
3. This algorithm uses additional bit called as Reference bit (R). If page in main
memory is referenced again, reference bit is incremented by 1.
4. When page fault occurs, page pointed by hand is inspected.
5. Before replacing the page, reference bit is checked,
• If R=0 ---page is unused and old, replace it. Then advance the hand by 1
position.
• If R=1 ---do not replace the page, a second chance is given to that page.
After page gets second chance, its reference bit is made zero and then
advance the hand by 1 position.
Q.9 Explain NRU page replacement algorithm.
1. Each page has reference bit R and modified bit M.
2. R is set when page is referenced(read/written)
3. M is set when page is modified (i.e. written).
4. Pages are divided into 4 categories-
• Class 0- not referenced, not modified
• Class 1- not referenced, modified
• Class 2- referenced, not modified
• Class 3- referenced, modified

5. Removes the page that has not been used recently. Class 0 is of lowest priority
while class 3 is of highest priority.
6. In case of page fault, first replace pages of class 0, then class 1 or class 2.
7. R=1 and M=1 indicates recently used pages.

Q.10 Explain Working set page replacement algorithm.


1. Working set is the set of pages which is currently being used by a process.
2. On the occasion of a page fault, a page is located which is not in the working set
and then it is removed.
3. When there is a page fault entire page table is scanned to find a page for
removal.
4. R is the referenced bit and t is the number of clock ticks.
• if R = 1, shows that the page in use during page fault and will not be
removed. A second chance is given to a page.
• If R = 0 , Age is calculated by: (Current virtual time – Time of last use)
If Age > t, then the page is not in working set and is removed.
If Age ≤ t, then the page is in the working set and is not removed.

Q.11 Explain Working set clock page replacement algorithm.


1. Working set clock PRA. Pages are put in a circular list just like in a clock.
Working set is the set of pages which is currently being used by a process.
2. On the occasion of a page fault, a page is located which is not in the working set
and then it is removed.
3. For an entry if R = 1, page is not removed. R bit is set to 0 and clock hand is
moved to next page.
4. If R = 0 and Age is calculated by: (Current virtual time – Time of last use)
If Age > t, then the page is not in working set and is replaced by a new page.
If Age ≤ t, then the page is in the working set and is not removed. Clock hand is
moved to next page.

Q.12 Explain design issues with paging.


1. Local Vs Global Allocation Policies-
i. Local-
Considers the pages allocated for that particular process.
If page fault occurs, replace the page of the same process by using PRA.
ii. Global-
Consider all pages in memory.
If page fault occurs, replace any page from main memory using PRA.
2. Load Control-
If virtual memory is too much larger than main memory available, thrashing may
occur.
Thrashing- State in which CPU performs ‘productive’ work less and ‘swapping’ more.
Solution :
Reduce number of processes competing for memory
reconsider degree of multiprogramming
3. Page Size-
If page size is small--- better fits for various data structures, but programs need many
pages which leads to larger page tables.
If page size is large – number of pages are less but results in internal fragmentation
4. Separate Data and instruction space and shared pages
Separate space for program and data. By separate Instruction(program) and data
pages, sharing can be done.
Advantage- Several users can run same program at the time. But data of each process
is different.
Better to share the program pages, rather than creating multiple copies of the same
in main memory.

Q.13 Explain segmentation concept with neat diagram.


1. Segmentation is a Memory management scheme that supports user’s view of
program.
2. In order to bring process from Virtual memory to RAM, it is spitted segment wise.
2. A program is divided into different logical units, each unit is known as segment. A
program is a collection of Segments.
3. A segment is a logical unit such as-

• Main function
• User defined functions
• Symbol table- variables, arrays, pointers, other data structures
• Stack
• Subroutines
4. Virtual memory is divided into variable sized partitions, each partition serve a
specific function known as segment.
5. Segment Table- Entity which maps segments from Virtual memory to physical
memory.
6. Two registers are used for mapping-
 Base- starting physical address of a segment in main memory
 Limit- Length of a segment
Q 13 What is Dining Philosophers problem in IPC?
1. Five silent philosophers sit at a round table with bowls of spaghetti. Forks are placed
between each pair of adjacent philosophers.
2. Each philosopher must alternately think and eat.
3. However, a philosopher can only eat spaghetti when he has both left and right forks.
Each fork can be held by only one philosopher and so a philosopher can use the
fork only if it is not being used by another philosopher.
4. After he finishes eating, he needs to put down both forks so they become available
to others.
5. A philosopher can take the fork on his right or the one on his left as they become
available, but cannot start eating before getting both of them.
6. The problem is how to design a discipline of behaviour (a concurrent algorithm)
such that no philosopher will starve.
7. Mutual exclusion is the basic idea of the problem; the dining philosophers create a
generic and abstract scenario useful for explaining issues of this type.
8. The failures these philosophers may experience are analogous to the difficulties that
arise in real computer programming when multiple programs need exclusive access
to shared resources

Source- https://www.youtube.com/watch?v=XjlFoND00oY
MCQs-

Deadlock

1. Which of the following is an example of a non-preemptable resource?

a) Memory

b) CPU cycles

c) DVD/CD recorder

d) Printer

Answer: c) DVD/CD recorder

2. Which of the following is NOT a necessary condition for a deadlock to occur?

a) Mutual Exclusion

b) Hold and Wait

c) Preemption

d) Circular Wait

Answer: c) Preemption

3. What is the main purpose of deadlock detection?

a) To prevent deadlocks from occurring

b) To recover from a deadlock

c) To determine if a deadlock has occurred

d) To avoid deadlocks

Answer: c) To determine if a deadlock has occurred

4. In a system with single resources of each type, which of the following methods can
be used for deadlock detection?

a) Resource Allocation Graph

b) Wait-for Graph

c) Banker's Algorithm

d) FIFO Algorithm

Answer: a) Resource Allocation Graph


5. Which deadlock recovery method involves taking a resource away from a process
and giving it to another process?

a) Preemption

b) Rollback

c) Killing Processes

d) Page Replacement

Answer: a) Preemption

6. What does the Banker's Algorithm do to ensure a system is in a safe state?

a) It checks if a request will lead to a safe state.

b) It prevents deadlocks by allocating all resources initially.

c) It avoids circular wait conditions.

d) It uses priority scheduling to avoid deadlock.

Answer: a) It checks if a request will lead to a safe state.

7. Which of the following is NOT a technique used for deadlock prevention?

a) Avoiding Circular Wait

b) Hold and Wait Prevention

c) Attacking Mutual Exclusion

d) Using Second Chance Algorithm

Answer: d) Using Second Chance Algorithm

8. What is the main characteristic of a livelock situation?

a) Processes are blocked and cannot proceed.

b) Processes are making no progress but are not blocked.

c) Resources are held but not used.

d) Processes are waiting indefinitely for a resource.

Answer: b) Processes are making no progress but are not blocked.


Memory Management

1. What does the base register contain in memory management?

a) Length of the process

b) Beginning RAM address of a process

c) Size of the page

d) Current available memory

Answer: b) Beginning RAM address of a process

2. Which page replacement algorithm replaces the page that will not be needed for the
longest time in the future?

a) FIFO

b) LRU

c) Optimal

d) Clock

Answer: c) Optimal

3. In the FIFO page replacement algorithm, which page is replaced?

a) The page that has not been used recently

b) The page that was loaded into memory first

c) The page that will be used soon

d) The page that has been referenced the most

Answer: b) The page that was loaded into memory first

4. What is the purpose of the Working Set Page Replacement Algorithm?

a) To remove the page that has not been used recently

b) To remove the page that has been in memory the longest

c) To remove the page not in the working set

d) To give pages a second chance before removal

Answer: c) To remove the page not in the working set


5. What does the NRU page replacement algorithm consider when deciding which page
to replace?

a) The amount of memory available

b) The reference and modified bits of the pages

c) The time since the page was last used

d) The size of the pages

Answer: b) The reference and modified bits of the pages

6. Which memory management technique involves dividing virtual address space into
fixed-size units?

a) Segmentation

b) Paging

c) Swapping

d) Compaction

Answer: b) Paging

7. In the context of memory management, what is a page fault?

a) When a page is loaded into memory

b) When a page is removed from memory

c) When a page required by a process is not in memory

d) When a page is accessed by the CPU

Answer: c) When a page required by a process is not in memory

8. Which of the following is NOT a design issue with paging?

a) Local vs. Global Allocation Policies

b) Page Size

c) Swapping

d) Load Control

Answer: c) Swapping

You might also like