CPU Scheduling Simulation

Hard Queue: Applications PRO
🔒 Login to Unlock

Problem Statement

Write a C program to simulate a Round-Robin CPU scheduling queue with a fixed time quantum.

Input Format

First line contains n and quantum. Second line contains n process burst times.

Output Format

Print execution order or remaining process processing sequence.

Constraints

1 <= n <= 30, 1 <= quantum <= 10

Sample Input

3 2
5 3 1

Sample Output

P1 P2 P3 P1 P2 P1

Explanation

Maintain a queue of processes. Dequeue a process, run it for min(burst, quantum), reduce its burst, and if remaining > 0, re-enqueue it.

Starter Code

#include <stdio.h>
#include <stdlib.h>

int main() {
    int n, q;
    if (scanf("%d %d", &n, &q) == 2) {
        // Write your code here for CPU scheduling simulation
    }
    return 0;
}

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used