Project for E0-253 Operating System IISc
This repository contains three projects as part of the Operating Systems coursework. Each project focuses on critical aspects of modern operating systems, namely core isolation, process pinning, and implementing a task scheduler, process checkpointing
-
Project 0: Core Isolation and Process Pinning (Kernel Programming, System Call Implementation, Kernel Debugging)
- This project involves isolating a CPU core and pinning specific processes to that core. The goal is to create a controlled environment for testing and performance analysis.
-
Project 1: Rotating Staircase Deadline Scheduler (RSDL) (Linux Scheduling, Kernel Programming, RSDL)
- This project focuses on building and integrating a new task scheduler within the Linux kernel. The scheduler, known as the Rotating Staircase Deadline Scheduler (RSDL), ensures fairness, bounded latency, no starvation, and good interactivity. The scheduler was configured to schedule normal processes running on a particular isolated core. Used CPU-SETs, CPU-Hotplugging functionality for isolating the core.
-
Project 2: Process Checkpointing - Context-Based Memory State Management (Kernel Programming, Page fault handling, System-call Implementation) Implemented an in-kernel page fault handling mechanism to facilitate saving or restoring process context to mitigate risk associated with unsafe code execution. Compared to fork this light weight mechanism observed speedup of 30x
In modern operating systems, isolating CPU cores can significantly improve the performance of specific tasks by preventing interference from other processes. This project involves creating a test bed by isolating a CPU core and pinning high and low priority processes to the isolated core.
- Kernel Space: Implement a system call to isolate CPU 0.
- User Space: Schedule two processes with the highest and lowest priorities to run exclusively on CPU 0.
- A single kernel patch containing all changes.
- Modified user space file (
main.c
).
- Download the Linux Kernel:
wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.0.19.tar.xz
- Implement Core Isolation: Modify the kernel to isolate CPU 0.
- Process Pinning: Schedule processes to run on the isolated core.
The task scheduler is a core component of any multitasking operating system. This project involves building and integrating the Rotating Staircase Deadline Scheduler (RSDL) into the Linux kernel. RSDL is an O(1) scheduler that guarantees fairness and bounded latency.
- Scheduler Design: RSDL uses two arrays,
active
andexpired
, each maintaining a list of runqueues based on priority levels. - Task Scheduling: Tasks are scheduled from highest to lowest priority, with each task receiving a fixed quota of 5 time units.
- Fairness and No Starvation: Ensures all tasks get a fair share of CPU time.
- Bounded Latency: Limits the maximum waiting time for tasks.
- Interactivity: Enhances system responsiveness.
- A single kernel patch containing all changes.
- User space files for testing the scheduler.
- Download the Linux Kernel:
wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.0.19.tar.xz
- Implement RSDL: Modify the kernel to implement the RSDL scheduler.
- Testing: Ensure all processes running on CPU 0 are scheduled using the RSDL scheduler.
- Linux kernel version 6.0.19
- Git
- Basic knowledge of kernel development
- Download and extract the kernel source:
wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.0.19.tar.xz tar -xf linux-6.0.19.tar.xz cd linux-6.0.19
- Apply the kernel patch:
git apply /path/to/your/patch.patch
- Build and install the kernel:
make -j$(nproc) sudo make modules_install sudo make install
- Boot your system with the new kernel.
- Verify core isolation and process pinning:
./main
- Test the RSDL scheduler by running your custom tests.
This project is part of the E0-253: Operating Systems course assignment. The goal is to implement an efficient method to save and restore program states in user-space programs, as an alternative to the fork-based method in Linux.
The C programming language is inherently unsafe as it allows arbitrary memory access. This project aims to build a system call for user-space programs to save and restore their program state in memory. This is particularly useful when executing potentially unsafe code sections.
To introduce a context-based method in Linux to save and restore program state without creating an additional process. This will be achieved by implementing a new system call named mmcontext
.
The mmcontext
system call accepts an integer argument:
0
to save the program state.1
to restore the program state.
- Save/restore the state of dynamically allocated anonymous memory.
- Return
0
on success or an appropriate error code on failure. - Allow only one context to be saved at a time.
- Support single-threaded programs only.
- Ensure no memory leaks upon process termination.
- Memory State Management: Manage the state of dynamically allocated anonymous memory.
- Error Handling: Handle errors like invalid arguments, existing contexts, and more.
- Performance Optimization: Ensure minimal overhead compared to the fork-based method.
- Ignore the state of the process stack, files, signals, and registers.
- Ensure address space remains unaltered between save and restore calls.
- Clean up process state upon termination to avoid memory leaks.
The implementation will be evaluated based on:
- Functional Correctness: The system call should work for various program sizes.
- Performance: Compared against the fork-based method in terms of throughput.
- Linux kernel source code
- GCC compiler
- Git
- Clone the repository:
git clone https://github.com/csl-iisc/e0253-os-2023.git
- Linux Kernel Archives
- RSDL Wikipedia
- Linux Kernel Mailing List
- Linux Man Pages
- YouTube Video on RSDL
This project is licensed under the MIT License - see the LICENSE file for details.
- Con Kolivas for the RSDL scheduler concept.
- Operating Systems course instructors for project guidance.
Feel free to contribute by submitting issues or pull requests to improve this project.