Skip to content

Ayush2006385/OS_Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OS_Project

Student Process Management System

Theme: University Student Registration System Simulator

A group of 4 C programs simulating core Operating System concepts using a university student registration scenario.


Dependencies

  • GCC compiler
  • POSIX Threads (pthread)
  • POSIX Semaphores (semaphore.h)
  • Standard C libraries

Setup

Make sure GCC is installed:

gcc --version

If not installed:

sudo apt install gcc        # Ubuntu/Debian
sudo dnf install gcc        # Fedora

Compile & Run

Activity 1 — Multi-Level Queue Scheduler

gcc activity1.c -o activity1
./activity1

Activity 2 — Resource Synchronization

gcc activity2.c -o activity2 -lpthread
./activity2

Activity 3 — Deadlock Handling

gcc activity3.c -o activity3 -lpthread
./activity3

Activity 4 — Memory Management (LRU)

gcc activity4.c -o activity4
./activity4

Activity 1 — Multi-Level Queue Scheduler (CO1)

Concept: 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

Sample Input

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

Sample Output

===== Average Waiting Time =====
Queue 1 (Year 4 - Senior):   3.00
Queue 2 (Year 3 - Junior):   2.00
Queue 3 (Year 2 - Sophomore): 1.00

Activity 2 — Resource Synchronization (CO2)

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

Sample Output

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

Activity 3 — Deadlock Handling (CO3)

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

Sample Output

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

Activity 4 — Memory Management (CO4)

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

Sample Input

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

Sample Output

Record  Page    Status
1       0       Fault
2       0       Hit
3       0       Hit
4       0       Hit
5       1       Fault
...
Total Page Faults = 5

File Structure

.
├── activity1.c    # Multi-Level Queue Scheduler
├── activity2.c    # Resource Synchronization
├── activity3.c    # Deadlock + Banker's Algorithm
├── activity4.c    # LRU Page Replacement
└── README.md

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages