How dhruvvit/cpu-scheduler works
This is a browser-based CPU scheduling simulator. Users enter processes and scheduling options, validate the inputs, run one of five scheduling policies, and inspect the resulting timeline, per-process results, metrics, and ready-queue events. The React app coordinates that workflow; a framework-independent algorithm entry point dispatches to the selected scheduler and adds aggregate metrics. The source index and excerpts support the main orchestration and several algorithm details; other algorithm implementations are represented by their indexed paths, without assuming unsampled behavior beyond the documented dispatch.
Main entry points: App.tsx Simulation app · index.ts Algorithm dispatcher · scheduler.ts Scheduler data types · GanttChart.tsx Gantt chart
Components 17
Simulation workflow
- Simulation app
src/App.tsx - Process inputs
src/components/ProcessTable.tsx - Algorithm options
src/components/AlgorithmSelector.tsx
Scheduling algorithms
- Algorithm dispatcher
src/algorithms/index.ts - FCFS scheduler
src/algorithms/fcfs.ts - SJF scheduler
src/algorithms/sjf.ts - SRTF scheduler
src/algorithms/srtf.ts - Round Robin scheduler
src/algorithms/roundRobin.ts - Priority scheduler
src/algorithms/priority.ts
Results and display
- Gantt chart
src/components/GanttChart.tsx - Metrics panel
src/components/MetricsPanel.tsx - Ready queue
src/components/ReadyQueue.tsx
Shared logic
- Input validation
src/utils/validation.ts - Metrics calculation
src/utils/metrics.ts - Process colors
src/utils/colors.ts - Scheduler data types
src/types/scheduler.ts
Other components
- User
Connections 26
- User → Process inputs: edits processes
src/components/ProcessTable.tsx - User → Algorithm options: chooses options
src/components/AlgorithmSelector.tsx - Process inputs → Simulation app: updates inputs
src/App.tsx - Algorithm options → Simulation app: updates config
src/App.tsx - Simulation app → Input validation: validates inputs
src/App.tsx - Simulation app → Algorithm dispatcher: runs simulation
src/App.tsx - Algorithm dispatcher → FCFS scheduler: dispatches FCFS
src/algorithms/index.ts - Algorithm dispatcher → SJF scheduler: dispatches SJF
src/algorithms/index.ts - Algorithm dispatcher → SRTF scheduler: dispatches SRTF
src/algorithms/index.ts - Algorithm dispatcher → Round Robin scheduler: dispatches RR
src/algorithms/index.ts - Algorithm dispatcher → Priority scheduler: dispatches priority
src/algorithms/index.ts - Algorithm dispatcher → Metrics calculation: calculates metrics
src/algorithms/index.ts - Simulation app → Process inputs: renders inputs
src/App.tsx - Simulation app → Algorithm options: renders options
src/App.tsx - Simulation app → Gantt chart: renders schedule
src/App.tsx - Simulation app → Metrics panel: renders metrics
src/App.tsx - Simulation app → Ready queue: renders events
src/App.tsx - Gantt chart → Process colors: builds color map
src/components/GanttChart.tsx - Metrics panel → Process colors: builds color map
src/components/MetricsPanel.tsx - Ready queue → Process colors: uses process colors
src/components/ReadyQueue.tsx - Simulation app → Scheduler data types: uses data types
src/App.tsx - Algorithm dispatcher → Scheduler data types: uses data types
src/algorithms/index.ts - Metrics calculation → Scheduler data types: uses result types
src/utils/metrics.ts - Gantt chart → Scheduler data types: reads schedule types
src/components/GanttChart.tsx - Metrics panel → Scheduler data types: reads output types
src/components/MetricsPanel.tsx - Ready queue → Scheduler data types: reads event types
src/components/ReadyQueue.tsx