Skip to content

A C-based simulation of a priority-driven task queue system, designed to manage and process tasks with varying priorities and service times. It calculates average waiting times to evaluate task processing efficiency.

License

Notifications You must be signed in to change notification settings

ZiyadAzzaz/Task-Queue-Simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Task Queue Simulator

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.


๐Ÿ“‹ Overview

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

View Code


๐Ÿ“ Features

  • ๐Ÿ—‚๏ธ 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

๐Ÿ› ๏ธ Tech Stack

  • Language: C
  • Compiler: GCC or any C99-compatible compiler
  • Execution: Linux/macOS/Windows terminal

๐Ÿงฉ Data Model

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)

๐Ÿš€ How to Compile and Run

  1. Clone this repository:

    git clone https://github.com/ZiyadAzzaz/Task-Queue-Simulator.git
    cd Task-Queue-Simulator
  2. Compile the source code:

    gcc -Wall -o task-queue Final_Queue.c
  3. Run the program:

    ./task-queue

๐Ÿ‘‰ View the complete source code


๐Ÿงช Sample Output

============================= 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

๐ŸŽฏ Future Enhancements (Optional Ideas)

  • ๐Ÿ’พ 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

๐Ÿ’ก Project Purpose

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

๐Ÿชช License

License

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.


๐Ÿ‘จโ€๐Ÿ’ป Author

Ziyad Azzaz
๐Ÿ”— GitHub: ZiyadAzzaz


โœจ Built to help learners master core concepts in C programming โ€” one project at a time.

About

A C-based simulation of a priority-driven task queue system, designed to manage and process tasks with varying priorities and service times. It calculates average waiting times to evaluate task processing efficiency.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages