-
This repository mainly focuses on projects for the online course "UW-Madison CS 537: Introduction to Operating Systems, Spring 2018" and the textbook Operating Systems: Three Easy Pieces.
-
This repo is duplicated from the skeleton repo.
-
Read project-descriptions for more informations.
- Docker
# Step1: Build Docker image
./xv6-container build
# Step2: Create Docker container
docker run -v "`pwd`":/home/xv6user/xv6 --name OSTEP -itd xv6env
# Step3: Enter Docker container
docker exec -it OSTEP bash
# Step4:
# * xv6-public # (MIT version)
# * xv6-wisc # (UW-Madison refactor version)
- Compile xv6
make qemu-nox
- Reference
- (Project 1a) Unix Utilities (cat, grep, zip/unzip)
- ✅ (May 12, 2021)
- Implement Unix utilities on my own, including cat, grep, zip/unzip.
- (Project 2a) Command Line Interpreter (My Unix Shell)
- ✅ (May 22, 2021)
- Basic shell: The shell supports both interactive mode and batch mode. In interactive mode, when a user types a command, the shell will use the
fork()
,execv()
, andwait()
syscalls to create a child process to execute the command. When the execution finishes, the main process will print the prompt again and wait for more user commands. - Build-in commands: Implement three built-in commands, including
exit
,cd
, andpath
(search path of the shell). - Redirection: With the support of redirection, a shell user can send the output of a program to a file rather than to the screen. I implement redirection with
open()
anddup2()
syscalls. Useopen()
to get the file descriptor of the target file, and then usedup2()
to duplicate the file descriptor of STDOUT. Example:ls -l > output
. - Parallel Commands: In this shell, users can run commands in parallel rather than starting a command only when the previous command finishes. Then, after starting all such processes, the shell uses a
wait()
loop to wait for them to complete. After all processes are done, return control to the user. Example:wish> ls -l & echo 123
- (Project 3a) Parallel Zip
- ✅ (June 19, 2021)
- In project 1a, I implemented a simple compression tool based on run-length encoding, known simply as zip.
- In project 3a, I implement something similar, except I use threads to make a parallel version of zip.
- Keywords:
- Multi-thread: pthread
- File I/O: open, mmap, munmap
These projects all are to be done inside the xv6 kernel based on an early version of Unix and developed at MIT.
- (Project 1b) xv6: Introducing a new system call
- ✅ (May 15, 2021)
- Introduce a new system call
getreadcount()
. This project is very helpful for me to understand the process of calling a syscall.
- (Project 2b) An xv6 Lottery Scheduler
-
✅ (June 6, 2021)
-
Implement a lottery scheduler in xv6. To elaborate, I implement a syscall
settickets
to set the number of tickets of the calling process. The basic idea is simple: assign each running process a slice of the processor based in proportion to the number of tickets it has; the more tickets a process has, the more it runs. Each time slice, a randomized lottery determines the winner of the lottery; that winning process is the one that runs for that time slice.
- (Project 3b) Virtual Memory (Null Pointer and Read-Only Regions)
- ✅ (July 11, 2021)
- (Task1) Null-pointer Dereference: In xv6's VM system, user code is loaded into the very first part of the address space. Thus, if you dereference a null pointer, you will not see an exception; rather, you will see whatever code is the first bit of code in the program that is running. In Task1, we should make xv6 trap and kill the process that dereferences a null pointer.
- (Task2) Read-only Code: In most operating systems, code is marked read-only instead of read-write. However, in xv6 this is not the case, so a buggy program could accidentally overwrite its own text. In Task2, we need to implement 2 syscalls to avoid the accidents.
- mprotect(void *addr, int len): Changes the protection bits of the page range starting at
addr
and oflen
pages to be read only. Thus, a write to this region should cause a trap (and thus kill the process) after mprotect() finishes. - munprotect(void *addr, int len): Sets the region back to both readable and writeable.
- mprotect(void *addr, int len): Changes the protection bits of the page range starting at