MIT6.S081学习笔记【一】

"MIT6.S081学习笔记【一】"

Posted by Simon on September 14, 2021

笔记

process

每一个进程有自己私有的用户态内存空间,包括指令、数据、堆栈。

内核会在CPU间调度进程的执行,当一个进程进入“等待”状态时,内核会保存当前进程执行的CPU寄存器数据,当其被唤醒时,会reload保存的数据。内核使用PID来唯一标识一个进程。

fork

fork是linux的一个系统调用,fork会创建一个新的进程作为调用者的子进程。fork在父进程中返回子进程的PID,在子进程中返回0,返回负数表示调用出错。

LAB

启动 xv6

  1. 准备wsl环境,下载运行ubuntu-20,这里遇到一个问题,wsl启动ubuntu后无法连接网络,解决方案如下:

    1. /etc/wsl.conf中加入:

      [network]
      generateResolvConf = false
      
    2. PowerShell重启WSL

      wsl.exe --shutdown
      
    3. 修改/etc/resolv.conf

      nameserver 223.5.5.5
      nameserver 223.6.6.6
      
  2. 换国内源

    cd /etc/apt/
    sudo mv sources.list sources.list.bak
    vim sources.list
       
    deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
       
    sudo apt-get update && sudo apt-get upgrade
    
  3. 安装编译工具

    sudo apt-get install git build-essential gdb-multiarch qemu-system-misc gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu 
    
  4. 编译&启动

    git clone git://g.csail.mit.edu/xv6-labs-2020 && cd xv6-labs-2020
    git checkout util
    make qemu