Skip to content

This Repo is the assignments of Advanced Operating System(Based on xv6)

Notifications You must be signed in to change notification settings

wangyu-/Operating_System-xv6

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This Repo is the assignments of Advanced Operating System(Based on xv6)

This project is to add some new functions to the xv6 system developed by MIT PDOS

To Run my project or original xv6, you should install qemu in your linux machine first;
Then run:

  • make command
  • make qemu or make qemu-nox

For quiting xv6, you should press ctrl+A+C and then insert quit command

For the specific test, you should follow the instruction from README in each project folder.

This project mainly divided into four parts:

  • Project1: xv6 intro: This first project is just a warmup, and thus relatively light on work. The goal of the project is simple: to add a system call to xv6. Your system call, getprocsinfo() , simply returns the PID value and process name for each of the processes that exists in the system at the time of the call.

  • Project2: Null pointer and share memory

    • Part A: Null-pointer Dereference: In xv6, the VM system uses a simple two-level page table as discussed in class. As it currently is structured, 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 (might not as you might expect as in Linux); rather, you will see whatever the the pointer in the your program points to, it will not trigger the nullpointer exception. Thus, the thing you might do is create a program that dereferences a null pointer.
    • PartB: In this part of the project, you'll explore how to add a shared-memory page to processes that are interested in communicating through memory. The basic process will be simple: there is a new system call you must create, called void *shmem_access(int page_number) , which should make a shared page available to the process calling it.
      One other call is needed: int shmem_count(int page_number). This call tells you, for a particular shared page, how many processes currently are sharing that page.
  • Project3: In this project, you'll be adding real kernel threads to xv6. Specifically, you'll do three things.
    First, you'll define a new system call to create a kernel thread, called clone() , as well as one to wait for a thread calledjoin().
    Then, you'll use clone() to build a little thread library, with a thread_create() call and lock_acquire() and lock_release() functions.
    Finally, you'll show these things work by using the TA's tests.

  • Project4:

    • Part A : xv6 scheduler: to be done in xv6 OS environment.
      In this part, you'll be putting a new scheduler into xv6. It is called a simple priority-based scheduler .
      The basic idea is simple: assign each running process a priority, which is an integer number, in this case either 1 (low priority) or 2 (high priority). At any given instance, the scheduler should run processes that have the high priority (2). If there are two or more processes that have the same high priority, the scheduler should round-robin between them. A low-priority (level 1) process does NOT run as long as there are high-priority jobs available to run.
    • Part B: File System:
      1. file system checker: to be done on the lab machines, so you can learn more about programming in C on a typical UNIX-based platform (Linux).
        In this part, you will be developing a working file system checker. A checker reads in a file system image and makes sure that it is consistent. When it isn't, the checker takes steps to fix the problems it sees; however, we won't be doing any fixes this time to keep your life a little simpler.
        We will use the xv6 file system image as the basic image that we will be reading and checking. The file fs.h includes the basic structures you need to understand, including the superblock, on disk inode format (struct dinode), and directory entry format (struct dirent). The tool mkfs.c will also be useful to look at, in order to see how an empty file-system image is created.

      2. File system integrity: to be done in the xv6 environment.In this part, you'll be changing the existing xv6 file system to add protection from data corruption. In real storage systems, silent corruption of data is a major concern, and thus many techniques are usually put in place to detect (and recover) from blocks that go bad.
        Specifically, you'll do three things.

        • First, you'll modify the code to allow the user to create a new type of file that keeps a checksum for every block it points to. Checksums are used by modern storage systems in order to detect silent corruption.
        • Second, you'll have to change the file system to handle reads and writes differently for files with checksums. Specifically, when writing out such a file, you'll have to create a checksum for every block of the file; when reading such a file, you'll have to check and make sure the block still matches the stored checksum, returning an error code (-1) if it doesn't. In this way, your file system will be able to detect corruption!
        • Third, for information purposes, you will also modify the stat() system call to dump some information about the file. Thus, you should write a little program that, given a file name, not only prints out the file's size, etc., but also some information about the file's checksums

=========================================================================

The Information below comes from the Original XV6

xv6 is a re-implementation of Dennis Ritchie's and Ken Thompson's Unix Version 6 (v6). xv6 loosely follows the structure and style of v6, but is implemented for a modern x86-based multiprocessor using ANSI C.

ACKNOWLEDGMENTS

xv6 is inspired by John Lions's Commentary on UNIX 6th Edition (Peer to Peer Communications; ISBN: 1-57398-013-7; 1st edition (June 14, 2000)). See also https://pdos.csail.mit.edu/6.828/, which provides pointers to on-line resources for v6.

xv6 borrows code from the following sources: JOS (asm.h, elf.h, mmu.h, bootasm.S, ide.c, console.c, and others) Plan 9 (entryother.S, mp.h, mp.c, lapic.c) FreeBSD (ioapic.c) NetBSD (console.c)

The following people have made contributions: Russ Cox (context switching, locking), Cliff Frey (MP), Xiao Yu (MP), Nickolai Zeldovich, and Austin Clements.

We are also grateful for the bug reports and patches contributed by Silas Boyd-Wickizer, Anton Burtsev, Cody Cutler, Mike CAT, Tej Chajed, eyalz800, Nelson Elhage, Saar Ettinger, Alice Ferrazzi, Nathaniel Filardo, Peter Froehlich, Yakir Goaron,Shivam Handa, Bryan Henry, Jim Huang, Alexander Kapshuk, Anders Kaseorg, kehao95, Wolfgang Keller, Eddie Kohler, Austin Liew, Imbar Marinescu, Yandong Mao, Matan Shabtay, Hitoshi Mitake, Carmi Merimovich, Mark Morrissey, mtasm, Joel Nider, Greg Price, Ayan Shafqat, Eldar Sehayek, Yongming Shen, Cam Tenny, tyfkda, Rafael Ubal, Warren Toomey, Stephen Tu, Pablo Ventura, Xi Wang, Keiichi Watanabe, Nicolas Wolovick, wxdao, Grant Wu, Jindong Zhang, Icenowy Zheng, and Zou Chang Wei.

The code in the files that constitute xv6 is Copyright 2006-2018 Frans Kaashoek, Robert Morris, and Russ Cox.

ERROR REPORTS

Please send errors and suggestions to Frans Kaashoek and Robert Morris (kaashoek,rtm@mit.edu). The main purpose of xv6 is as a teaching operating system for MIT's 6.828, so we are more interested in simplifications and clarifications than new features.

BUILDING AND RUNNING XV6

To build xv6 on an x86 ELF machine (like Linux or FreeBSD), run "make". On non-x86 or non-ELF machines (like OS X, even on x86), you will need to install a cross-compiler gcc suite capable of producing x86 ELF binaries (see https://pdos.csail.mit.edu/6.828/). Then run "make TOOLPREFIX=i386-jos-elf-". Now install the QEMU PC simulator and run "make qemu".

About

This Repo is the assignments of Advanced Operating System(Based on xv6)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 86.6%
  • Assembly 3.8%
  • Makefile 3.4%
  • Shell 2.3%
  • Perl 2.1%
  • Ruby 1.0%
  • OpenEdge ABL 0.8%