Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

0460210 Operating Systems Laboratory Course

Course Overview

This repository contains implementations and solutions for the Operating Systems laboratory course, focusing on kernel programming, system calls, device drivers, and process management in Linux.

Lab Assignments

HW1 - ProceNet: Social Network for Processes

Objective: Implement a social networking system for processes using custom system calls.

Key Features:

  • Custom system calls for process interaction
  • Friend invitation and response mechanisms
  • Process-to-process communication
  • Kernel-level social network data structures

Files:

  • HW1/Submit/procenet_api.h - User-space API definitions
  • HW1/Submit/kernel/procenet.c - Kernel implementation
  • HW1/Submit/kernel/fork.c - Modified fork system call
  • HW1/ex1.pdf - Assignment instructions

System Calls Implemented:

  • procenet_invite(pid_t pid, char* message) - Send friend invitation
  • procenet_respond(pid_t pid, int response) - Respond to invitation
  • procenet_invitations(struct invitation_t* invitations, ssize_t size) - Get pending invitations
  • procenet_info(pid_t pid, struct friend_t* friends) - Get friend information

Test Suites:

  • HW1/Original-tests-from-model/ - Original test suite with Python extensions

HW2 - Process Scheduling and Priority Management

Objective: Modify the Linux scheduler to implement custom scheduling policies and priority management.

Key Features:

  • Modified O(1) scheduler implementation
  • Custom priority calculations
  • Interactive process detection
  • Timeslice management
  • Wake-up mechanisms and invitation-based scheduling

Files:

  • HW2/Submit/kernel/sched.c - Modified scheduler implementation
  • HW2/Submit/kernel/exit.c - Process exit handling
  • HW2/Submit/include/linux/sched.h - Task structure modifications
  • HW2/ex2.pdf - Assignment instructions

Test Suites:

  • HW2/Tests/Set-From-HW1/ - Test set adapted from HW1
  • HW2/Tests/Original-tests-from-model-HW1/ - Original HW1 tests for compatibility
  • HW2/Tests/Set1-For-HW2/ - Specific HW2 scheduling tests
  • HW2/Tests/Set2-For-HW2/ - Additional HW2 test cases
  • Tests cover tie-breaking rules, wake-up mechanisms, and scheduling priorities

HW3 - DevNet: Character Device Driver

Objective: Implement a network-like character device driver for inter-process communication.

Key Features:

  • Character device driver implementation
  • Port-based communication system
  • Packet queuing and management
  • Blocking/non-blocking I/O operations
  • Support for up to 256 devices

Files:

  • HW3/Submit/devnet.c - Main device driver implementation
  • HW3/Submit/devnet.h - Header definitions and structures
  • HW3/Submit/README.txt - Implementation notes and known issues
  • HW3/ex3.pdf - Assignment instructions

Device Operations:

  • LISTEN - Set device to listen mode on specified port
  • CONNECT - Connect to a specific device and port
  • Read/Write operations with packet-based communication
  • Maximum Transfer Unit (MTU): 1500 bytes
  • Queue size: 128 packets

Test Suites:

  • HW3/Test/RmAndStart.sh - Automated test runner script
  • HW3/Test/more_tests2.py - Python test suite for device operations
  • HW3/Test/test_c_suite.c - C test suite for edge cases

Known Issues:

  • Test failure: "write should return EAGAIN if incoming queue is full by other port" (4 points deducted)

Technical Implementation Details

Memory Management

  • Proper kernel memory allocation using kmalloc/kfree
  • Spinlock protection for concurrent access
  • List management using Linux kernel list primitives

Synchronization

  • Wait queues for blocking operations
  • Spinlocks for critical sections
  • Interrupt handling for device operations

Error Handling

  • Comprehensive error code returns (EINVAL, ESRCH, EFAULT, EAGAIN)
  • Proper cleanup on failure paths
  • Validation of user-space inputs

Course Learning Objectives

  1. System Call Implementation: Design and implement custom system calls
  2. Kernel Programming: Work directly with Linux kernel internals
  3. Device Drivers: Develop character device drivers
  4. Process Management: Understand and modify process scheduling
  5. Synchronization: Implement proper kernel synchronization mechanisms
  6. Memory Management: Handle kernel memory allocation and deallocation
  7. Testing & Debugging: Comprehensive test suite development and kernel debugging

Repository Structure

LabOS-public/
├── HW1/                          # ProceNet implementation
│   ├── ex1.pdf                   # Assignment instructions
│   ├── Original-tests-from-model # Original Python test suite
│   └── Submit                    # Final submission
├── HW2/                          # Scheduler modifications  
│   ├── ex2.pdf                   # Assignment instructions
│   ├── Tests                     # Comprehensive test suites
│   └── Submit                    # Final submission
├── HW3/                          # DevNet device driver
│   ├── ex3.pdf                   # Assignment instructions
│   ├── Test                      # Automated test framework
│   └── Submit                    # Final submission
└── README.md                     # This file

License

This code is provided for educational purposes as part of the Operating Systems laboratory course. Please refer to your institution's academic integrity policies when using this code.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages