Skip to content
hrshyaPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

gemOS — x86-64 Operating System & Systems Programming

A cumulative systems-programming and operating-systems project based on gemOS, an educational x86-64 operating-system kernel developed through the CS330 course.

The project progresses from low-level Linux/POSIX programming and process management to kernel development involving virtual memory, system calls, exception handling, scheduling, tracing, threading, synchronization, and copy-on-write memory management.

Project Overview

The repository contains two complementary parts:

  • gemOS/ — the cumulative gemOS kernel and user-space environment, including the kernel subsystems and extensions developed throughout the course.
  • labs/ — selected implementations organized by laboratory and question, preserving the progression of the systems-programming work.

The labs/ directory contains the submitted implementation code rather than generated test outputs or course-provided testcase data.


Repository Structure

.
├── gemOS/
│   ├── include/
│   ├── user/
│   ├── *.c
│   ├── *.h
│   ├── *.S
│   └── Makefile
│
├── labs/
│   ├── lab01/
│   ├── lab02/
│   ├── lab04/
│   ├── lab05/
│   ├── lab06/
│   ├── lab07/
│   ├── lab09/
│   └── lab11/
│
└── README.md

Labs 3, 8, and 10 are not included because no corresponding assignment source directories were present in the working course repository.


Laboratory Work

Lab 1 — Linux Systems Programming

Q1 — Word Count

Implemented a wc-style utility using C/POSIX file and input APIs, supporting character, word, and line counting.

Concepts: file I/O, command-line parsing, strings, POSIX APIs.

Q2 — Performance Ring Buffer

Processed Linux perf_event ring-buffer records, handling sample and lost-event records and accounting for unknown record types.

Concepts: perf_event, memory-mapped ring buffers, binary record processing, low-level Linux instrumentation.


Lab 2 — Processes, IPC & System Calls

Q1 — Parallel Prime Counting

Parallelized prime counting using multiple processes created with fork() and collected partial results using process termination status.

Concepts: fork(), waitpid(), process parallelism, exit status communication.

Q2 — Recursive exec

Implemented recursive computation using repeated process replacement with execl().

Concepts: fork/exec model, process replacement, argument passing.

Q3 — File Search

Implemented string searching over file contents using low-level file descriptors and read().

Concepts: open(), read(), file descriptors, buffered/unbuffered processing.

Q4 — System Call Trace Counting

Parsed system-call trace data and counted occurrences of selected system calls.

Concepts: low-level file I/O, trace processing, string parsing.

Q5 — Pipe + exec Encryption Pipeline

Built a parent-child processing pipeline using pipes, process creation, descriptor redirection, and exec() to stream data through an encryption process.

Concepts: fork(), pipe(), dup()/dup2(), exec(), IPC, file I/O.

Q6 — Multi-Process Prime Counting

Generalized parallel prime counting to an arbitrary number of child processes, partitioning the search space and communicating partial results through pipes.

Concepts: multi-process parallelism, pipes, process synchronization, IPC.

Q7 — Memory Compaction

Implemented compaction of dynamically allocated process memory and reduced the data-segment footprint using sbrk().

Concepts: process memory layout, heap management, sbrk(), memory compaction.


Lab 4 — Virtual Memory & Code Relocation

Q1 — Memory Mapping

Implemented dynamic memory management using explicit virtual-memory mappings instead of conventional allocation routines.

Concepts: mmap(), munmap(), mremap(), virtual memory.

Q2 — Memory Span Discovery

Determined the contiguous mapped memory span surrounding a given address by probing adjacent pages.

Concepts: page mappings, virtual-address space, page granularity.

Q3 — Runtime Code Relocation

Relocated executable code into a dynamically mapped region, computed relocated function addresses, and transferred execution to relocated code using x86-64 assembly.

Concepts: executable memory, code relocation, address arithmetic, x86-64 assembly, indirect control flow.


Kernel Development

Lab 5 — Process Information

Extended gemOS with process-information interfaces exposing information about:

  • process identity and parent relationships
  • process/file-descriptor state
  • memory segments
  • virtual-memory areas

The implementation spans kernel-side process metadata and the user-space interface.

Concepts: system calls, process control blocks, file descriptors, memory segments, VMAs.


Lab 6 — Exception Handling

Implemented configurable divide-by-zero exception handling inside gemOS.

The implementation works with the saved execution context and supports different recovery behaviors, including modifying register state, skipping faulting instructions, redirecting execution to user handlers, and recovering at function boundaries.

Concepts: hardware exceptions, saved CPU context, instruction pointers, register state, user/kernel transitions.


Lab 7 — Kernel Trace Buffer

Implemented a kernel trace-buffer facility with file-descriptor based access.

The implementation includes trace-buffer creation, circular-buffer reads/writes, file-operation dispatch, and validation of user-provided memory ranges.

Concepts: kernel buffers, circular buffers, file operations, address validation, synchronization and resource management.


Lab 9 — Scheduling & Page Tables

Round-Robin Scheduling

Implemented and integrated Round-Robin scheduling with process queues and timer-driven scheduling behavior.

Concepts: scheduling queues, process states, timer interrupts, context switching.

Four-Level Page-Table Walk

Implemented traversal of the x86-64 four-level page-table hierarchy to resolve virtual-address mappings.

Concepts: PML4/PDPT/PD/PT hierarchy, virtual-to-physical translation, page-table entries.


Lab 11 — Threads, Synchronization & Copy-on-Write

Thread Creation & Lifecycle

Implemented kernel-level thread creation and execution contexts, including thread-specific stacks, register state, entry points, and lifecycle management.

Concepts: execution contexts, kernel stacks, user stacks, thread lifecycle.

Thread Synchronization

Implemented synchronization mechanisms for coordinating concurrent execution, including blocking/wakeup behavior and kernel synchronization primitives.

Concepts: synchronization, wait queues, blocking, wakeup, concurrency.

Copy-on-Write Fork

Implemented cfork() using shared physical pages and copy-on-write semantics.

The implementation constructs child address spaces using four-level x86-64 page tables, tracks shared physical pages through PFN reference counts, write-protects shared mappings, and handles write faults by creating private page copies and invalidating stale TLB entries.

Concepts: copy-on-write, page tables, PFN reference counting, page faults, TLB invalidation, virtual-memory isolation.


Major Technical Areas

The project covers:

  • Process Management

    • fork()
    • cfork()
    • thread creation
    • process/thread lifecycle
    • parent-child relationships
  • Virtual Memory

    • mmap() / munmap() / mremap()
    • four-level x86-64 page tables
    • virtual-to-physical translation
    • VMAs and memory segments
    • copy-on-write
  • Concurrency & IPC

    • processes
    • pipes
    • descriptor duplication
    • synchronization
    • wait queues
    • Round-Robin scheduling
  • Kernel Development

    • system calls
    • file descriptors
    • exception handling
    • trace buffers
    • process information
    • memory validation
  • Low-Level Systems Programming

    • x86-64 assembly
    • direct system-call interfaces
    • page-table manipulation
    • physical-page reference counting
    • TLB invalidation
    • executable code relocation

Notes

The gemOS/ directory is retained as the cumulative OS source tree used throughout the project. The labs/ directory provides a cleaner record of the individual submitted implementations.

Ge# gemOS — x86-64 Operating System & Systems Programming

A cumulative systems-programming and operating-systems project based on gemOS, an educational x86-64 operating-system kernel developed through the CS330 course.

The project progresses from low-level Linux/POSIX programming and process management to kernel development involving virtual memory, system calls, exception handling, scheduling, tracing, threading, synchronization, and copy-on-write memory management.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages