nachos 5.0j(java版)学习笔记一:环境搭建
nachos 5.0j(java版)學習筆記一:環境搭建
梗概:
寫在前面:
nachos 5.0j可以在windows和Linux系統上運行;
對于proj1,可以直接導入eclipse進行編譯;
project2需要交叉編譯,而對于win系統中的此類的資料比較少,所以還是投向了linux的懷抱;(修改:后來,我發現,可以在Linux系統中交叉編譯,然后將coff文件拷貝到eclipse里就行。)
但是筆者的筆記本過于垃圾,不想和虛擬機作斗爭了,筆者最后用的是阿里云學生輕量級服務器(無圖形界面);
下面我的環境搭建其實是針對無圖形界面的Linux系統的,當然也適用于有圖形界面的Linux系統;
1.java開發環境:jdk的安裝配置
筆者用的是jdk-13_linux-x64_bin.tar.gz
解壓文件
$tar -xzvf jdk-13_linux-x64_bin.tar.gz
ps:為了保持接下來目錄一致,建議將解壓文件移動到/root/usr/local/java目錄下
配置環境變量
$vi /etc/profile
在最后面添加幾句話:
保存后,更新一下
#source /etc/profile
驗證安裝是否成功
$ java -version
$ javac -version
以上兩個指令返回相應的版本信息,即為安裝成功
2.運行proj1
將nachos-java.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
在/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目錄下,配置環境變量
檢驗一下
# 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 -lnachos4.運行proj2
進入proj2
編譯
將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版)学习笔记一:环境搭建的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 阿里云服务器ECS按ctrl+alt+d
- 下一篇: android Dialog提示框。单选