-
- 運作測試程式
- 将程式mount進模拟的系統
- 交叉編譯
在終端1下打開dmtcp:
$ dmtcp_coordinator
終端2下,root權限引導FS:
終端3下,用m5和模拟的系統建立連接配接:
~gemfi-master$ cd ./util/term
~gemfi-master/util/term$ m5term localhost
參考在gem5的full system下運作 alpha編譯的測試程式 running gem5 on ubuntu in full system mode in alpha
運作測試程式
出現的界面如下:
# ls
benchmarks etc linuxrc modules sbin usr
bin iscsi lost+found parsec sys var
dev lib mnt proc tmp
進入benchmarks并運作一個例子:
# cd benchmarks
# ls
aio-bench netperf-bin
alpha_barrier_system_call_test pthread_mutex_test
micros surge
# ./pthread_mutex_test 2 2
Using threads for iters
Counter value is
将程式mount進模拟的系統
在終端4下,檢視img偏移量,參考:mount挂載img檔案
~gemfi-master$ cd ./dist/disks
$ fdisk -l linux-parsec---m5-with-test-inputs.img
Disk linux-parsec---m5-with-test-inputs.img: MB, bytes
heads, sectors/track, cylinders, total sectors
Units = 扇區 of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk identifier:
裝置 啟動 起點 終點 塊數 Id 系統
linux-parsec---m5-with-test-inputs.img1 + Linux
可以看到,起點為63,從 512*63 = 32256 開始挂載
~gemfi-master# cp ./tests/test-progs/hello/bin/alpha/linux/hello ./hello
~gemfi-master# mount -o,loop,offset=32256 ./dist/disks/linux-parsec-2-1-m5-with-test-inputs.img /mnt
ls檢視,可以看到mnt目錄,向其中建立檔案夾Gem-test,将hello拷貝至目錄下,并umount後重新啟動模拟系統:
~gemfi-master# ls /mnt
benchmarks dev iscsi linuxrc mnt proc sys usr
bin etc lib lost+found modules sbin tmp var
~gemfi-master# mkdir /mnt/testGemFI
~gemfi-master# cp ./hello /mnt/testGemFI/hello
~gemfi-master# umount /mnt
~gemfi-master# dmtcp_checkpoint build/ALPHA/gem5.opt configs/example/fs.py
在模拟出來的系統中可以看到:
# ls
Gem-test etc lost+found proc tmp
benchmarks iscsi mnt sbin usr
bin lib modules sys var
dev linuxrc parsec
運作hello程式,出現permission denied,添權重限即可:
# cd Gem-test
# ./hello
bash: ./hello: Permission denied
# chmod +x hello
# ./hello
Hello world!
交叉編譯
參考官方頁面Gem5 Download或學習日志Gem5學習03-Download,我使用的是x86主機,下載下傳交叉編譯器:gcc-4.3.2, glibc-2.6.1(NPTL, x86/32)
将壓縮包解壓縮,拷貝到/usr/local目錄下:
$ tar -xvf alphaev67-unknown-linux-gnu-x86-tar.bz2
$ cp -rv alphaev67-unknown-linux-gnu /usr/local
檢視PATH,現在還沒有交叉編譯器的路徑,編輯~/.bashrc檔案,添加路徑:
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
$ vim ~/.bashrc
在打開的檔案中添加:
修改後儲存退出,運作source使其立即生效:
$ source ~/.bashrc
現在嘗試編譯一個hello例子程式,輸入alpha後按Tab無法補全,執行編譯代碼,報錯如下:
$ alphaev67-unknown-linux-gnu-gcc -o hello hello.c -static -O2
alphaev67-unknown-linux-gnu-gcc: error trying to exec 'cc1': execvp: No such file or directory
該錯誤問題在于沒有打開/usr/local/alphaev67-unknown-linux-gnu/libexec/gcc/alphaev67-unknown-linux-gnu/4.3.2/下cc1檔案的權限,打開該目錄中所有檔案的權限即可:
$ cd /usr/local/libexec/gcc/alphaev67-unknown-linux-gnu//
$ ls
cc1 cc1plus collect2 f951 install-tools
$ chmod -R *
再次輸入alpha,按Tab鍵出現
alphaev67-unknown-linux-gnu-
,編譯C檔案使用gcc,輸入gcc即可:
$ alphaev67-unknown-linux-gnu-gcc -o hello hello.c -static -O2
$ ls
hello hello.c
按照上一内容步驟,将程式mount進模拟的系統即可。