solution - Operating System : Process Management (Test 3)

Question : Which component selects a process from the ready queue to run?

Solution :
25520260310071920 Correct Answer : Scheduler

Description -

The correct answer is Scheduler (specifically, the CPU Scheduler or Short-Term Scheduler).

The CPU scheduler is a core component of the operating system responsible for selecting which process from the Ready queue should be allocated CPU time next. It uses scheduling algorithms (such as Round Robin, Priority Scheduling, or Shortest Job First) to make these decisions, referencing attributes like Priority and Process State stored within each process's PCB.

Breakdown of Other Options

  • Compiler: Translates high-level source code into machine code before execution.
  • Loader: Copies programs from storage (like a disk) into the main memory (RAM) so they can start running.
  • Linker: Combines various object code files and libraries into a single executable file.

Question : Which scheduler selects processes from the job pool in secondary memory?

Solution :
790320260310071445 Correct Answer : Long-term scheduler

Description -

The correct answer is Long-term scheduler.

The long-term scheduler (also widely referred to as the Job Scheduler) is responsible for selecting processes from the job pool—which resides in mass storage or secondary memory (like a disk)—and loading them into the main memory (RAM).

By determining which programs are admitted into the system's primary execution space, the long-term scheduler directly controls the degree of multiprogramming (the number of processes present in memory at one time). It operates less frequently compared to other schedulers, executing only when a process completes and exits the system, creating room for a new job.

Breakdown of Other Schedulers

  • Short-term scheduler (CPU Scheduler): Selects a process that is already loaded in the main memory's ready queue and allocates the physical CPU to execute it. It operates exceptionally fast and runs every few milliseconds.
  • Medium-term scheduler (Swapper): Handles swapping processes between the main memory and secondary storage. It temporarily pulls processes out of memory ("swaps out") to free up space when RAM becomes overly congested.
  • I/O scheduler: Manages and reorders the physical read/write data requests waiting on input/output devices to maximize disk efficiency.

Question : Which scheduler is responsible for swapping processes in and out of memory?

Solution :
647120260310071254 Correct Answer : Medium-term scheduler

Description -

The correct answer is Medium-term scheduler.

The medium-term scheduler (also known as the Swapping Scheduler) is explicitly designed to handle the moving of processes between the main memory (RAM) and secondary storage (such as a disk swap space).

When the main memory becomes overly congested, the medium-term scheduler frees up RAM by removing a process from active execution ("swapping out"). It holds that partially executed process in secondary storage until memory resources clear up or the process's blocked I/O completes. It then brings the process back into RAM ("swapping in") so it can resume exactly where it left off. By doing this, it dynamically adjusts and reduces the degree of multiprogramming when system load is high.

Summary Comparison of the Three Main Schedulers

Scheduler Type

Also Known As

Primary Location of Operation

Main Responsibility

Speed

Long-term

Job Scheduler

Secondary Memory \(\rightarrow \) Main Memory

Selects new jobs to load into RAM; controls the initial degree of multiprogramming.

Slowest

Medium-term

Swapping Scheduler

Main Memory \(\leftrightarrow \) Secondary Memory

Swaps processes in and out of memory to free up RAM space.

Medium

Short-term

CPU Scheduler

Ready Queue \(\rightarrow \) CPU core

Selects which ready process gets to execute on the CPU core next.

Fastest

Question : The medium-term scheduler mainly helps in:

Solution :
954420260310071205 Correct Answer : Swapping processes

Description -

The correct answer is Swapping processes.

The medium-term scheduler is a memory management component that specializes in swapping processes between the main memory (RAM) and secondary memory (such as a hard drive or SSD swap space).

When a system's RAM becomes heavily crowded, this scheduler steps in to temporarily pause a process, remove it from memory, and write its active state data out to disk. This frees up crucial RAM space for other active operations. Once the system load decreases, the medium-term scheduler swaps that process back into RAM so it can seamlessly resume execution.

Breakdown of Other Options

  • CPU allocation: This is the job of the short-term scheduler (CPU scheduler), which decides which ready process gets CPU time next.
  • Disk scheduling: This is handled by the I/O scheduler inside the operating system to optimize read/write speeds for hardware storage.
  • Process termination: This is triggered either by the program completing its sequence naturally or by the operating system kernel when handling a fatal error or a force-kill command.

Question : Which scheduler reduces the degree of multiprogramming?

Solution :
883620260310071047 Correct Answer : Medium-term scheduler

Description -

The correct answer is Medium-term scheduler.

The degree of multiprogramming refers to the total number of processes currently residing in the main memory (RAM).

When the main memory becomes heavily congested or low on resources, the medium-term scheduler steps in to temporarily remove partially executed processes from RAM and write them to secondary storage (disk). This process is known as swapping out. By moving active processes out of memory, it directly reduces the degree of multiprogramming to optimize system stability and clear up memory space.

Differentiating the Core Schedulers

  • Long-term scheduler: Controls and sets the initial degree of multiprogramming by deciding how many new jobs are allowed into the RAM ready queue in the first place. It does not actively reduce it mid-execution.
  • Short-term scheduler: Provides minimal to no control over the degree of multiprogramming. Its sole responsibility is rapidly allocating the CPU to processes already waiting inside the ready queue.

Question : The short-term scheduler selects processes from:

Solution :
958020260310071001 Correct Answer : Ready queue

Description -

The correct answer is Ready queue.

The short-term scheduler (also known as the CPU Scheduler) is responsible for allocating physical CPU time to processes. It selects a process directly from the Ready queue—which contains all the active processes currently loaded into the main memory (RAM) that are fully prepared and waiting to execute. Because CPU allocation happens continuously every few milliseconds, this scheduler operates at exceptionally high speeds.

Breakdown of the Other Options

  • Job pool / Secondary memory: This is where programs sit on the hard disk or SSD before execution. The long-term scheduler is responsible for selecting items from here to move them into RAM.
  • Device queue: This queue holds processes that are blocked and waiting for an input/output (I/O) device to complete a request (like a file read or keyboard input).

Question : The long-term scheduler selects processes from:

Solution :
132920260310070848 Correct Answer : Job pool in secondary storage

Description -

The correct answer is Job pool in secondary storage.

The long-term scheduler (also known as the Job Scheduler) is responsible for controlling the initial entry of programs into the main memory system.

When a large number of programs are submitted to a system, they are placed in a job pool within secondary storage (such as a hard drive or SSD). The long-term scheduler reviews this pool, selects which processes should be initialized, and moves them into the main memory's ready queue to be executed. This allows it to directly control the degree of multiprogramming.

Breakdown of the Other Options

  • Ready queue: This is where processes wait in the main memory (RAM) for CPU allocation. The short-term scheduler pulls from here.
  • CPU queue: A conceptual reference to the ready queue where jobs line up for processor time.
  • Device queue: This queue holds processes that are currently blocked because they are waiting for an I/O device (like a printer or disk read) to respond.

Question : Which of the following is responsible for suspending and resuming processes?

Solution :
944720260310070754 Correct Answer : Medium-term scheduler

Description -

The correct answer is Medium-term scheduler.

The medium-term scheduler (also known as the swapping scheduler) is directly responsible for suspending and resuming processes.

When the system's main memory (RAM) becomes over-crowded, this scheduler chooses an active process to temporarily halt and remove from memory. This action is called swapping out or suspending the process. Once memory becomes available again or the process finishes waiting for a resource, the medium-term scheduler brings it back into memory—a process called swapping in or resuming—allowing it to pick up exactly where it was paused.

Breakdown of Other Options

  • Short-term scheduler: Does not swap or suspend processes; it rapidly selects a process that is already in the main memory's ready queue and gives it immediate CPU time.
  • Long-term scheduler: Manages the very initial entry of a process from the disk's job pool into memory. It does not manage mid-execution suspensions.
  • Dispatcher: Responsible for loading the process chosen by the short-term scheduler onto the CPU by performing context switching.

Question : Which scheduling type allows the OS to interrupt a running process?

Solution :
723620260310070624 Correct Answer : Preemptive scheduling

Description -

The correct answer is Preemptive scheduling.

In preemptive scheduling, the operating system kernel retains ultimate control over the CPU core. The OS has the authority to forcibly pause or interrupt a currently running process mid-execution, save its state into its Process Control Block (PCB), and allocate the CPU to a different process.

These forced context switches typically occur due to:

  • Time-sharing policies: A fixed execution window (time quantum) expires, as seen in the Round Robin algorithm.
  • Priority rules: A higher-priority process transitions into the ready queue, meaning the lower-priority running job must step aside.

Breakdown of Other Options

  • Non-preemptive scheduling: Once a process is allocated the CPU, it holds it exclusively. The OS cannot forcibly interrupt it; the process will run continuously until it either voluntarily yields control (like requesting I/O) or fully completes execution and terminates.
  • Batch scheduling: An old or specialized processing framework where a set of jobs are collected and run sequentially without interactive user intervention.
  • Sequential scheduling: A generic description of handling jobs one after another in exact sequence, lacking an interrupt mechanism.

Question : In non-preemptive scheduling:

Solution :
415320260310070532 Correct Answer : Process runs until completion or blocking

Description -

The correct answer is Process runs until completion or blocking.

In non-preemptive scheduling, once the operating system allocates the CPU to a specific process, that process holds onto the CPU exclusively. The operating system cannot forcibly interrupt or take the CPU away from it.

The process will continue running uninterrupted until it either:

  1. Completes its execution and naturally terminates.
  2. Blocks itself voluntarily, such as by requesting an I/O operation (like waiting for a file download or keyboard input) or waiting for an event.

Breakdown of Incorrect Options

  • CPU can be taken from a running process anytime: This describes preemptive scheduling, not non-preemptive.
  • OS always interrupts processes: The OS explicitly avoids interrupting processes in this model.
  • CPU runs only one process forever: The CPU will switch to a different process as soon as the current one finishes or blocks. It does not stay locked on one process forever.

Question : Which scheduler ensures a good mix of CPU-bound and I/O-bound processes?

Solution :
490020260310070429 Correct Answer : Long-term scheduler

Description -

The correct answer is Long-term scheduler.

The long-term scheduler (Job Scheduler) is responsible for selecting processes from the job pool in secondary storage and loading them into the main memory (RAM).

To maximize system efficiency and resource utilization, it tries to maintain a balanced mix of CPU-bound and I/O-bound processes:

  • CPU-bound processes spend most of their time doing heavy computations and utilizing the CPU.
  • I/O-bound processes spend most of their time waiting for input/output devices (like disk reads or network data) and use very little CPU.

If the long-term scheduler selects only CPU-bound processes, the ready queue will stay full, but the I/O devices will sit completely idle. If it selects only I/O-bound processes, the device queues will get congested while the CPU sits idle. By creating a good mix, it ensures both the CPU core and the hardware peripherals are working simultaneously, keeping system throughput high.

Why Other Options Do Not Balance the Mix

  • Short-term scheduler: Simply selects whatever is already waiting in the ready queue to run next; it does not control which new jobs are admitted into memory.
  • Medium-term scheduler: Focuses entirely on swapping processes in and out of RAM to manage memory saturation, rather than choosing the initial operational mix of jobs.
  • I/O scheduler: Focuses strictly on reordering block read/write requests on the storage disk to reduce mechanical or interface latency.

Question : Context switching occurs when:

Solution :
766620260310070332 Correct Answer : CPU switches from one process to another

Description -

The correct answer is CPU switches from one process to another.

A context switch is the core procedure where the operating system kernel stops running one active process on a CPU core and starts running another.

To make this swap safely without losing progress, the OS performs two crucial actions:

  1. It saves the current context (including the program counter, CPU registers, and state memory) of the running process into its own Process Control Block (PCB).
  2. It loads the saved context of the next process from its PCB into the CPU registers so it can resume execution seamlessly.

Breakdown of Other Options

  • A process moves from disk to memory: This is known as loading or swapping in, managed by the long-term or medium-term scheduler.
  • Memory allocation changes: This relates to memory management processes (like paging or segmentation adjustments), which don't inherently require a process-to-process CPU swap.
  • I/O device completes operation: This generates an I/O interrupt, which frequently triggers a context switch afterward, but the completed operation itself is not a context switch.

Question : Context switching stores process information in:

Solution :
147220260310070237 Correct Answer : Process Control Block (PCB)

Description -

The correct answer is Process Control Block (PCB).

During a context switch, the operating system pauses a running process and must save its exact execution state so it can return to it later without losing progress. It saves this operational data (including the program counter, general-purpose registers, process state, and memory limits) directly into the process's Process Control Block (PCB). The PCB acts as the official repository in main memory for a process's metadata.

Breakdown of Other Options

  • Cache memory / Register stack: The physical registers and cache inside the CPU are what the process uses while it is actively running. During a context switch, data is cleared out of these hardware components and moved to the PCB in RAM.
  • Disk buffer: A temporary holding space in memory used to optimize data transfers to and from secondary storage (like a hard drive), rather than storing active process states.

Question : Which scheduler is mainly involved in time-sharing systems?

Solution :
246220260310070141 Correct Answer : Medium-term scheduler

Description -

The correct answer is Medium-term scheduler.

In a time-sharing system, the primary objective is to provide quick response times to multiple interactive users or programs sharing the CPU concurrently. Because many processes compete for active memory simultaneously, the system can easily run out of physical RAM.

To handle this, time-sharing systems introduce an intermediate level of scheduling called the medium-term scheduler. It manages the swapping of processes in and out of main memory:

  • Swapping Out (Suspending): When RAM becomes heavily congested or a process gets temporarily blocked waiting for interactive user I/O, this scheduler removes the process from memory and stores it in secondary storage (disk).
  • Swapping In (Resuming): Once memory frees up or the process's I/O event finishes, it reintroduces the process back into RAM so it can continue execution seamlessly.

This active management of memory saturation makes the medium-term scheduler uniquely central to the stability of time-sharing systems.

Role of Other Schedulers

  • Long-term scheduler: Often completely absent or minimal in modern time-sharing systems because programs are admitted directly into memory upon launch rather than sitting in a job queue.
  • Short-term scheduler: Rapidly switches the CPU among processes already waiting in the ready queue, but it relies entirely on the medium-term scheduler to keep the right processes in RAM.
  • Batch scheduler: A type of long-term scheduler optimized specifically for non-interactive batch systems rather than interactive time-sharing systems.

Question : A process moved to secondary memory due to lack of RAM is in:

Solution :
46920260310070000 Correct Answer : Suspend Ready state

Description -

The correct answer is Suspend Ready state.

When a process is fully ready to run but the operating system faces a severe lack of RAM, the medium-term scheduler temporarily removes the process from main memory and moves it to secondary memory (disk storage). This technique is known as swapping out.

Because the process was already prepared to execute (was in the Ready state) before being swapped out to free up RAM, its new state becomes Suspend Ready (or Swapped Ready). Once enough RAM becomes available, the OS will swap it back into main memory and return it to the normal Ready state.

Breakdown of the Other States

  • Ready state: The process is fully prepared to execute, but it must be residing in the main memory (RAM), not secondary storage.
  • Running state: The process's instructions are currently being executed directly by a CPU core.
  • Waiting state: The process is in RAM but is blocked because it is waiting for an external I/O event (like a keystroke or file read) to finish. (If it were moved to secondary memory while waiting, it would enter the Suspend Wait state).

Question : Which operation moves a blocked process back to the ready queue?

Solution :
394820260310065830 Correct Answer : Resumption

Description -

The correct answer is Resumption.

When a process is in the Blocked (or Waiting) state, it cannot execute because it is waiting for an external event to finish, such as a file loading from a disk or keyboard input from a user.

  • Resumption occurs after the blocking event completes (e.g., the I/O device sends an interrupt signaling it is done). The operating system then wakes the process up, shifts its state from Blocked back to Ready, and moves its Process Control Block (PCB) back into the Ready queue so it can wait for CPU time again.

Breakdown of Other Options

  • Scheduling: This operation selects a process that is already in the ready queue and allocates the CPU to it, moving it from the Ready state to the Running state.
  • Termination: This deletes the process and frees up all of its allocated system resources once execution is finished or aborted.
  • Blocking: This is the opposite operation—it moves an actively executing process from the Running state into the Blocked/Waiting state when it makes an I/O request.

Question : Which operation creates a new process in the system?

Solution :
535420260310065722 Correct Answer : Creation

Description -

The correct answer is Creation (often referred to as Process Creation or spawning).

Creation is the explicitly designated operating system operation that initializes and spawns a new process in the system. During this operation, the operating system allocates a unique Process ID (PID), sets up its initial memory space (Text, Data, Heap, and Stack segments), and builds a brand new Process Control Block (PCB) to track its lifecycle. In modern operating systems like Unix/Linux, this is commonly triggered by system calls like fork() or exec().

Breakdown of Other Options

  • Execution: This is the phase where an already created process runs its machine instructions on the physical CPU core.
  • Scheduling: This action selects an existing process from the ready queue and hands it CPU time.
  • Resumption: This moves an existing process back to an active state (like moving it from a suspended state back into the ready queue).

Question : Which operation selects the next process to execute?

Solution :
308920260310065632 Correct Answer : Scheduling

Description -

The correct answer is Scheduling.

Scheduling (specifically managed by the operating system's CPU scheduler) is the definitive operation that selects the next process from the ready queue to execute on the CPU. It evaluates available processes using specific scheduling criteria—such as process priority, arrival order, or remaining execution time—to determine which task gets processor access next.

Breakdown of Other Options

  • Creation: The operation responsible for initializing a program, generating its unique Process ID (PID), and constructing its Process Control Block (PCB). It does not choose what runs next.
  • Blocking: The event that pauses an actively running process and moves it out of the CPU queue because it is waiting for an external event (like user input or an I/O operation).
  • Deletion (or Termination):

The cleanup operation that closes a process out of system memory and frees up its allocated hardware resources.

Question : When a process waits for an event or resource, the OS performs:

Solution :
138020260310065542 Correct Answer : Blocking

Description -

The correct answer is Blocking.

When an actively executing process reaches a point where it cannot continue without an external event or resource—such as waiting for a user to press a key, reading a file from a disk, or waiting for a network packet—it cannot use the CPU efficiently.

To prevent the CPU from sitting idle, the operating system performs a Blocking operation. The OS changes the process's state from Running to Waiting (or Blocked), moves its Process Control Block (PCB) out of the ready queue and into a device/event queue, and reallocates the CPU core to a different process that is ready to run.

Breakdown of Other Options

  • Scheduling: This is the opposite action, where the OS selects a prepared process from the ready queue and moves it into the execution slot.
  • Deletion: This permanently terminates a process and releases all of its system resources back to the pool.
  • Execution: This is the active state where the CPU is actively processing the machine instructions of a running application.

Question : The deletion of a process is also called:

Solution :
327720260310065505 Correct Answer : Killing/Termination

Description -

The correct answer is Killing/Termination.

The deletion of a process refers to the operation where a process completes its final instruction or is forcibly stopped by the system. The operating system kernel officially names this phase termination (or killing the process).

During this operation, the OS performs critical cleanup tasks:

  • It deallocates all physical main memory (RAM) used by the process.
  • It closes all open file descriptors and frees up hardware devices listed in the process's PCB.
  • It deletes the Process Control Block (PCB) entirely from the system records.

Breakdown of Other Options

  • Creation: The initial operation that instantiates a process, assigns a PID, and constructs the PCB.
  • Scheduling: The process of selecting which ready task gets access to the CPU core next.
  • Blocking: The operation that pauses a running process and puts it into a waiting state while it waits for an external event.

Question : Context switching refers to:

Solution :
600720260310065345 Correct Answer : Switching CPU from one process to another

Description -

The correct answer is Switching CPU from one process to another.

A context switch is the fundamental operating system procedure where the kernel stops running one active process on a CPU core and begins running another.

To execute this swap safely without losing progress, the OS performs two critical steps:

  1. It saves the current context (including the program counter, CPU register states, and memory flags) of the running process into its designated Process Control Block (PCB).
  2. It loads the saved context of the incoming process from its PCB into the physical CPU hardware registers, allowing it to resume execution seamlessly.

Breakdown of Other Options

  • Switching memory: While context switching requires updating memory mapping tables (like pointers to page tables), the core objective is changing which process controls the CPU, not merely altering memory allocations.
  • Changing process priority: This is a dynamic update to a process's scheduling metadata within the PCB, often handled by aging policies or system calls, not a context switch.
  • Deleting a process: This is known as process termination or killing, which involves cleaning up and destroying the PCB entirely.

Question : Which structure stores process information like state and scheduling data?

Solution :
451020260310065310 Correct Answer : Process Control Block

Description -

The correct answer is Process Control Block.

The Process Control Block (PCB) (also known as a task control block) is the primary data structure used by the operating system kernel to store all the information associated with a specific process. Whenever a process is created, the OS allocates a dedicated PCB for it to track its complete execution metadata, including:

  • Process state: (New, Ready, Running, Waiting, Terminated)
  • Scheduling data: (Process priority, pointers to scheduling queues)
  • Execution context: (Program counter, CPU registers)
  • Resource management: (Memory limits, open file lists, I/O device allocations)

Breakdown of Other Options

  • Stack: A memory segment reserved within the process's own address space used to store temporary execution data, such as local variables, function parameters, and return addresses.
  • Heap: A memory region used for dynamic memory allocation at runtime (e.g., using malloc() or new), which is requested by the program code itself.
  • Register: Small, ultra-fast storage cells located directly inside the physical CPU hardware that hold data actively being processed; they do not store comprehensive OS scheduling metadata.

Question : When a process goes from running to waiting state, the CPU:

Solution :
391420260310065214 Correct Answer : Is assigned to another process

Description -

The correct answer is Is assigned to another process.

When a process transitions from the Running state to the Waiting (or Blocked) state, it is because the process has requested an event that takes time to complete—such as waiting for user input, reading data from a disk, or downloading a file.

Because the current process cannot do any more work until that external event finishes, the operating system kernel steps in to maximize system efficiency. The OS performs a context switch: it saves the waiting process's current progress into its Process Control Block (PCB) and immediately assigns the CPU core to another process from the Ready queue that is fully prepared to execute. This ensures the processor stays busy and doesn't waste computing power.

Breakdown of Incorrect Options

  • Stops working / Shuts down: Operating systems are built to keep the CPU working as close to 100% efficiency as possible. The hardware will not sit idle or shut down simply because one application is waiting for a resource.
  • Executes the same process: The current process is blocked and literally cannot execute any further instructions until its requested resource becomes available.

Question : A process can move from waiting to ready when:

Solution :
107720260310065052 Correct Answer : Resource becomes available

Description -

The correct answer is Resource becomes available.

A process enters the Waiting (or Blocked) state because it is explicitly waiting for an external event to finish or a specific system resource to be released—such as an I/O operation completing, a file finish downloading, or a printer becoming free.

The moment that requested resource becomes available or the event occurs, the hardware sends an interrupt to the operating system. The OS then updates the process's state from Waiting back to Ready and moves its Process Control Block (PCB) into the Ready queue. This signals that the process has everything it needs to execute and is simply waiting for its turn on the CPU.

Breakdown of Other Options

  • CPU becomes idle: When the CPU becomes idle, it triggers the short-term scheduler to pick a process already inside the ready queue and move it to the Running It does not pull a process directly out of the waiting queue.
  • Process terminates: This operation clears a process out of memory entirely and deletes its PCB.
  • New process is created: This places a brand-new process into the system lifecycle, moving it into the Ready state from the New It has no effect on existing blocked processes.

Question : Which state occurs only once in the lifetime of a process?

Solution :
37620260310064958 Correct Answer : New and Terminated

Description -

The correct answer is New and Terminated.

A process state represents a phase in its execution timeline. While a process can cycle between the Ready, Running, and Waiting states hundreds or thousands of times during its execution, the creation and deletion phases are strictly non-repeatable milestones:

  • New: This state occurs exactly once at the very beginning when the operating system initially instantiates the process, assigns its unique PID, and constructs its Process Control Block (PCB).
  • Terminated (or Exit): This state occurs exactly once at the very end when the process finishes its execution sequence or is killed. The OS strips away its allocated resources, permanently deletes its PCB, and removes it from the system registry.

Breakdown of Cycle-Based States

  • Ready, Running, and Waiting: These states make up the active execution cycle. In any time-sharing or preemptive scheduling operating system, a single process will repeatedly transition back and forth through these states as its time slice expires or as it requests and finishes I/O operations.