OS Lab Manual

St. Joseph's College of Engineering · AI & Data Science · 2026–2027

CS25308 · R-2025 · Semester IIIOperating Systems Laboratory

Twenty experiments in C and shell script: UNIX commands, CPU scheduling, synchronization, deadlock, memory allocation, page replacement, file allocation and disk scheduling.

Experiments

Each page link opens the full manual at that experiment.

  1. Ex 1a

    Basics of UNIX commands

    Directory, file, process, text and permission commands: pwd, ls, cd, mkdir, cp, mv, rm, who, date, head, tail, wc, chmod, man.

    Recorded run pwd → /home/user

  2. Ex 1b

    Simulation of UNIX commands

    C programs that reimplement ls, cp, grep and cat with opendir, readdir, open, read and write.

    Recorded run ./copy src.txt dest.txt → File copied successfully

  3. Ex 2a

    Shell program: largest of N numbers

    A bash script that reads N values into an array and tracks the maximum in a loop.

    Recorded run 15 20 30 40 55 → largest is 55

  4. Ex 2b

    UNIX commands using case

    A menu-driven script that runs date, who or prints $HOME with case…esac, and quits on w.

    Recorded run choice 3 → Home directory is /home/sys1

  5. Ex 3A

    FCFS scheduling

    Serves processes in arrival order and prints the Gantt chart, waiting time and turnaround time.

    Recorded run bursts 3 1 4 6 8 → avg waiting 5.80, avg turnaround 10.20

  6. Ex 3B

    SJF scheduling

    Sorts processes by burst time, then computes waiting and turnaround times.

    Recorded run bursts 4 1 7 9 3 → P2 P5 P1 P3 P4, avg waiting 5.60

  7. Ex 3C

    Priority scheduling

    Runs processes in order of priority value and reports the averages.

    Recorded run 5 processes → avg waiting 7.40, avg turnaround 10.40

  8. Ex 3D

    Round robin scheduling

    Gives each process a fixed time slice in turn until every burst is finished.

    Recorded run bursts 3 5 2 8 10, slice 5 → avg waiting 8.80

  9. Ex 4

    Producer–consumer with semaphores

    A three-slot bounded buffer with wait and signal on empty, full and mutex.

    Recorded run produce Blue, Green → consumed in order, buffer empty

  10. Ex 5

    Interprocess communication: shared memory

    A parent creates a segment with shmget and shmat; the child writes into it and the parent reads it back.

    Recorded run child writes a–z → parent prints abcdefghijklmnopqrstuvwxyz

  11. Ex 6A

    Deadlock avoidance: Banker's algorithm

    Builds the need matrix and runs the safety algorithm to find a safe sequence.

    Recorded run 3 processes, 3 resources → safe state, P0 P1 P2

  12. Ex 6B

    Deadlock detection

    Computes availability from allocation and request matrices and marks processes that can finish.

    Recorded run 3 processes → no deadlock detected

  13. Ex 7

    Memory allocation: first, best and worst fit

    Fixed-partition allocation with three placement strategies and fragment reporting.

    Recorded run best fit → P1 (15) in block 2 (20), fragment 5

  14. Ex 8A

    FIFO page replacement

    Replaces the oldest page in a circular frame queue and counts page faults.

    Recorded run 1 3 2 1 4 5 3 2, 3 frames → 7 page faults

  15. Ex 8B

    LRU page replacement

    Evicts the page that has gone unused the longest.

    Recorded run 2 3 4 3 2 4 1 5, 2 frames → 7 page faults

  16. Ex 8C

    Optimal page replacement

    Evicts the page whose next use is farthest in the future.

    Recorded run 15 pages, 4 frames → 12 page faults, rate 0.80

  17. Ex 9A

    Contiguous file allocation

    Places a file in consecutive blocks of a 20-block memory and rejects occupied or out-of-range starts.

    Recorded run file 15, start 8, length 5

  18. Ex 9B

    Linked file allocation

    Checks each requested block against the list of allocated blocks before assigning the file.

    Recorded run blocks 3 4 5 6 8 9 taken → request 1–9 refused

  19. Ex 9C

    Indexed file allocation

    An index block holds the addresses of a file's data blocks and refuses blocks already in use.

    Recorded run index block 4 → blocks 5 8 9 10 11

  20. Ex 10

    Disk scheduling: FCFS, SCAN, C-SCAN

    Simulates head movement for three algorithms and totals the seek distance.

    Recorded run FCFS 362 · SCAN 240 · C-SCAN 382 (average 47.75)

Course outcomes

On completing the course

CO1
Explain the fundamental structure, functions, and services of modern operating systems.
CO2
Implement and analyze process management and CPU scheduling mechanisms.
CO3
Simulate process synchronization and deadlock handling algorithms.
CO4
Demonstrate memory management and page replacement techniques through programming.
CO5
Design and simulate file system and I/O management algorithms.

Reference books

Text and reference

  • Silberschatz, Galvin, Gagne. Operating System Concepts, 10th ed., Wiley.
  • William Stallings. Operating Systems: Internals and Design Principles, 9th ed., Pearson.
  • Andrew S. Tanenbaum. Modern Operating Systems, Pearson.
  • D. M. Dhamdhere. Operating Systems: A Concept-Based Approach, McGraw Hill.
  • Achyut S. Godbole. Operating Systems, Tata McGraw Hill.

Full programs, algorithms and screenshotsThe manual has every program listing and terminal output, plus the viva questions at the end.

Open full manual (PDF)