PintOS安装教程
安装预置工具
- 使用编辑器打开源文件(也可以去目录下双击打开)
sudo vi /etc/apt/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
- 安装工具
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install libncurses5-dev
sudo apt-get install libx11-dev
sudo apt-get install libxrandr-dev
sudo apt-get install binutils
sudo apt-get install perl
sudo apt-get install make
sudo apt-get install gdb
sudo apt-get install qemu
sudo apt-get install geany
sudo apt-get install git
sudo apt-get install qemu-system-x86
Ubuntu18.10开始,qemu是个空包,需装qemu-system-x86
下载Pintos
- 新建目录,在
/home/{username}
文件夹创建pintos
文件夹 (建议不要直接装在/home
文件夹下,可能因权限问题pintos无法正常运行)
cd /home/{username}
mkdir pintos
- 进入pintos目录,从网上git最新的pintos到本地
git clone git://pintos-os.org/pintos-anon
配置Pintos
-
打开pintos-gdb文件,修改其中的
GDBMACROS
变量,将gdb-macros
完整路径赋值给该变量,gdb-macros文件位于.../pintos-anon/src/misc
; -
打开Makefile文件将
LOADLIBES
变量改为LDLIBS
; -
进入
.../pintos-anon/src/utils
目录输入make
编译utils;- Ubuntu22.04会报错,这个时候我们需要在
/usr/include
目录下打开终端输入sudo touch stropts.h
添加一个空的头文件,并且修改.../pintos-anon/src/utils/squish-pty.c
文件,将288-294行如下一段代码注释掉
然后/* if (isastream (slave)) { if (ioctl (slave, I_PUSH, "ptem") < 0 || ioctl (slave, I_PUSH, "ldterm") < 0) fail_io ("ioctl"); } */
make
编译时虽有warning但可以正常编译
- Ubuntu22.04会报错,这个时候我们需要在
-
编辑
.../pintos-anon/src/threads/Make.vars
(第7行):更改bochs
为qemu
; -
进入
.../pintos-anon/src/threads
目录输入make
编译线程目录; -
编辑
.../pintos-anon/src/utils/pintos
(约在第103⾏):替换bochs
为qemu
; -
编辑
.../pintos-anon/src/utils/pintos
(约在第257行):替换kernel.bin
为完整的路径:.../pintos-anon/src/threads/build/kernel.bin
; (在做userprog实验时,需把路径中的threads改成userprog) -
编辑
.../pintos-anon/src/utils/pintos
(约在621行):替换qemu-system-i386
为qemu-system-x86_64
; -
编辑
.../pintos-anon/src/utils/Pintos.pm
(约在362行):替换loader.bin
为完整路径.../pintos-anon/src/threads/build/loader.bin
; (和7同理) -
用vi编辑器打开
~/.bashrc
(或打开隐藏文件夹显示,/home/{username}
目录下双击点开~/.bashrc
),在最后一行添加export PATH=$PATH:/user/bin:/home/.../pintos-anon/src/utils
; -
重新打开终端输入
source ~/.bashrc
; -
进入到pintos目录下运行
pintos run alarm-multiple
,若没有报错且出现Execution of 'alarm-multiple' complete
则代表成功;