nachos 5.0j(java版)学习笔记一:环境搭建

梗概:

  1. jdk安装配置
  2. proj1运行
  3. mips交叉编译器(附完整代码记录)
  4. proj2运行(附完整代码记录)
  5. nachos整理(包括proj1/2,项目源码/使用说明/实验报告)

写在前面:

nachos 5.0j可以在windows和Linux系统上运行;
对于proj1,可以直接导入eclipse进行编译;
project2需要交叉编译,而对于win系统中的此类的资料比较少,所以还是投向了linux的怀抱;(修改:后来,我发现,可以在Linux系统中交叉编译,然后将coff文件拷贝到eclipse里就行。)
但是笔者的笔记本过于垃圾,不想和虚拟机作斗争了,笔者最后用的是阿里云学生轻量级服务器(无图形界面);
下面我的环境搭建其实是针对无图形界面的Linux系统的,当然也适用于有图形界面的Linux系统;

1.java开发环境:jdk的安装配置

  1. 笔者用的是jdk-13_linux-x64_bin.tar.gz

  2. 解压文件
    $tar -xzvf jdk-13_linux-x64_bin.tar.gz
    ps:为了保持接下来目录一致,建议将解压文件移动到/root/usr/local/java目录下

  3. 配置环境变量
    $vi /etc/profile
    在最后面添加几句话:

      # jdkexport JAVA_HOME=/root/usr/local/java/jdk-13export CLASSPATH=.:$JAVA_HOME/jre/bin/lib.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexport PATH=$PATH:$JAVA_HOME/bin
    

    保存后,更新一下
    #source /etc/profile

  4. 验证安装是否成功
    $ java -version
    $ javac -version
    以上两个指令返回相应的版本信息,即为安装成功

2.运行proj1

将nachos-java.tar.gz解压

#tar -xzvf jdk-8u211-linux-x86.tar.gz

将nachos文件移动到root/usr/wp文件夹下,为了方便配置环境变量,建议跟我的目录一致,移动完之后用pwd和ls命令检验一下

# pwd
/root/usr/wp/nachos
# ls
ag  bin  machine  Makefile  network  proj1  proj2  proj3  proj4  README  security  test  threads  userprog  vm

添加nochos/bin目录到PATH环境变量

回到根目录,用vi编辑器编辑/etc/profile

#vi /etc/profile

在/etc/profile文件尾部添加

# nachos excutation
export PATH=$PATH:/root/usr/wp/nachos/bin

保存文件,更新一下

# source /etc/profile

在nochos/proj1目录下,执行编译make、运行nachos

root@iZ2ze1vavqma9q8lhrqq6wZ:~/usr/wp/nachos/proj1# ls
Makefile  nachos  nachos.conf
root@iZ2ze1vavqma9q8lhrqq6wZ:~/usr/wp/nachos/proj1# make
javac -classpath . -d . -sourcepath ../.. -g ../threads/ThreadedKernel.java
../../nachos/threads/KThread.java:311: warning: 'yield' may become a restricted identifier in a future releasepublic void run() { while (true) yield(); }^(to invoke a method called yield, qualify the yield with a receiver or type name)
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: ../../nachos/machine/Lib.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 warning
javac -classpath . -d . -sourcepath ../.. -g ../threads/Boat.java
root@iZ2ze1vavqma9q8lhrqq6wZ:~/usr/wp/nachos/proj1# nachos
nachos 5.0j initializing... config interrupt timer user-check grader
*** thread 0 looped 0 times
*** thread 1 looped 0 times
*** thread 0 looped 1 times
*** thread 1 looped 1 times
*** thread 0 looped 2 times
*** thread 1 looped 2 times
*** thread 0 looped 3 times
*** thread 1 looped 3 times
*** thread 0 looped 4 times
*** thread 1 looped 4 times
Machine halting!Ticks: total 2130, kernel 2130, user 0
Disk I/O: reads 0, writes 0
Console I/O: reads 0, writes 0
Paging: page faults 0, TLB misses 0
Network I/O: received 0, sent 0

此后,便可以修改代码,完成proj1的相关问题了,make命令-对整个项目进行编译,nachos命令-运行项目

3.mips交叉编译器

将mips-x86.linux-xgcc.tgz解压到nachos目录下
进入nachos/test目录下,配置环境变量

# export ARCHDIR=../mips-x86.linux-xgcc
# export PATH=/root/usr/wp/nachos/mips-x86.linux-xgcc:$PATH

检验一下

# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/root/usr/local/java/jdk-13/bin:/root/usr/wp/nachos/bin

编译

#make clean
#make

完整操作记录:

root@iZ2ze1vavqma9q8lhrqq6wZ:~# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/root/usr/local/java/jdk-13/bin:/root/usr/wp/nachos/bin
root@iZ2ze1vavqma9q8lhrqq6wZ:~# cd usr/wp/nachos
root@iZ2ze1vavqma9q8lhrqq6wZ:~/usr/wp/nachos# ls
ag  bin  machine  Makefile  mips-x86.linux-xgcc  mips-x86.linux-xgcc.tgz  network  proj1  proj2  proj3  proj4  README  security  test  threads  userprog  vm
root@iZ2ze1vavqma9q8lhrqq6wZ:~/usr/wp/nachos# cd test
root@iZ2ze1vavqma9q8lhrqq6wZ:~/usr/wp/nachos/test# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/root/usr/local/java/jdk-13/bin:/root/usr/wp/nachos/bin
root@iZ2ze1vavqma9q8lhrqq6wZ:~/usr/wp/nachos/test# export ARCHDIR=../mips-x86.linux-xgcc
root@iZ2ze1vavqma9q8lhrqq6wZ:~/usr/wp/nachos/test# export PATH=/root/usr/wp/nachos/mips-x86.linux-xgcc:$PATH
root@iZ2ze1vavqma9q8lhrqq6wZ:~/usr/wp/nachos/test# echo $PATH
/root/usr/wp/nachos/mips-x86.linux-xgcc:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/root/usr/local/java/jdk-13/bin:/root/usr/wp/nachos/bin
root@iZ2ze1vavqma9q8lhrqq6wZ:~/usr/wp/nachos/test# make clean
rm -f strt.s *.o *.coff libnachos.a
root@iZ2ze1vavqma9q8lhrqq6wZ:~/usr/wp/nachos/test# make
../mips-x86.linux-xgcc/mips-gcc -O2 -B../mips-x86.linux-xgcc/mips- -G 0 -Wa,-mips1 -nostdlib -ffreestanding -c assert.c
../mips-x86.linux-xgcc/mips-ar rv libnachos.a assert.o
a - assert.o
../mips-x86.linux-xgcc/mips-gcc -O2 -B../mips-x86.linux-xgcc/mips- -G 0 -Wa,-mips1 -nostdlib -ffreestanding -c atoi.c
../mips-x86.linux-xgcc/mips-ar rv libnachos.a atoi.o
a - atoi.o
../mips-x86.linux-xgcc/mips-gcc -O2 -B../mips-x86.linux-xgcc/mips- -G 0 -Wa,-mips1 -nostdlib -ffreestanding -c printf.c
../mips-x86.linux-xgcc/mips-ar rv libnachos.a printf.o
a - printf.o
../mips-x86.linux-xgcc/mips-gcc -O2 -B../mips-x86.linux-xgcc/mips- -G 0 -Wa,-mips1 -nostdlib -ffreestanding -c readline.c
../mips-x86.linux-xgcc/mips-ar rv libnachos.a readline.o
a - readline.o
../mips-x86.linux-xgcc/mips-gcc -O2 -B../mips-x86.linux-xgcc/mips- -G 0 -Wa,-mips1 -nostdlib -ffreestanding -c stdio.c
../mips-x86.linux-xgcc/mips-ar rv libnachos.a stdio.o
a - stdio.o
../mips-x86.linux-xgcc/mips-gcc -O2 -B../mips-x86.linux-xgcc/mips- -G 0 -Wa,-mips1 -nostdlib -ffreestanding -c strncmp.c
../mips-x86.linux-xgcc/mips-ar rv libnachos.a strncmp.o
a - strncmp.o
../mips-x86.linux-xgcc/mips-gcc -O2 -B../mips-x86.linux-xgcc/mips- -G 0 -Wa,-mips1 -nostdlib -ffreestanding -c strcat.c
../mips-x86.linux-xgcc/mips-ar rv libnachos.a strcat.o
a - strcat.o
../mips-x86.linux-xgcc/mips-gcc -O2 -B../mips-x86.linux-xgcc/mips- -G 0 -Wa,-mips1 -nostdlib -ffreestanding -c strcmp.c
../mips-x86.linux-xgcc/mips-ar rv libnachos.a strcmp.o
a - strcmp.o
../mips-x86.linux-xgcc/mips-gcc -O2 -B../mips-x86.linux-xgcc/mips- -G 0 -Wa,-mips1 -nostdlib -ffreestanding -c strcpy.c
../mips-x86.linux-xgcc/mips-ar rv libnachos.a strcpy.o
a - strcpy.o
../mips-x86.linux-xgcc/mips-gcc -O2 -B../mips-x86.linux-xgcc/mips- -G 0 -Wa,-mips1 -nostdlib -ffreestanding -c strlen.c
../mips-x86.linux-xgcc/mips-ar rv libnachos.a strlen.o
a - strlen.o
../mips-x86.linux-xgcc/mips-gcc -O2 -B../mips-x86.linux-xgcc/mips- -G 0 -Wa,-mips1 -nostdlib -ffreestanding -c memcpy.c
../mips-x86.linux-xgcc/mips-ar rv libnachos.a memcpy.o
a - memcpy.o
../mips-x86.linux-xgcc/mips-gcc -O2 -B../mips-x86.linux-xgcc/mips- -G 0 -Wa,-mips1 -nostdlib -ffreestanding -c memset.c
../mips-x86.linux-xgcc/mips-ar rv libnachos.a memset.o
a - memset.o
../mips-x86.linux-xgcc/mips-cpp  start.s > strt.s
../mips-x86.linux-xgcc/mips-as -mips1 -o start.o strt.s
rm strt.s
../mips-x86.linux-xgcc/mips-ranlib libnachos.a
../mips-x86.linux-xgcc/mips-gcc -O2 -B../mips-x86.linux-xgcc/mips- -G 0 -Wa,-mips1 -nostdlib -ffreestanding -c halt.c
../mips-x86.linux-xgcc/mips-ld -s -T script -N -warn-common -warn-constructors -warn-multiple-gp -o halt.coff halt.o start.o -lnachos
../mips-x86.linux-xgcc/mips-gcc -O2 -B../mips-x86.linux-xgcc/mips- -G 0 -Wa,-mips1 -nostdlib -ffreestanding -c sh.c
../mips-x86.linux-xgcc/mips-ld -s -T script -N -warn-common -warn-constructors -warn-multiple-gp -o sh.coff sh.o start.o -lnachos
../mips-x86.linux-xgcc/mips-gcc -O2 -B../mips-x86.linux-xgcc/mips- -G 0 -Wa,-mips1 -nostdlib -ffreestanding -c matmult.c
../mips-x86.linux-xgcc/mips-ld -s -T script -N -warn-common -warn-constructors -warn-multiple-gp -o matmult.coff matmult.o start.o -lnachos
../mips-x86.linux-xgcc/mips-gcc -O2 -B../mips-x86.linux-xgcc/mips- -G 0 -Wa,-mips1 -nostdlib -ffreestanding -c sort.c
../mips-x86.linux-xgcc/mips-ld -s -T script -N -warn-common -warn-constructors -warn-multiple-gp -o sort.coff sort.o start.o -lnachos
../mips-x86.linux-xgcc/mips-gcc -O2 -B../mips-x86.linux-xgcc/mips- -G 0 -Wa,-mips1 -nostdlib -ffreestanding -c echo.c
../mips-x86.linux-xgcc/mips-ld -s -T script -N -warn-common -warn-constructors -warn-multiple-gp -o echo.coff echo.o start.o -lnachos
../mips-x86.linux-xgcc/mips-gcc -O2 -B../mips-x86.linux-xgcc/mips- -G 0 -Wa,-mips1 -nostdlib -ffreestanding -c cat.c
../mips-x86.linux-xgcc/mips-ld -s -T script -N -warn-common -warn-constructors -warn-multiple-gp -o cat.coff cat.o start.o -lnachos
../mips-x86.linux-xgcc/mips-gcc -O2 -B../mips-x86.linux-xgcc/mips- -G 0 -Wa,-mips1 -nostdlib -ffreestanding -c cp.c
../mips-x86.linux-xgcc/mips-ld -s -T script -N -warn-common -warn-constructors -warn-multiple-gp -o cp.coff cp.o start.o -lnachos
../mips-x86.linux-xgcc/mips-gcc -O2 -B../mips-x86.linux-xgcc/mips- -G 0 -Wa,-mips1 -nostdlib -ffreestanding -c mv.c
../mips-x86.linux-xgcc/mips-ld -s -T script -N -warn-common -warn-constructors -warn-multiple-gp -o mv.coff mv.o start.o -lnachos
../mips-x86.linux-xgcc/mips-gcc -O2 -B../mips-x86.linux-xgcc/mips- -G 0 -Wa,-mips1 -nostdlib -ffreestanding -c rm.c
../mips-x86.linux-xgcc/mips-ld -s -T script -N -warn-common -warn-constructors -warn-multiple-gp -o rm.coff rm.o start.o -lnachos

4.运行proj2

进入proj2
编译

#make

将test中的halt.coff复制到proj2

# cp ../test/halt.coff ../proj2

运行

# nachos -x halt.coff

完整记录如下:

root@iZ2ze1vavqma9q8lhrqq6wZ:~/usr/wp/nachos/test# cd ../proj2
root@iZ2ze1vavqma9q8lhrqq6wZ:~/usr/wp/nachos/proj2# make
javac -classpath . -d . -sourcepath ../.. -g ../userprog/UserKernel.java
../../nachos/threads/KThread.java:311: warning: 'yield' may become a restricted identifier in a future releasepublic void run() { while (true) yield(); }^(to invoke a method called yield, qualify the yield with a receiver or type name)
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: ../../nachos/machine/Lib.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 warning
javac -classpath . -d . -sourcepath ../.. -g ../threads/Boat.java
root@iZ2ze1vavqma9q8lhrqq6wZ:~/usr/wp/nachos/proj2# cp ../test/halt.coff ../proj2
root@iZ2ze1vavqma9q8lhrqq6wZ:~/usr/wp/nachos/proj2# ls
halt.coff  Makefile  nachos  nachos.conf
root@iZ2ze1vavqma9q8lhrqq6wZ:~/usr/wp/nachos/proj2# nachos -x halt.coff
nachos 5.0j initializing... config interrupt timer processor console user-check grader
*** thread 0 looped 0 times
*** thread 1 looped 0 times
*** thread 0 looped 1 times
*** thread 1 looped 1 times
*** thread 0 looped 2 times
*** thread 1 looped 2 times
*** thread 0 looped 3 times
*** thread 1 looped 3 times
*** thread 0 looped 4 times
*** thread 1 looped 4 times
Testing the console device. Typed characters
will be echoed until q is typed.

接下来就可以开始着手proj2的相关问题了。

nachos 5.0j(java版)学习笔记一:环境搭建相关推荐

  1. 深度学习(二)theano学习笔记(1)环境搭建

    theano学习笔记(1)环境搭建 原文地址:http://blog.csdn.net/hjimce/article/details/46654229 作者:hjimce 搭建theano实属不易,因 ...

  2. Go学习笔记_环境搭建

    Go学习笔记_环境搭建 Go背景知识 go的特点(官网): Build fast, reliable, and efficient software at scale- Go is an open s ...

  3. 微信公众号开发-Java版学习笔记

    微信公众号开发整体不难,主要是熟悉微信公众号常用的一些接口文档,然后会一门后端语言(比如java)即可. 罗召勇老师教程:微信公众号开发-Java版(蓝桥罗召勇) 微信公众号文档:微信公众号官方文档 ...

  4. 李沐《动手学深度学习》第二版 pytorch笔记1 环境搭建

    李沐<动手学深度学习>第二版pytorch笔记1 搭建环境 文章目录 李沐<动手学深度学习>第二版pytorch笔记1 搭建环境 此时尚有耐心 虚拟环境搭建 创建虚拟环境 查看 ...

  5. cocos2d-x lua 学习笔记(1) -- 环境搭建

    Cocos2d-x 3.0以上版本的环境搭建和之前的Cocos2d-x 2.0 版差异较大的,同时从Cocos2d-x 3.0项目打包成apk安卓应用文件,搭建安卓环境的步骤有点繁琐,但搭建一次之后, ...

  6. Django学习笔记 开发环境搭建

    为什么使用django? 1.支持快速开发:用python开发:数据库ORM系统,并不需要我们手动地构造SQL语句,而是用python的对象访问数据库,能够提升开发效率. 2.大量内置应用:后台管理系 ...

  7. HarmonyOS_BearPi-HM Nano学习笔记之环境搭建

    前言:期待了已久的小熊派鸿蒙开发板终于出世了,12月11号准时抢到优惠券,果断下单,运费一起也就是29.9,实话说,很划算的,毕竟对自己的学习投资嘛,得舍得. 下面我把代码仓库.资料.视频课程地址贴出 ...

  8. Linux学习笔记1—环境搭建

    文章目录 一.Linux是什么? 二.购买云服务器搭建Linux环境 1 Xshell 1.1 Linux下简单的用户管理 1.2 Xshell的复制粘贴 2 vscode+RemoteSSH插件 3 ...

  9. 移植u-boot1.1.6到友善mini2440学习笔记之环境搭建(系列之一)

    前记:两年前就想学习ARM,由于一些原因耽搁了下来.如今迫于找硬件岗位工作的压力,不得不硬着头皮学习ARM,以前就知道ARM入门是计较困难的,如今真是体会深切啊,全是心酸泪,不仅自己的无知跟自己作对, ...

  10. wepy学习笔记之环境搭建

    写了近两年小程序了,越来越发现原生小程序有太多鸡肋的地方.所以今天准备尝试一下wepy,正好最近手上有个外包,可以拿来练手.如果可以的话,或许会出一系列wepy相关的文章(偏实战),欢迎大佬们指正. ...

最新文章

  1. FPP(彩包)、COEM(简包)、MOLP(license授) 介绍
  2. 北邮国院c语言期末考试题,北邮C语言复习题2014.ppt
  3. 文件寄生——寄生虫自体繁衍的道路
  4. Java创建线程的三种方式,以前只知道两种,现在添加一种Callable与FutureTask创建的方式
  5. P3952-时间复杂度【模拟】
  6. php 模拟请求工具,http-mock-master模拟HTTP请求库
  7. 采用HTML5搭建的多个网站尝鲜试用
  8. jfreechart折线图y轴刻度值_Python matplotlib绘制折线图
  9. cad导出pdf_“又”一款免费的CAD批量导出PDF、DWF、PLT神兵利器
  10. 一元多次方程C语言,C语言解决多元多次方程.(19页)-原创力文档
  11. 【转】对人生的看法和感悟
  12. 基于单片机的加油机系统
  13. SAP 谈谈存货分析报表
  14. 玩转基因组浏览器之查看gwas结果
  15. 《Dreamweaver CS6 完全自学教程》笔记 第十七章:Spry 框架技术
  16. krait和kryo_回归四核的自主Kryo架构_手机_手机评测-中关村在线
  17. WIN32 进程间通讯-共享内存
  18. 【期货量化】通过日结算率计算日/月收益率以及利用resample进行时间序列处理
  19. 新买的iphone如何保证安全
  20. 基于matlab的瑞利信道模拟和仿真

热门文章

  1. tomcat编码设置
  2. 对Retinex算法的一些理解
  3. 惠普台式电脑引导不了系统_惠普电脑进入bios设置引导模式操作步骤图文
  4. Oracle数据库以及客户端下载资源
  5. 高德地图No implementation found for long com.autonavi.amap.mapcore.MapCore.nativeNewInstance
  6. UNITY游戏开发源码
  7. Jersey入门教程
  8. jersey 过滤_Jersey
  9. 吴恩达深度学习——人脸识别与神经风格转换
  10. 使用花生壳做内网穿透