Implemented FCFS scheduling in C Shell using arrays, loops and manual time calculations to simulate process execution order and waiting times.
I developed a First-Come First-Serve (FCFS) CPU Scheduling simulator using only C Shell (csh) scripting. This project includes two input modes (dynamic & fixed), full input validation, sorting by arrival time, manual CPU time tracking, and formatted output with average time calculations.
The entire logic — from data collection to final table generation — is done using low-level shell operations, arrays, bc
for floating-point math, and file-based data sharing between scripts.
This project is structured into:
fcfs.csh
→ main logic and control
sub.csh
→ input handler
wrong_alert.csh
→ optional alert sound on invalid input
User selects input mode (dynamic/fixed).
Script collects and validates process data.
Processes are sorted by arrival time.
FCFS scheduling is applied manually (no libraries).
Outputs a final table with execution, waiting, and turnaround times + averages.
Teaches how schedulers like FCFS really work
Sharpens low-level scripting skills
Works entirely in terminal with user interaction
Great for learning OS-level logic hands-on
I wanted to simulate the FCFS CPU scheduling algorithm using only C Shell scripting, knowing that csh
has many limitations compared to Bash or Python. My strategy was to keep everything simple but functional. I focused on breaking the script into separate parts for better organization and reusability. I used arrays to store process data, temporary files to pass values between scripts, and standard Unix tools like grep
, sort
, and bc
to overcome the lack of built-in support for things like input validation, sorting, and floating-point arithmetic. My goal was to make the script interactive, accurate, and understandable, even for those new to shell scripting.
The design of the project is structured around three main scripts. The main one, fcfs.csh
, handles the overall flow including user interaction, array management, sorting, scheduling logic, and output display. To keep the input section clean, I separated out arrival and burst time handling into a helper script called sub.csh
, which gets called from the main script for each process. For error handling, especially when the user enters invalid input, I created wrong_alert.csh
to play a sound alert. The script supports two input modes — dynamic, where I enter process IDs manually, and fixed, where I just input the number of processes and IDs are auto-generated. After collecting input, I write the process data into a temporary file, sort it based on arrival time, and re-load the sorted values into arrays. Then the script calculates waiting time, turnaround time, execution start, and completion time for each process, and prints everything in a neatly formatted output table along with average values at the end.
📖 More details, procedures and screenshots are available in my Medium article:
🔗 How I Built an FCFS CPU Scheduler in C Shell (Yes, CSH!)