Theme: University Student Registration System Simulator
A group of 4 C programs simulating core Operating System concepts using a university student registration scenario.
- GCC compiler
- POSIX Threads (
pthread) - POSIX Semaphores (
semaphore.h) - Standard C libraries
Make sure GCC is installed:
gcc --versionIf not installed:
sudo apt install gcc # Ubuntu/Debian
sudo dnf install gcc # Fedoragcc activity1.c -o activity1
./activity1gcc activity2.c -o activity2 -lpthread
./activity2gcc activity3.c -o activity3 -lpthread
./activity3gcc activity4.c -o activity4
./activity4Concept: Students registering for courses are treated as processes. Three priority queues based on year level, with Round Robin (quantum = 2) within each queue.
| Queue | Year Level | Priority |
|---|---|---|
| Queue 1 | Year 4 (Senior) | Highest |
| Queue 2 | Year 3 (Junior) | Medium |
| Queue 3 | Year 2 (Sophomore) | Lowest |
Enter number of students (max 20): 3
Student 1
Student ID: 101
Year (4=Senior, 3=Junior, 2=Sophomore): 4
Registration Time (1-10): 5
Student 2
Student ID: 202
Year (4=Senior, 3=Junior, 2=Sophomore): 2
Registration Time (1-10): 3
Student 3
Student ID: 303
Year (4=Senior, 3=Junior, 2=Sophomore): 3
Registration Time (1-10): 4
===== Average Waiting Time =====
Queue 1 (Year 4 - Senior): 3.00
Queue 2 (Year 3 - Junior): 2.00
Queue 3 (Year 2 - Sophomore): 1.00
Concept: Multiple students trying to register for limited course seats.
- 5 student threads booking seats
- 3 courses with seats: Course 1 (10), Course 2 (15), Course 3 (8)
- Mutex locks for seat allocation
- Semaphores for seat counting
- Race conditions prevented
Student 1 attempting to book Course 2
Student 2 attempting to book Course 1
Student 1 successfully booked Course 2. Remaining seats: 14
Student 2 successfully booked Course 1. Remaining seats: 9
...
Final Remaining Seats:
Course 1: 8 seats left
Course 2: 13 seats left
Course 3: 7 seats left
Concept: Students need multiple resources to complete work.
- 4 student threads
- 4 resources: Lab, Projector, Textbook, Laptop
- First demonstrates a deadlock situation
- Then applies Banker's Algorithm to find safe sequence
===== DEADLOCK DEMONSTRATION =====
S0 got Lab
S1 got Projector
S2 got Textbook
S3 got Laptop
S0 waiting for Projector
S1 waiting for Textbook
S2 waiting for Laptop
S3 waiting for Lab
Deadlock occurred! All students are waiting.
===== BANKER'S ALGORITHM =====
S0 executes
S1 executes
S2 executes
S3 executes
System is SAFE
Safe sequence: S0 S1 S2 S3
Concept: Paging-based memory management for student records.
- Each student record = 1 KB
- Page size = 4 KB (4 records per page)
- Physical memory = 16 frames
- LRU page replacement policy
Enter 20 student record accesses (1-20):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Record Page Status
1 0 Fault
2 0 Hit
3 0 Hit
4 0 Hit
5 1 Fault
...
Total Page Faults = 5
.
├── activity1.c # Multi-Level Queue Scheduler
├── activity2.c # Resource Synchronization
├── activity3.c # Deadlock + Banker's Algorithm
├── activity4.c # LRU Page Replacement
└── README.md