#C12936. Multi-Level Process Scheduler Simulation

    ID: 42418 Type: Default 1000ms 256MiB

Multi-Level Process Scheduler Simulation

Multi-Level Process Scheduler Simulation

You are required to simulate a multi-level process scheduler. In this simulation, each process is characterized by a unique process ID (pid), an initial priority (0, 1, or 2), and a burst time. The scheduler manages processes using three separate queues according to their priorities. At each scheduling round, a fixed number of processor slots (given by the input) are used to execute processes concurrently. Each process is executed for a single time quantum and on execution, its burst time is decremented by 1. If a process is not completed (i.e. its remaining burst time is still positive), it is reinserted into a queue with a lowered priority (i.e. priority increases by one; however, the maximum priority level is 2). Every time a process is executed, a message in the exact format Executing Process PID=X (where X is the process ID) should be printed on a new line. The simulation continues until all processes complete their execution.

Note: Although the simulation is meant to mimic concurrent scheduling, the execution order is determined sequentially by always selecting the process from the non-empty queue with the highest priority (lowest numeric value) first.

inputFormat

The input is read from standard input (stdin) and is formatted as follows:

  • The first line contains a single integer p representing the number of processors.
  • The second line contains a single integer n indicating the number of processes.
  • The next n lines each contain three space-separated integers: pid (the process ID), priority (an integer 0, 1, or 2 where a lower value means higher priority), and burst_time (the total number of time quanta required for the process to complete).

outputFormat

The output is written to standard output (stdout). For every time quantum a process is scheduled, output a line exactly in the format:

Executing Process PID=X

where X is the process's ID. Each such execution should be printed on a new line in the order they occur in the simulation.

## sample
2
1
4 1 5
Executing Process PID=4

Executing Process PID=4 Executing Process PID=4 Executing Process PID=4 Executing Process PID=4

</p>