CS162 PintOS

Jan 1, 2024 · 2 min read

I implemented part of an operating system called Pintos.

For this project in UC Berkeley’s CS162, I implemented part of an operating system called Pintos. The OS supports multi-threading, virtual memory, FFS file system, and user programs. The OS is written in C and x86 assembly.

The parts I implemented (with my team) are:

  1. User program setup and syscall handling
    1. Parsing user program arguments and passing them onto the user stack
    2. Setting up stack and heap for the user program
    3. Initializing PCB and passing load information to the PCB
    4. Sleeping the parent process, passing info to the parent process waiting on the child process to load, and waking up the parent process
    5. Implementing wait, exec, exit, sbrk
    6. Implementing FPU context initialization, saving, and restoring
  2. File System
    1. Implemented fs cache blocks using LRU eviction policy, free map, extensible inode, directory structures, and file structure
    2. Implemented file system calls create, remove, open, close, read, write, seek, tell, filesize, mkdir, readdir, isdir, inumber, chdir
  3. Multithreading
    1. Implemented thread scheduling using priority scheduling
    2. Implemented thread alarm system call
    3. Implemented user level threads
      1. Designing and implementing thread control block
      2. Designing and implementing kernel level user thread trapping (to allow user threads to get terminated by the kernel)
      3. Implementing pthread library functions pthread_create, pthread_exit, pthread_join, pthread_mutex_init, pthread_mutex_lock, pthread_mutex_unlock, pthread_sema_init, pthread_sema_up, pthread_sema_down.