• 在gem5的full system下运行 alpha编译的测试程序 running gem5 on ubuntu in full system mode in alpha


    背景

    先需要在full system下运行gem5,通过网上查找资料以及向别人请教,终于成功运行,网上大多是关于alpha指令集的,且都是英文的,为了方便大家学习,现在总结一下,希望对大家有所帮助。

    首先需要安装gem5-stable,可以参考我前面的一篇博客:

    http://blog.csdn.net/wyj7260/article/details/8267345

    首先做一下声明,关于ubuntu的版本:ubuntu的版本没有明确的要求,我在分别在ubuntu的10.04,11.04,以及12.10上安装成功。gem5版本也没有

    特别的要求,我用的是gem5-stable_2012_02_02,如果是初次接触的话,最好选用新的版本,因为听实验室师兄说,gem5现在关注的人逐渐增多

    ,最近一段时间gem5对alpha的支持基本没有新的更新,但是对x86的支持越来越好,而且gem5的新版本代码书写比较规范。

    这篇文章介绍full system in alpha。

    安装过程:

    下载full system需要的两个包:

    首先在安装好gem5-stable之后,再到官网下载full system需要的包:

    Full System Files : http://www.m5sim.org/dist/current/m5_system_2.0b3.tar.bz2

    linux-dist : http://www.m5sim.org/dist/current/linux-dist.tgz

    安装:记我的gem5-stable安装目录为$GEM

    a)      ~/gem5-stable$  mkdir dist

    b)      将包m5_system_2.03.tar.bz2 复制到dist目录下

    b) ~/gem5-stable$ cd dist/

    c) ~/gem5-stable/dist$  tar -xvf m5_system_2.03.tar.bz2

    d) ~/gem5-stable/dist$ cd m5_system_2.0b3/

    f) ~/gem5-stable/dist/m5_system_2.0b3$ mv./binaries/ ../binaries

    g) ~/gem5-stable/dist/m5_system_2.0b3$ mv./disks/ ../disks

    h) ~/gem5-stable/dist$ rm -rfm5_system_2.0b3

    i)修改$GEM5/config/common/SysPath.py 文件:

    把exceptKeyError:

      path = [ '/dist/m5/system', '/n/poolfs/z/dist/m5/system

    修改成

    except KeyError:

    path = [ '/dist/m5/system', ' /home/wyj2/gem5-stable/dist' ]

    运行

    1、  首先编译gem5.opt

    ~/gem5-stable $ scons ./build/ALPHA/gem5.opt

    可以通过 $GEM5/m5out/system.terminal查看启动linux内核的monitor进程。

    2、运行模拟的linux系统

    ./build/ALPHA/gem5.opt ./configs/example/fs.py

    将看到如下界面

    gem5 Simulator System. http://gem5.org

    gem5 is copyrighted software; use the --copyright option for details.

    gem5 compiled Jul 13 2013 15:50:46

    gem5 started Jul 13 2013 15:53:18

    gem5 executing on jsi-desktop

    command line: ./build/ALPHA/gem5.opt ./configs/example/fs.py

    Global frequency set at 1000000000000 ticks per second

    info: kernel located at: /home/wyj2/gem5-stable/dist/binaries/vmlinux

    Listening for system connection on port 3456

          0: system.tsunami.io.rtc:Real-time clock set to Thu Jan  100:00:00 2009

    warn: CoherentBus system.membus has no snooping ports attached!

    0: system.remote_gdb.listener: listening for remote gdb #0 on port 7000

    **** REAL SIMULATION ****

    info: Entering event queue @ 0. Starting simulation...

    warn: Prefetch instructions in Alpha do not do anything

    warn: Prefetch instructions in Alpha do not do anything

    3、开启另外一个ssh界面,使用M5Term来与simulatedsystem进行交互

    ~/gem5-stable$cd ./util/term

    ~/gem5-stable$make

    ~/gem5-stable$sudomake install

    ~/gem5-stable$m5termlocalhost 3456

    4、这样就进入了模拟出来的系统:

    #ls后就看到如下:

    # ls

    benchmarks  etc        linuxrc     modules     sys        var

    bin         iscsi       lost+found  proc       tmp

    dev         lib         mnt         sbin        usr

    5、在模拟系统中运行一个测试程序试试:

    #cd benchmarks

    #ls

    将看到如下几个测试程序:

    aio-bench           netperf-bin         surge

    micros              pthread_mutex_test

    #./pthread_mutex_test2 2

    运行结果如下:

    Using 2 threadsfor 2 iters

    Counter value is 4

    #

    如何将程序mount进模拟的系统

    现在以将$GEM/tests/test-progs/hello/bin/alpha/linux/hello,mount进模拟的系统为例,讲述如何将编译好的程序mount进被模拟的系统。

    1、将hello文件拷贝到当前路径/gem5-stable$ cp./tests/test-progs/hello/bin/alpha/linux/hello ./hello

    2、~/gem5-stable$ sudomount -o,loop,offset=32256 ./dist/disks/linux-latest.img /mnt

    关于偏移量32256请参考链接:http://my.oschina.net/toyandong/blog/65002

    3、显示一下/mnt,可以看到挂载好的操作系统

    ~/gem5-stable$ ls/mnt

    benchmarks  dev iscsi  linuxrc     mnt     proc  sys  usr

    bin         etc lib    lost+found  modules sbin  tmp  var

    4、  在使用linux的image文件之前,应该执行umount操作。

    ~/gem5-stable$ sudo umount /mnt

    5、  重新开启模拟的linux,进入模拟的linux (参考本文 “运行” 中的2和3)

    #ls

    可以看到我们添加的testGem5目录

    benchmarks  etc        linuxrc     modules     sys        usr

    bin         iscsi       lost+found  proc       testGem5   var

    dev         lib         mnt         sbin        tmp

    6、#cd testGem5

      #./hello

    执行结果:

    Hello world!

    #

    参考链接:

    http://www.m5sim.org/Running_M5_in_Full-System_Mode

    http://novel.ict.ac.cn/qguo/pdf/gem5.pdf

    http://gem5.org/dist/tutorials/hipeac2012/gem5_hipeac.pdf

    以及参考师兄的ppt

  • 相关阅读:
    sys模块详解
    os模块详解2
    tyvj 1203 机器分配
    洛谷 P1496 火烧赤壁
    P1204 [USACO1.2]挤牛奶Milking Cows
    bzoj 2120 数颜色
    P2056 采花
    P1972 [SDOI2009]HH的项链
    9.20模拟赛
    P2709 小B的询问
  • 原文地址:https://www.cnblogs.com/dyllove98/p/3188341.html
Copyright © 2020-2023  润新知