/xv6-public

xv6 for education purpose

Primary LanguageC

Info:

Office Hours: Thur: 1:00 - 3:00 pm.

Room: WCH 110.

xv6 tutorial

resources

  • [class website] CW

  • [lab website] LW

  • [xv6 BOOK] XB Important! Please Read!!!

  • [xv6 source code reference] XS

  • [Official xv6] OX

  • [GDB commands] GC


  • [Lab 0: PC booting] LPC
    1. [Intro x86, stack] IS -- nice video to introduce x86 architecture, assembly, and stack
    2. [quick learn x86 assembly instructions] QLAI
    3. Appendix A -- PC hardware
    4. Appendix B -- The boot loader

  • Lab 0.5 syscalls & scheduler (no require to submit anything)
    1. implement a syscall int count(void) that counts number of syscalls.

      a. This syscall will return number of syscalls you called, from the begining of process started until to the calling 'count()'.

      b. First, you need to create a syscall. If you don't know how to create one, find a syscall such as open(), and see how it created. (hint: the files you need to modify -- user.h, defs.h, sysproc.c, sysfile.c, syscall.h, syscall.c, usys.S)

      c. Then, you need to implement it. You will change some code in proc.h and proc.c. You can either implement it in sysfile.c or sysproc.c.

      d. Finally, you can create a user file and test your syscall count you just created. If you want to create your own user file, then you should add it in Makefile. You are also able to change the code in usertests.c and add 'count()' some place in main().

    2. explain what policy of scheduler uses in xv6.

    3. Read the book.


  • [Lab 1] L11
    1. [tips] L1
    2. [test cases] TC

  • [Lab 2] L2

    Lab2 warm up:

    1. How to use thread_create, look up the test files.
    2. synchronization -- create a user program to implement game frisbee (Create serveral threads, they will play throwing and catching a frisbee game. Frisbee is a global variable, so it needs a lock to be protected in critical section. Who gets the lock means who gets the frisbee and releasing the lock means that thread are throwing the frisbee. There will be one of others will catch frisbee. Implement this scenario ).
    3. page table -- know how exec() works (you will be asked in walkthrough doc for lab2)

login sledge

open your terminal, type:

$ ssh your_cs_account@sledge.cs.ucr.edu 
$ password:*

Example

$ ssh sjin010@sledge.cs.ucr.edu

Tutorials

  • [set up git version control] SUG
  • [run xv6 & using gdb] XV6T 9 min

In the tutorial, instead of typing gdb, you should type:

$ gdb q -iex "set auto-load safe-path /home/csgrads/sjin010/xv6-public/"

change the directory

/home/csgrads/sjin010/xv6-public/

to your working directory. Find your working path, type

$pwd

in the terminal.

nice discussion of xv6

  • [xv6 syscalls] SYSC --- more detail tutorial. (eg: how to create a user file, how syscall works.).
  • [xv6 fork(), wait(), exec()] FWE --- play around with syscalls.
  • [xv6 scheduler] XS --- nice explanation of scheduler part.
  • [stack exec] SE --- explanation of stack and exec part.

Tips

How to exit xv6.

open another terminal, find the process PID of running QEMU

$ ps aux | less | grep uname

uname is your cs account. eg: sjin010

Then kill that process

$ kill -9 PID

How to exit xv6 (faster)

in the terminal that qemu is running,

  1. press 'CTL + A'
  2. press 'C'
  3. enter 'q'

Best way to get xv6 source code

$ git clone https://github.com/guilleiguaran/xv6.git