https://github.com/justine-george/seeking-tutor-problem-posix-threads
Multithreaded simulation of a tutoring center coordination system using POSIX threads, mutex locks, and semaphores in C.
https://github.com/justine-george/seeking-tutor-problem-posix-threads
c mutex-synchronisation mutithreading semaphores simulation
Last synced: 5 months ago
JSON representation
Multithreaded simulation of a tutoring center coordination system using POSIX threads, mutex locks, and semaphores in C.
- Host: GitHub
- URL: https://github.com/justine-george/seeking-tutor-problem-posix-threads
- Owner: justine-george
- License: mit
- Created: 2023-01-04T07:59:14.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-01-24T05:23:08.000Z (almost 2 years ago)
- Last Synced: 2025-01-01T14:46:24.160Z (about 1 year ago)
- Topics: c, mutex-synchronisation, mutithreading, semaphores, simulation
- Language: C
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Multi-threaded POSIX Simulation of a Mentoring Center with Priority Scheduling (aka Seeking-Tutor-Problem)
This repository contains an implementation that models and synchronizes the activities of a coordinator, tutors, and students in a mentoring center using POSIX threads, mutex locks, and semaphores, as per the original problem described below.
## Problem Description
In the computer science department's mentoring center (csmc), there are coordinators, tutors, and students. The center is equipped with a waiting area with several chairs and a separate tutoring area. The coordinators and tutors manage the flow of students based on their need for assistance and priority.
Students seeking help from tutors arrive at the center and wait in the available chairs. If no chairs are free, they return later. The coordinator organizes the students based on their priority, which depends on the frequency of their visits: first-time visitors have the highest priority. Students with the same priority level are queued based on their arrival time. Tutors, after being notified by the coordinator, assist the students with the highest priority.
## Implementation Details
The implementation uses:
- POSIX threads to simulate the concurrent activities of coordinators, tutors, and students
- Mutex locks to manage access to shared resources like chairs
- Semaphores to synchronize the interaction between students, tutors, and the coordinator
## Compilation Format
Compile the program using the following command:
```bash
gcc csmc.c -o csmc -Wall -Werror -pthread -std=gnu99
```
## Running the Program
To execute the program, use the following format:
```bash
./csmc #students #tutors #chairs #help
```
## Sample Usage
### Input
```bash
./csmc 2 2 2 1
```
### Output
````
S: Student 1 takes a seat. Empty chairs = 1.
S: Student 2 takes a seat. Empty chairs = 0.
C: Student 1 with priority 0 added to the queue. Waiting students now = 1. Total requests = 1
T: Student 1 tutored by Tutor 1. Students tutored now = 0. Total sessions tutored = 1
S: Student 1 received help from Tutor 1.
C: Student 2 with priority 0 added to the queue. Waiting students now = 1. Total requests = 2
T: Student 2 tutored by Tutor 2. Students tutored now = 0. Total sessions tutored = 2
S: Student 2 received help from Tutor 2.
````