Operations Systems C5 Flashcards

1
Q

Q132: What are the consequences of many programs competing for limited resources in a system?

A

A132: The consequences include:
- Lack of process synchronization
- Potential for deadlock, livelock, and starvation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Q133: How is a deadlock described in the context of system resource sharing?

A

A133: A deadlock is described as a “deadly embrace,” “Catch 22,” or “blue screen of death.” It occurs when two or more jobs are placed in a HOLD state because they are waiting for an unavailable vital resource, causing the system to come to a standstill.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the Seven Cases of Deadlock or Livelock

A
  • Nonsharable/nonpreemptable resources
    – Allocated to jobs requiring same type of resources
  • Resource types locked by competing jobs
    – File requests
    – Databases
    – Dedicated device allocation
    – Multiple device allocation
    – Spooling
    – Network
    – Disk sharing
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Q134: Describe the Narrow staircase analogy in the context of system resource sharing.

A

A134: The Narrow staircase analogy compares the system to a staircase where the steps and landings represent resources.
- Stairs are wide enough for only one person.
- Landing at each floor can accommodate two people.
- Deadlock occurs when two people meet on the stairs, and neither retreats.
- Livelock occurs when two people on a landing keep mirroring each other’s steps without moving forward.
- Starvation occurs when people wait on the landing for a break that never comes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Q135: How is a deadlock different from starvation?

A

A135:
- Deadlock is more serious than starvation.
- Deadlock affects the entire system and more than one job.
- All system resources become unavailable in a deadlock.
- Deadlocks are more accepted in interactive and real-time systems.
- OS must prevent or resolve deadlock situations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Q136: What is livelock in the context of system resource sharing?

A

A136: Livelock occurs when two processes on a landing keep mirroring each other’s steps without making any progress, leading to a continuous loop of actions that prevent them from moving forward

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Q137: What is starvation in the context of system resource sharing?

A

A137: Starvation occurs when processes or jobs are waiting for a resource that they never get access to, leading to them being stuck in a waiting state indefinitely.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Q138: Why do deadlocks become critical situations in interactive systems and real-time systems?

A

A138: Deadlocks become critical in these systems because they can cause the entire system to become unresponsive, affecting the timely execution of jobs and leading to potential failures or delays in real-time operations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What scenario is described in Case 1: Deadlocks on File Requests in the context of resource sharing and system deadlocks?

A

Answer:
In Case 1, multiple programs are competing for access to specific files required for execution. The scenario involves:
- Two programs, P1 and P2.
- Two files, F1 and F2.
- P1 holds access to file F1 and requires file F2 to proceed.
- P2 holds access to file F2 and requires file F1 to proceed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Question:
What scenario is described in Case 2: Deadlocks in Databases in the context of resource sharing and system deadlocks?

A

In Case 2, two processes, P1 and P2, are compeating for access to and updating of two specific records, R1 and R2, within a database. This competition leads to a deadlock due to the following sequence:
- P1 accesses and locks record R1.
- P2 accesses and locks record R2.
- P1 attempts to access record R2 but finds it locked by P2.
- P2 attempts to access record R1 but finds it locked by P1.

This scenario illustrates the risk of not implementing proper locking mechanisms, resulting in a race condition between the processes. The absence of proper locking can lead to incorrect final data versions, heavily depending on the order of process execution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What scenario is described in Case 3: Deadlocks in Dedicated Device Allocation in the context of resource sharing and system deadlocks?

A

In Case 3, two administrators, each managing separate education programs with processes P1 and P2, require access to two dedicated audio recorders, R1 and R2. Due to the limited availability of these resources, a deadlock ensues as follows:
- P1 requests and acquires audio recorder R1.
- P2 requests and acquires audio recorder R2.
- P1 subsequently requests audio recorder R2 but finds it blocked by P2.
- P2 requests audio recorder R1 but finds it blocked by P1.

This situation highlights the challenges posed by limited resource availability and the potential for deadlocks when processes compete for exclusive access to dedicated devices without proper resource management.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What scenario is described in Case 4: Deadlocks in Multiple Device Allocation in the context of resource sharing and system deadlocks?

A

In Case 4, three programs, P1, P2, and P3, are striving for access to three dedicated devices: a scanner, a printer, and a plotter. The deadlock scenario unfolds as follows:
- P1 acquires the scanner.
- P2 acquires the printer.
- P3 acquires the plotter.
- P1 subsequently requests the printer but finds it blocked by P2.
- P2 requests the plotter but finds it blocked by P3.
- P3 requests the scanner but finds it blocked by P1.

This example illustrates the complications that arise when multiple processes contend for a set of dedicated devices, leading to a deadlock due to competing resource requirements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

In Case 5: Deadlocks in Spooling, what is the scenario involving virtual and dedicated devices, the spooling process, and the resulting deadlock?

A

Case 5 discusses the issues of spooling, where a high-speed disk device acts as a virtual printer, facilitating data transfer between the CPU and the actual printer. The spooler serves as a temporary storage system, accepting output from multiple users. This output remains in the spooling system until the printer is ready to process the job data.

However, a deadlock situation arises due to the printer’s requirement to have all job outputs before initiating the printing process. As the spooling system fills up, no single job possesses its entire print output within the spooling area. **This results in incomplete output for all jobs, ultimately leading to a deadlock **where the system cannot proceed with any printing tasks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

In Case 6: Deadlocks in a Network, what scenario is presented regarding the absence of network protocols, the involved computing devices, and the resulting deadlock?

A

Case 6 illustrates a situation where there are** no network protocols** in place to control the flow of network messages. In this example, there are seven computing devices connected to the network, each residing on different nodes. The direction of the arrows in the figure indicates the communication flow between these devices.

However, a deadlock occurs when all available buffer space in the network fills up. This leads to a situation where the devices are unable to communicate further due to the lack of available buffer space, resulting in a network deadlock.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

In Case 7: Deadlocks in Disk Sharing, what is the scenario involving disk access, the conflicting commands from competing processes, and the resulting livelock?

A

Case 7 describes a scenario where competing processes send conflicting commands for disk access, leading to a livelock situation. In this example, there are two processes, each waiting for an I/O request. One process is positioned at Track 20, while the other is at Track 310. The deadlock sequence unfolds as the disk arm moves back and forth between Tracks 20 and 310, attempting to fulfill the conflicting commands from the two processes. However, due to the conflicting nature of these commands, neither I/O request is satisfied, resulting in a livelock where the processes remain in a loop without making progress.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the four necessary conditions for a system to experience deadlock or livelock?

A

The four necessary conditions for a system to experience deadlock or livelock are:

  1. Mutual Exclusion: Only one process can access a dedicated resource at a time.
  2. Resource Holding: A process holds resources and waits for other processes to release their resources.
  3. No Preemption: Resources cannot be forcibly taken away from a process; they can only be released voluntarily.
  4. Circular Wait: There exists a circular chain of processes, where each process is waiting for another process in the chain to release a resource.

All these conditions need to be present simultaneously for a deadlock or livelock to occur. To resolve deadlock, at least one of these conditions must be removed. Preventing all four conditions at the same time ensures deadlock prevention, although this can be challenging to implement.

17
Q

Describe the use of directed graphs in modeling deadlocks and provide examples of deadlock scenarios.

A

Directed graphs are utilized to model deadlocks, with circles representing processes and squares representing resources. Solid lines with arrows denote resources held by processes, while dashed lines with arrows signify processes waiting for resources. Deadlocks can occur when processes are waiting for resources held by others, leading to scenarios like Scenario Two, where deadlock occurs due to mutual resource dependency.

18
Q

In the context of modeling deadlocks, directed graphs are used to visually represent the relationships between processes and resources in a system. Circles in the graph represent processes, while squares represent resources. Solid lines with arrows indicate resources held by processes, while dashed lines with arrows represent processes waiting for resources.

A

A deadlock scenario depicted in a directed graph occurs when there is a cycle in the graph. This cycle signifies a situation where processes are waiting for resources held by other processes, creating a mutual dependency that prevents any process from progressing.

19
Q

Compare and contrast the three scenarios for detecting deadlocks in a system, as illustrated through directed graphs. What are the key differences between scenarios that result in deadlock and those that prevent it?

A

The three scenarios for detecting deadlocks in a system include scenarios where deadlock occurs and scenarios where deadlock is avoided. The key differences lie in whether resources are released before the next process requests them, preventing deadlock, or if processes are waiting for resources held by others, leading to a deadlock situation.

Resource Release Before Request (Deadlock Avoidance):

Processes Waiting for Resources Held by Others (Deadlock Occurrence):

Resource Allocation Strategies (Deadlock Prevention):

20
Q

Discuss the role of resource allocation in deadlock occurrence, considering scenarios where resources are allocated individually versus when they are grouped within processes. How does this allocation affect the likelihood of deadlock?

A

Resource allocation plays a crucial role in deadlock occurrence. When resources are allocated individually, there may be fewer opportunities for deadlock as processes can release resources before requesting additional ones. However, when resources are grouped within processes, creating mutual dependencies, the likelihood of deadlock increases as processes may become deadlocked while waiting for resources held by others.

21
Q

Describe the concept of deadlock prevention and the conditions it aims to eliminate. How does deadlock prevention differ from deadlock avoidance?

A

Deadlock prevention aims to eliminate one or more of the four necessary conditions for deadlock: mutual exclusion, resource holding, no preemption, and circular wait. It differs from deadlock avoidance in that prevention takes proactive measures to ensure that deadlocks cannot occur, whereas avoidance seeks to dynamically allocate resources in a way that avoids the possibility of deadlock.

21
Q

Explain Dijkstra’s Banker’s Algorithm for deadlock avoidance. How does it regulate resource allocation to prevent deadlock situations?

A

Dijkstra’s Banker’s Algorithm regulates resource allocation by ensuring that resources are only allocated if the system remains in a safe state. It achieves this by granting resources to processes only if the maximum resources needed by a process do not exceed the available resources in the system. This prevents deadlock by ensuring that resources are allocated in a way that allows processes to complete their execution.

The Banker’s Algorithm prevents deadlock by only allocating resources if the system can ensure all processes can eventually complete, maintaining a safe state.

22
Q

What are the assurances provided by operating systems for deadlock avoidance? Discuss the challenges and limitations associated with implementing the Banker’s Algorithm.

A

Operating systems provide assurances for deadlock avoidance by ensuring that resource requests are granted only if the system can guarantee that deadlock will not occur. The Banker’s Algorithm faces challenges such as the need for processes to declare their maximum resource needs, a fixed number of resources for each resource class, and the assumption of worst-case scenarios, which may result in inefficient resource utilization and scheduling issues.

Operating systems ensure deadlock avoidance by granting resource requests only if they can guarantee the system will remain deadlock-free, but implementing the Banker’s Algorithm is challenging due to the

need for processes to declare maximum resource needs,

fixed resource quantities,

potential resource underutilization, and the

complexity of continuous safety checks.

23
Q

Outline the process of deadlock detection using directed resource graphs. How does the detection algorithm identify and resolve deadlock situations?

A

Deadlock detection involves building directed resource graphs and looking for cycles within them. The detection algorithm identifies processes involved in deadlock by removing processes that are not waiting for any resources or processes that are waiting for resources that are not fully allocated. Once deadlock is detected, various recovery methods can be employed to resolve the situation, such as terminating involved jobs or preempting resources.

24
Q

Discuss various methods for deadlock recovery once deadlock is detected. What factors should be considered when selecting a victim for termination in the recovery process?

A

Deadlock recovery methods include

terminating all involved jobs,

restarting jobs from the beginning,

selectively terminating only the jobs involved in deadlock.

Factors to consider when selecting a victim for termination include
job priority,

CPU time used,

number of other jobs affected,

whether the job is modifying critical data.

25
Q

What is starvation, and how does it occur in a computing system? Provide an example scenario illustrating starvation. Additionally, discuss a method for starvation avoidance mentioned in the context of the Dining Philosophers Problem.

A

Starvation in a computing system refers to a situation where a job or process is prevented from execution because it is waiting for resources that never become available. This often occurs due to conservative resource allocation strategies. For example, in the Dining Philosophers Problem, philosophers may starve if they cannot acquire all necessary resources (forks) simultaneously, leading to deadlock or starvation.