9 Operating System Management

Introduction to Information Technology · Unit 9

Operating System Management

Exam-focused notes for Operating System Management (Introduction to Information Technology, BIT101): what the TU syllabus asks and how it has actually been tested, with 3 solved past questions from this unit.

Operating System Management in short

The operating system must decide which task gets the CPU, handle problems when tasks wait on each other, and manage memory addresses. This unit covers those core ideas.

Operating System Management: notes

Process scheduling concepts

A process is a program in execution. Process scheduling is the method the OS uses to choose which process gets the CPU next. It is needed because there are many processes but usually one CPU.

A process moves through states: new, ready, running, waiting (blocked), and terminated. The scheduler picks from the ready queue.

Key terms:

  • Arrival time: when the process enters the ready queue.
  • Burst time: CPU time the process needs.
  • Completion time: when it finishes.
  • Turnaround time: completion time minus arrival time.
  • Waiting time: turnaround time minus burst time.
  • Response time: time from arrival to first use of the CPU.

Goals: high CPU use, high throughput, low waiting time, low turnaround time, and fairness.

Non-preemptive scheduling

In non-preemptive scheduling, once the CPU is given to a process, it keeps it until it finishes or waits for input or output. The OS cannot take the CPU away.

Examples:

  • First Come First Served (FCFS): processes run in order of arrival.
  • Shortest Job First (SJF): the process with the smallest burst time runs first.

Worked example of FCFS. Three processes arrive at time 0 with burst times P1 = 5, P2 = 3, P3 = 2.

ProcessBurstCompletionTurnaroundWaiting
P15550
P23885
P3210108

$$\text{Average waiting time} = \frac{0+5+8}{3} = 4.33$$

If SJF is used, the order is P3, P2, P1. Waiting times are 0, 2, and 5, and the average is $\frac{0+2+5}{3} = 2.33$. SJF gives the lowest average waiting time but long jobs may wait too long (starvation).

Advantages of non-preemptive: simple and little switching cost. Disadvantage: one long process can delay all the others.

What this unit covers

  • Process scheduling concepts
  • Non-preemptive scheduling
  • Preemptive scheduling
  • Deadlock definition and reasons
  • Physical and logical address concepts

Deadlock definition and reasons

2080 · 5 marks

What is Deadlock? What are the reasons for deadlock? [5]

Show solved answer

Deadlock

Definition

A deadlock is a situation in which a set of processes are blocked permanently because each process in the set is waiting for a resource that is held by another process in the same set. As a result, none of the processes can proceed, and they remain in a waiting state indefinitely.

Example: Process P1 holds Resource R1 and waits for R2, while Process P2 holds R2 and waits for R1. Neither can proceed.


Reasons for Deadlock (Necessary Conditions)

Deadlock can occur if and only if all four of the following conditions hold simultaneously (Coffman Conditions, 1971):

1. Mutual Exclusion

  • At least one resource must be held in a non-shareable mode.
  • Only one process can use the resource at a time.
  • If another process requests that resource, it must wait.

2. Hold and Wait

  • A process is holding at least one resource and is waiting to acquire additional resources that are currently held by other processes.

3. No Preemption

  • Resources cannot be forcibly taken away from a process holding them.
  • A resource can only be released voluntarily by the process holding it after it has completed its task.

4. Circular Wait

  • A set of processes {P0, P1, P2, ..., Pn} exists such that:
    • P0 is waiting for a resource held by P1
    • P1 is waiting for a resource held by P2
    • ...
    • Pn is waiting for a resource held by P0
  • This forms a circular chain of waiting processes.

Summary Table

ConditionDescription
Mutual ExclusionResource held by only one process at a time
Hold and WaitProcess holds resource while waiting for more
No PreemptionResource cannot be forcibly taken away
Circular WaitCircular chain of processes waiting for each other

Key Point: All four conditions must hold simultaneously for a deadlock to occur. Preventing even one of these conditions is sufficient to prevent deadlock.

Open this answer on its own page →

Physical and logical address concepts

2080 · 5 marks

Explain about Physical address and Logical address. [5]

A logical address is the address generated by the CPU during program execution. It is the address that a running program "sees" and uses to reference memory locations. Key characteristics: - Generated by the CPU - Also called virtual address - Does not directly correspond to a physical location i...

Open this answer on its own page →

Process scheduling concepts

2078 · 5 marks

What is scheduling? Explain Non Pre.-emptive scheduling and Pre-emptive scheduling. [5]

Scheduling is the process by which the operating system decides the order in which processes are allocated CPU time. The CPU scheduler selects a process from the ready queue and allocates the CPU to it. The main goal of scheduling is to maximize CPU utilization, throughput, and to minimize waitin...

Open this answer on its own page →