Skip to content
pwnjoshiPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

Repository files navigation

OS Lab

Small C exercises exploring processes, fork(), IPC, CPU scheduling, page replacement, and file I/O.

Experiment checklist

All 13 experiments in the supplied list are covered. Existing programs are kept in their original folders; the missing experiments are added below.

No. Question (simple wording) Source
1 Create a child process using fork(). Fork demo
2 Parent adds odd numbers; child adds even numbers from 1 to n. Odd/even sums
3 Make the parent wait until the child finishes. Wait demo
4 Show orphan and zombie processes. Orphan, Zombie
5 Send data between processes using a pipe. Pipe demo
6 Send a message using a FIFO (named pipe). Writer, Reader
7 Send and receive a message using a message queue. Sender, Receiver
8 Write and read a message using shared memory. Writer, Reader
9 Run processes in first come, first served order. FCFS
10 Run the shortest available job first. SJF
11 Run the available process with the highest priority first. Priority
12 Replace the oldest loaded page when frames are full. FIFO pages
13 Replace the page that has not been used for the longest time. LRU pages

Running the new programs

Use Linux or Ubuntu in WSL with GCC. The process and IPC programs need Linux system calls and cannot be run directly with a Windows-only C compiler. Compile each source separately, for example from the project folder:

gcc -std=c11 -Wall -Wextra November12/parent_odd_child_even_sum.c -o /tmp/odd_even
/tmp/odd_even
gcc -std=c11 -Wall -Wextra November13/fcfs_scheduling.c -o /tmp/fcfs
/tmp/fcfs

For each IPC pair, compile both files separately in the same way:

  • FIFO: start the writer, enter a message, then run the reader in another terminal from the same directory. The writer waits for the reader. The reader removes os_lab_fifo after reading it.
  • Message queue: run the sender first, then the receiver. The receiver removes the queue after reading the message.
  • Shared memory: run the writer first and let it finish, then run the reader. The reader removes the shared memory after reading it.

Run one pair at a time. The message queue uses key 1234 and shared memory uses key 5678; use these examples where those keys are free. If a run is interrupted, ipcs lists remaining IPC objects; remove only this example's queue or memory with ipcrm -Q 1234 or ipcrm -M 5678. Remove a leftover FIFO with rm os_lab_fifo from the directory where the writer ran.

Scheduling programs accept up to 20 processes. Arrival and burst times are whole numbers up to 100000; burst time must be positive. SJF and priority are non-preemptive: a running process finishes before another starts. Smaller priority numbers mean higher priority. Ties follow input order.

Page replacement programs accept up to 100 nonnegative page numbers and up to 20 frames. They print the frames after each reference and count hits and faults.

Programs

July 31

August 7

August 17

September 18

September 25

AI assistance

Copilot was used to structure this README.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages