Skip to content

About

KTU S4 Operating Systems Lab (CSL204) Solved Programs. Includes CPU Scheduling, System Calls, and Shell Scripts for the 2019 Scheme.

Topics

Resources

Stars

17 stars

Watchers

1 watching

Forks

Latest commit

 

History

50 Commits

Folders and files

Repository files navigation

Operating Systems Lab - KTU S4

A practical collection of Operating Systems laboratory programs for KTU CSE S4.

C Shell GitHub stars

This repository brings together the source code and reference material completed during the Operating Systems lab. It is useful for revising concepts, preparing for practical examinations, and comparing different OS algorithms through small, readable implementations.

What You Will Find

  • Linux command reference material and shell scripting exercises
  • UNIX process, directory, and file I/O system calls
  • CPU scheduling simulations with waiting and turnaround times
  • Shared-memory IPC and semaphore-based synchronization problems
  • Fixed and variable partition memory allocation
  • FIFO, LRU, LFU, and Optimal page replacement
  • Banker's safety algorithm and deadlock detection
  • FCFS, SCAN, and CSCAN disk scheduling

Quick Navigation

Topic Start here
Shell scripting Cycle 2
System calls and file I/O Cycles 3-4
CPU scheduling Cycle 5
IPC and synchronization Cycles 6-7
Memory management Cycles 8-9
Deadlocks and disk scheduling Cycles 10-11
Complete file list Lab Programs

Lab Overview

Cycle Area Main concepts Files
1 Linux commands Command-line fundamentals 1
2 Shell scripting Conditions, loops, search, patterns, arguments 14
3 System calls fork, exec, stat, directory operations 4
4 File I/O open, read, write, close 1
5 CPU scheduling FCFS, SJF, SRTF, Round Robin, Priority 5
6 Shared-memory IPC shmget, shmat, shmdt, shmctl 3
7 Synchronization Semaphores and classic problems 4
8 Memory allocation Fixed and variable partitions 2
9 Page replacement FIFO, LRU, LFU, Optimal 5
10 Deadlock handling Safety, resource requests, detection 4
11 Disk scheduling FCFS, SCAN, CSCAN 2

Getting Started

Prerequisites

You will need:

  • A Unix-like operating system such as Linux or macOS
  • GCC or another C compiler
  • Bash or a compatible shell
  • POSIX development support for programs using processes, threads, shared memory, or semaphores

Clone the Repository

git clone https://github.com/ar-ashiq/Operating-Systems-Lab-S4-KTU.git
cd Operating-Systems-Lab-S4-KTU

Compile and Run a C Program

gcc cycle5/fcfs.c -o fcfs
./fcfs

For a program using POSIX threads or semaphores, your platform may require an additional linker flag:

gcc cycle7/producerConsumer.c -o producer_consumer -pthread
./producer_consumer

Run a Shell Script

chmod +x cycle2/1grossSalary.sh
./cycle2/1grossSalary.sh

Most programs are interactive and expect input from the terminal. Read the source before running it so you know the expected input format and algorithm assumptions.

Lab Programs

All links below open the corresponding file directly on GitHub.

Cycle 1 - Linux Commands

Cycle 2 - Shell Scripting

Cycle 3 - Process and Directory System Calls

  • Fork, process IDs, exit, and wait - Demonstrates parent-child process creation and synchronization.
  • Exec - Replaces the current process with the ls -l command using execlp.
  • Stat - Reads file metadata such as size, device ID, and timestamps.
  • Directory operations - Opens a directory, reads its entries, and closes it.

Cycle 4 - File I/O System Calls

Cycle 5 - CPU Scheduling Algorithms

Cycle 6 - IPC Using Shared Memory

Cycle 7 - Semaphores and Synchronization

  • Dining Philosophers - Coordinates philosophers competing for shared chopsticks.
  • Producer-Consumer - Synchronizes producers and consumers with counting semaphores and a mutex.
  • Readers-Writers - Coordinates concurrent readers and exclusive writers.
  • Sleeping Barber - Models waiting customers, barber availability, and limited waiting seats.

Cycle 8 - Memory Allocation

Cycle 9 - Page Replacement Algorithms

Cycle 10 - Deadlock Handling

Cycle 11 - Disk Scheduling Algorithms

Learning Path

  1. Begin with shell scripting to practise input, conditions, loops, and functions.
  2. Move to system calls and file I/O.
  3. Compare the CPU scheduling algorithms using the same process concepts.
  4. Study IPC and synchronization before working through deadlocks.
  5. Finish with memory management, page replacement, and disk scheduling.

Contributions

Found an error, portability issue, or a missing lab program? Contributions are welcome.

  1. Fork the repository.
  2. Create a focused branch for your change.
  3. Test the program on a Unix-like system.
  4. Open a pull request with a short explanation of the change.

You can also open an issue or contact ashiqar2002@gmail.com.

Acknowledgements

Created as a practical study resource for Kerala Technological University (KTU) Computer Science students learning Operating Systems.

License

This repository is licensed under the MIT License. You are free to use, modify, and distribute the programs with the license notice included.

About

KTU S4 Operating Systems Lab (CSL204) Solved Programs. Includes CPU Scheduling, System Calls, and Shell Scripts for the 2019 Scheme.

Topics

Resources

Stars

17 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages