Implement Priority Round Robin Scheduling Algorithm with Tests
- Added `priority_rr` algorithm to handle scheduling based on priority and round-robin principles. - Created unit tests for `select()`, `shouldPreempt()`, and `isQuantumExpired()` functions to ensure correct behavior. - Developed integration tests to validate the scheduling logic under various scenarios, including preemption and round-robin execution. - Introduced `useExport` hook for exporting process metrics to CSV format. - Added `useGanttScroll` hook to manage smooth scrolling of the Gantt chart during simulation.
This commit is contained in:
1 parent
083fc0027e
commit
51a8a6fa40
38 files changed
+2530
-45
No files matched your search
@@ -67,6 +67,16 @@ export const presets: Preset[] = [
|
||||
],
|
||||
config: defaultConfig({ algorithm: "PRIORITY_P", isPreemptive: true, agingEnabled: true, agingInterval: 3 }),
|
||||
},
|
||||
{
|
||||
name: "priority_rr_demo",
|
||||
description: "Priority RR: P3 (priority 1) preempts mid-run; P1 & P2 (priority 2) share CPU via RR",
|
||||
processes: [
|
||||
{ id: "p1", name: "P1", arrivalTime: 0, priority: 2, color: "#4FC3F7", bursts: [{ type: "cpu", duration: 4 }] },
|
||||
{ id: "p2", name: "P2", arrivalTime: 0, priority: 2, color: "#81C784", bursts: [{ type: "cpu", duration: 4 }] },
|
||||
{ id: "p3", name: "P3", arrivalTime: 4, priority: 1, color: "#F06292", bursts: [{ type: "cpu", duration: 2 }] },
|
||||
],
|
||||
config: defaultConfig({ algorithm: "PRIORITY_RR", quantum: 2 }),
|
||||
},
|
||||
{
|
||||
name: "io_heavy",
|
||||
description: "Mixed CPU-bound and I/O-bound processes",
|
||||
@@ -77,4 +87,27 @@ export const presets: Preset[] = [
|
||||
],
|
||||
config: defaultConfig({ algorithm: "SJF_P", isPreemptive: true }),
|
||||
},
|
||||
{
|
||||
name: "convoy_effect",
|
||||
description: "One long process blocks shorter ones — FCFS convoy vs SJF comparison",
|
||||
processes: [
|
||||
{ id: "p1", name: "P1", arrivalTime: 0, priority: 5, color: "#EF5350", bursts: [{ type: "cpu", duration: 12 }] },
|
||||
{ id: "p2", name: "P2", arrivalTime: 1, priority: 5, color: "#81C784", bursts: [{ type: "cpu", duration: 2 }] },
|
||||
{ id: "p3", name: "P3", arrivalTime: 2, priority: 5, color: "#FFB74D", bursts: [{ type: "cpu", duration: 1 }] },
|
||||
{ id: "p4", name: "P4", arrivalTime: 3, priority: 5, color: "#CE93D8", bursts: [{ type: "cpu", duration: 3 }] },
|
||||
],
|
||||
config: defaultConfig({ algorithm: "FCFS" }),
|
||||
},
|
||||
{
|
||||
name: "multilevel_demo",
|
||||
description: "Priority RR with 3 priority tiers — demonstrates multilevel scheduling",
|
||||
processes: [
|
||||
{ id: "p1", name: "P1", arrivalTime: 0, priority: 1, color: "#EF5350", bursts: [{ type: "cpu", duration: 4 }] },
|
||||
{ id: "p2", name: "P2", arrivalTime: 0, priority: 1, color: "#FF8A65", bursts: [{ type: "cpu", duration: 3 }] },
|
||||
{ id: "p3", name: "P3", arrivalTime: 2, priority: 2, color: "#81C784", bursts: [{ type: "cpu", duration: 5 }] },
|
||||
{ id: "p4", name: "P4", arrivalTime: 2, priority: 2, color: "#4FC3F7", bursts: [{ type: "cpu", duration: 2 }] },
|
||||
{ id: "p5", name: "P5", arrivalTime: 4, priority: 3, color: "#CE93D8", bursts: [{ type: "cpu", duration: 6 }] },
|
||||
],
|
||||
config: defaultConfig({ algorithm: "PRIORITY_RR", quantum: 2 }),
|
||||
},
|
||||
];
|
||||
Reference in new issue
Block a user