This project is a simple implementation of a thread pool in C#. The program reads a list of tasks from an input file, assigns them to a thread pool with a specified maximum number of threads, and executes them concurrently. After execution, it generates a report summarizing the execution time of each task and the overall simulation performance. This project is the Final Project for the Operating Systems course at Bu-Ali Sina University during the Fall 1403 semester, showcasing key concepts of multi-threading, synchronization, and task scheduling.
- Custom thread pool implementation.
- Concurrent execution of tasks.
- Task scheduling and execution management.
- Simulation report including execution time and resource utilization.
- .NET SDK installed
- Basic knowledge of C# and multi-threading
- Clone the repository:
git clone cd ThreadPool - Build the project:
dotnet build
- Modify
Program.csto specify the input file:string filePath = "./Inputs/input_1.txt";
- Run the program:
dotnet run
- The program reads tasks from the input file, executes them using the thread pool, and prints a detailed simulation report.
The input file should follow this format:
<max_threads>
<task_name> <execution_time_in_ms>
<task_name> <execution_time_in_ms>
...
10
Task1 500
Task2 300
Task3 200
Task4 400
Task5 100
Task6 150
______________________________ Simulation Report ______________________________
Total Simulation Time: 504 ms
Total Allocated Threads: 6
Total Completed Tasks: 10
Unused Threads: 4
_______________________________________________________________________________
_____________________________ Task Timing Report ______________________________
Task 5: Allocation = 0 ms, Completion = 107 ms, Duration = 107 ms
Task 6: Allocation = 0 ms, Completion = 153 ms, Duration = 153 ms
Task 3: Allocation = 0 ms, Completion = 201 ms, Duration = 201 ms
Task 2: Allocation = 0 ms, Completion = 312 ms, Duration = 312 ms
Task 4: Allocation = 0 ms, Completion = 408 ms, Duration = 408 ms
Task 1: Allocation = 0 ms, Completion = 504 ms, Duration = 504 ms
_______________________________________________________________________________