A C-based simulation of a priority-driven task queue system, designed to process tasks based on their priorities and service times.
This project demonstrates task scheduling, queue management, and performance evaluation using a linked-list-based priority queue in C.
This simulation models a basic task scheduling environment where tasks:
- โ Arrive randomly over time
- โ Are enqueued based on priority
- โ Are processed according to priority and service time
- โ Contribute to the calculation of average waiting time
- ๐๏ธ Simulate Task Arrivals: Tasks are randomly generated based on a probability model
- ๐น๏ธ Priority Queue Management: Tasks are inserted based on priority (lower number = higher priority)
- โณ Time Simulation: Task service and queue state update over simulated ticks
- ๐ Average Waiting Time Calculation: Evaluates system efficiency after all tasks are processed
- ๐ฅ๏ธ Terminal Output: Queue state and events are printed in a readable format
- Language: C
- Compiler: GCC or any C99-compatible compiler
- Execution: Linux/macOS/Windows terminal
Each task is represented by the following structure:
| Field | Type | Description |
|---|---|---|
id |
int |
Unique task identifier |
arrival_time |
int |
Time the task arrives |
service_time |
int |
Time required to complete the task |
priority |
int |
Priority value (0 = highest priority) |
-
Clone this repository:
git clone https://github.com/ZiyadAzzaz/Task-Queue-Simulator.git cd Task-Queue-Simulator -
Compile the source code:
gcc -Wall -o task-queue Final_Queue.c
-
Run the program:
./task-queue
๐ View the complete source code
============================= 0
TASK ARRIVED with id: 0, service time: 5, priority: 2
Queue: [0|0|5|2] => NULL
...
SERVE TASK: 0
Average Waiting Time: 4.20
- ๐พ Save and load queue states from files (CSV, JSON)
- ๐ ๏ธ Command-line configuration of arrival rate and simulation ticks
- ๐งฎ Real-time statistics during simulation
- ๐ Visualization of task throughput and wait time trends
- ๐ง Extend with round-robin or multi-level queue algorithms
This project was built as a practical exercise to help students and beginners understand:
- How priority queues work in practice
- Using linked lists for queue implementations
- Concepts of discrete event simulation
- Core data structure operations in C
This project is licensed under the terms of the MIT License.
You are free to:
- โ Use this code for any purpose
- โ Modify it for personal or academic projects
- โ Share or publish improvements
Note: Provided "as is", without warranty of any kind.
Ziyad Azzaz
๐ GitHub: ZiyadAzzaz
โจ Built to help learners master core concepts in C programming โ one project at a time.