日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

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

發(fā)布時(shí)間:2023/12/10 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 nachos 5.0j(java版)学习笔记一:环境搭建 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

nachos 5.0j(java版)學(xué)習(xí)筆記一:環(huán)境搭建

梗概:

  • jdk安裝配置
  • proj1運(yùn)行
  • mips交叉編譯器(附完整代碼記錄)
  • proj2運(yùn)行(附完整代碼記錄)
  • nachos整理(包括proj1/2,項(xiàng)目源碼/使用說明/實(shí)驗(yàn)報(bào)告)
  • 寫在前面:

    nachos 5.0j可以在windows和Linux系統(tǒng)上運(yùn)行;
    對(duì)于proj1,可以直接導(dǎo)入eclipse進(jìn)行編譯;
    project2需要交叉編譯,而對(duì)于win系統(tǒng)中的此類的資料比較少,所以還是投向了linux的懷抱;(修改:后來,我發(fā)現(xiàn),可以在Linux系統(tǒng)中交叉編譯,然后將coff文件拷貝到eclipse里就行。)
    但是筆者的筆記本過于垃圾,不想和虛擬機(jī)作斗爭(zhēng)了,筆者最后用的是阿里云學(xué)生輕量級(jí)服務(wù)器(無圖形界面);
    下面我的環(huán)境搭建其實(shí)是針對(duì)無圖形界面的Linux系統(tǒng)的,當(dāng)然也適用于有圖形界面的Linux系統(tǒng);

    1.java開發(fā)環(huán)境:jdk的安裝配置

  • 筆者用的是jdk-13_linux-x64_bin.tar.gz

  • 解壓文件
    $tar -xzvf jdk-13_linux-x64_bin.tar.gz
    ps:為了保持接下來目錄一致,建議將解壓文件移動(dòng)到/root/usr/local/java目錄下

  • 配置環(huán)境變量
    $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

  • 驗(yàn)證安裝是否成功
    $ java -version
    $ javac -version
    以上兩個(gè)指令返回相應(yīng)的版本信息,即為安裝成功

  • 2.運(yùn)行proj1

    將nachos-java.tar.gz解壓

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

    將nachos文件移動(dòng)到root/usr/wp文件夾下,為了方便配置環(huán)境變量,建議跟我的目錄一致,移動(dòng)完之后用pwd和ls命令檢驗(yàn)一下

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

    添加nochos/bin目錄到PATH環(huán)境變量

    回到根目錄,用vi編輯器編輯/etc/profile

    #vi /etc/profile

    在/etc/profile文件尾部添加

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

    保存文件,更新一下

    # source /etc/profile

    在nochos/proj1目錄下,執(zhí)行編譯make、運(yùn)行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的相關(guān)問題了,make命令-對(duì)整個(gè)項(xiàng)目進(jìn)行編譯,nachos命令-運(yùn)行項(xiàng)目

    3.mips交叉編譯器

    將mips-x86.linux-xgcc.tgz解壓到nachos目錄下
    進(jìn)入nachos/test目錄下,配置環(huán)境變量

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

    檢驗(yàn)一下

    # 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.運(yùn)行proj2

    進(jìn)入proj2
    編譯

    #make

    將test中的halt.coff復(fù)制到proj2

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

    運(yùn)行

    # 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的相關(guān)問題了。

    總結(jié)

    以上是生活随笔為你收集整理的nachos 5.0j(java版)学习笔记一:环境搭建的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。