Skip to main content

Chapter 02 · Watch, then practise

Process Management

Watch the related lecture, then read the question and answer below.

8 questions · 15 playlist videos. Matches are based on video titles; broader background matches are labeled.

Open the full chapter playlist ↗

Topic matches: two-state process model and process-state transitions.

1. Process and process models

Define process. Explain the process model along with the transitions.

Answer

A process is an entity representing the basic unit of work to be implemented in the system; a process is a program in execution.

Two-state model

  • Running: The process is running on the CPU.
  • Not running: The process is not running on the CPU.

When a new process P2 is created, it is in the not-running state. When the CPU becomes free, the dispatcher gives control of the CPU to P2, which is waiting in the queue. The dispatcher is a program that gives control of the CPU to the process selected by the CPU scheduler. When the dispatcher allows P2 to execute, P2 starts its execution.

Five-state model

  1. New: A process that has just been created but has not yet been admitted to the pool of executable processes by the OS.
  2. Ready: A process prepared to execute when given the opportunity; it is waiting only for CPU availability.
  3. Running: The process currently being executed.
  4. Blocked (waiting): A process that cannot execute until an event occurs.
  5. Exit: A process released from the pool of executable processes by the OS.

The two original transition diagrams, including their arrow labels, are preserved here:

Original two-state and five-state process diagrams

Topic match: processes versus threads.

2. Process versus thread

Differentiate between process and thread.

Answer

ProcessThread
Does not share memory; loosely coupled.Shares memory and files; tightly coupled.
Creation is time-consuming.Creation is fast.
Execution is slow.Execution is fast.
Takes more time to terminate.Takes less time to terminate.
Takes more time to switch between processes.Takes less time to switch.
System calls are required for communication.System calls are not required for communication.
Requires more resources.Requires fewer resources.
Not suitable for parallelism.Suitable for parallelism.

Source fidelity: This reproduces the source's broad comparisons, including its claim about process parallelism; it is not a corrected technical comparison.

Topic matches: context switching and the process control block that stores process state.

3. Context switching

What is context switching? Explain the process with an example.

Answer

Context switching is the mechanism to store and restore the state or context of a CPU in a process control block so that execution can resume from the same point later. It enables multiple processes to share a single CPU.

When the scheduler switches the CPU from one process to another, the state of the current process is stored in its control block. The state of the next process is loaded from its PCB and used to set the program counter, registers, and other state. The second process can then start executing.

The source diagram shows the queue changing from B, F, D, G, A to F, D, G, A, B:

Original context-switching diagram and comparison tables

Topic match: user-level versus kernel-level threads.

4. User-level versus kernel-level threads

Differentiate between user-level threads and kernel-level threads.

Answer

User-level threadKernel-level thread
Faster to create and manage.Slower to create and manage.
Implemented by a thread library at user level.The operating system supports creation of kernel threads.
Generic and can run on any OS.Specific to the OS.
Multithreaded applications cannot take advantage of multiprocessing.Kernel routines themselves can be multithreaded.

Source fidelity: The last two rows are retained as written in the notes, rather than generalized or corrected.

No dedicated scheduler-types or dispatcher video is listed in the supplied chapter playlist.

5. Scheduling, schedulers, and dispatcher

Define scheduling. Explain a scheduler and its types. Define dispatcher.

Answer

Scheduling: The activity of the process manager that removes the running process from the CPU and selects another process according to a particular strategy.

Scheduler: Special system software that handles process scheduling. Its main tasks are selecting jobs to submit to the system and deciding which process to run.

  • Long-term scheduler: Decides the priority in which processes must be placed in main memory. The notes describe these processes as entering the ready state and waiting for execution by the CPU.
  • Mid-term scheduler: Places blocked and suspended processes in secondary memory.
  • Short-term scheduler: Decides the priority in which processes in the ready queue receive CPU time.

Dispatcher: The module that gives control of the CPU to the process selected by the short-term scheduler from the processes ready to execute.

Covers arrival, burst, waiting, and turnaround times. Coverage of utilization, throughput, and response time has not been verified.

6. Scheduling terms

Define the following terms.

Answer

  • CPU utilization: Keeping the CPU as busy as possible. The source gives a theoretical range of 0%-100% and a practical range of 40%-90%; these are source statements, not measurements of this project.
  • Throughput: The rate at which processes complete per unit time.
  • Turnaround time: The difference between completion time and submission time.
  • Waiting time: The sum of periods spent waiting in a queue.
  • Response time: The time from submission until the process starts responding.
  • Burst time: The duration for which a process gets control of the CPU.

Related examples of non-preemptive SJF and preemptive shortest-remaining-time scheduling; not a dedicated comparison lecture.

7. Preemptive versus non-preemptive scheduling

Differentiate between preemptive and non-preemptive scheduling.

Answer

Preemptive schedulingNon-preemptive scheduling
Resources are allocated to a process for a limited time.A process holds allocated resources until its burst completes or it switches to a waiting state.
A process can be interrupted during execution.A process cannot be interrupted until it terminates or switches to a waiting state.
Has scheduling overhead.The source states that it does not have overhead.
Flexible.Rigid.

Algorithm demonstrations for the worked calculations. The videos use their own examples; they are not verified solutions to the scanned data sets. The priority lecture is specifically preemptive.

8. CPU scheduling calculations

Calculate average turnaround time and average waiting time using FCFS, SJN, SRTN, priority, round-robin, and HRRN scheduling for the data sets in the source.

Answer

The original input tables, time quanta, Gantt charts, intermediate formulas, corrections, and final results are retained below. They have not been recomputed or silently corrected. The source uses different quanta in different examples; read the value beside each example.

FCFS calculations

Original handwritten solution

FCFS and SJN calculations

Original handwritten solution

SJN calculations

Original handwritten solution

SJN, priority, and round-robin calculations

Original handwritten solution

Round-robin calculations

Original handwritten solution

Round-robin and HRRN calculations

Original handwritten solution

HRRN calculations

Original handwritten solution

HRRN and SRTN calculations

Original handwritten solution

SRTN calculations — continued

Original handwritten solution

SRTN calculations — continued

Original handwritten solution

SRTN calculations — continued

Original handwritten solution

More videos from this chapter’s playlist

These playlist videos do not have a direct match among the questions above.