技能学习

最近开始学习南京大学计算机系统实验,刚刚完成PA0——开发环境配置。从安装 GNU/Linux 系统,熟悉Linux常用命令,学习Makefile,GDB,Git,TMux工具的的使用,编译并运行NEMU(全系统模拟器)。
PA0实验中遇到印象非常深刻的问题是:

  1. 在Installing Tools环节,系统崩溃自动重启无法开机,安装的是双系统,ubuntu 20.04 LTS。第一次系统崩溃不知道是什么问题,以为自己指令操作不当导致。只好重新安装系统(仍然是用之前做好的Ubuntu20.04LTS U盘),安装输入法、翻墙工具然后又是Installing Tools环节,无法关机(右上角的Poweroff按钮消失)后使用终端poweroff关机,此时已经凌晨2点以为解决了。早上起来无法开机(心态有点崩),在怀疑是系统与软件兼容问题?不过不是LTS版本吗?带着疑惑试了第三次重装,果然是一样的结果。后重新下载ubuntu 21.04,后来没有故障。由于自己对linux的不熟悉导致了浪费了很多时间,不过也熟悉了不少。

  2. 在Compiling and Running NEMU环节,在执行make menuconfig命令后出现报错,官方给的方案是自己解决。一开始看着报错摸不着头脑,分析报错信息,查看nemu文件构成,功能等,半个小时过去了没解决(就开始作弊了,百度搜索…不过还好也没搜到解决方案),只能接着想后来在报错信息发现了端倪和官方的提示(缺少的工具装上),根据信息装上了两个工具后成功解决这个报错。虽然是个小问题,但无不反应普通高校学校的同学对学术欺骗的态度,和面对问题的独立解决能力差和不耐心,值得自己反思。

这是实验的开端,官方预计解决时间是10h,我花了23h,可见与南大学子的差距。此次实验也是对自己能力的调整与突破:

  • 尝试全英文学习,使用英文doc,全英文版ubuntu,全英文查阅问题

  • 尽可能做到学术诚信,不抄袭,不参考他人代码,独立解决

PA0

First Exploration with GNU/Linux

GUI and CLI

if you stick to GUI, you can only do what it can; but in CLI(Command Line Interface), it can do what you want.

Difference Between “su” and “su -” Commands

Linux User Environment: Linux’s systems are multi-user environments. Whenever Linux operating system creates a new shell session(a new terminal) it started preparing an environment for itself. This environment basically holds the Environment variable(Environment depends on shell type, Bash is generally used by most of the Linux distribution).
For example, pwd command is an environmental variable.

su command is an abbreviation(缩写) for “substitute user” because it is used for switching to another user during a normal login session, but it is often mistaken as an abbreviation for “super user” as mainly su command is used for getting “super user” privileges.

Su Command

$whoami
ryan #show current user$pwd
/home/ryan #show cuurent directory$su root #not create a new User Environment#whoami
root #pwd
/home/ryan #the same

Su - Command

$whoami
ryan #show current user$pwd
/home/ryan #show current directory$su - root #Create a new User Environment#whoami
root#pwd
/root

su command does not create a new User Environment (in the simple term they pretend to be the target user) but su - **creates a totally new **User Environment(in the simple term they are actually the target user).

Sudo Command

sudo command executes instructions as a system administrator, that is to say, the instructions executed via sudo are as if they were executed by root himself.

More Exploration

Man Command

man an interface to the system reference manuals.

Inputman ls, “LS(1)” is displayed in the upper left corner, “LS” means manual’s name and “(1)” means this in the first chapter.

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-djjYxVmq-1631088803738)(https://secure.wostatic.cn/static/63wTbG998PmyHhvU7WY5qH/man ls截图.png)]

Makefile

Makefile is a program-building tool that runs on Unix, Linux, and their flavors. It aids in simplifying building program executables that may need various modules. To determine how the modules need to be compiled or recompiled, make takes the help of user-defined makefiles. Makefile guides the make utility while compiling and linking program modules.

Compiling the source code files can be tiring, especially when you have to include several source files and type the compiling command every time you need to compile. Makefiles are the solution to simplify this task.

Makefiles are speical format files that help build and manage the projects automatically.

The make command allows you to manage large programs or groups of programs. As you begin to write large programs, you notice that re-compiling large programs take a longer time than re-compiling short programs. Moreover, you notice that you usually only work on a small section of the program, and much of reaming program is unchanged.

Difference between g++ & gcc

g++ gcc
g++ is used to compile C++ program. gcc is used to compile C program
g++ can compile any .c or .cpp files but they will be treated as C++ files only. gcc can compile any .c or .cpp files but they will be treated as C and C++ respectively.
g++ fileName.cpp -o binary gcc fileName.c -o binary
Using g++ to link the object files, file automatically links in the std C++ libraries. gcc does not do this.

Defining Rules in Makefile

target [target...] : [dependent...]
[command...]

In the above code, the arguments in brackets are optional and ellipsis means one or more.Here, note that the tab to preface each command is required.

Make How to Execute

  • Find “Makefile” or “makefile” files in the current directory.

  • If you find it, make will search the first target of the makefile, such as the main file(executable file).

  • If the main file is not found or the .o files that the main file depends on are newer than it, execute the command to generate the main file.

  • If the .o files are not found, make will find the dependent files of the .o files and execute the command to generate .o files(It likes the process of the stack).

  • If the .o files and .h files are both found, make will generate .o files then use .o files to achieve the final task - - - generate the main file.

Special Macros

$@ The file name of the target.
$< The name of the first dependency.
$* The part of filename which matched a suffix rule.
$? The names of all the dependencies newer than the target separated by spaces.
$^ The names of all the dependencies separated by spaces, but with duplicate names removed.

GDB

GDB, short for GNU Debugger, is the most popular debugger for UNIX systems to debug C and C++ programs. A debugger is a program that runs other programs, allowing the user to exercise control over these programs, and to examine variables when problems arise.

GDB Command

Getting Started: Starting and Stopping

  • gcc -g main.c - Compiles main.c with the debugging option (-g). You still get an a.out, but it contains debugging information that lets you use variables and function names inside GDB.

  • gdb a.out - Opens GDB with file a.out, but does not run the program.

  • r - Runs the program until a breakpoint or error

  • q - Quit GDB

  • l - List 10 lines of source code for current line.

Stepping through Code

  • next - Runs the program until next line, then pauses. If the current line is a function, it executes the entire function , the pauses. next is good for walking through your code quickly.

  • step - Runs the next instruction, not line.If the current instruction is setting a variable, it is the same as next. If it’s a function, it will jump into the function, execute the first statement, then pause. step is good for diving into the detail of your code.

  • finish - Finishes executing the current function, then pause (also called step out).

Breakpoints or Watchpoints

  • print x - Prints current value of variable x.

  • display x - Constantly displays the value of variable x, which is shown after every step of pause.

Getting Source Code for PAs

Git usage

Use the branch feature of git to manage the process of development. A branch is an ordered list of commits , where a commit refers to some modifications in the project.

  • git branch - List all branches.

  • ** git checkout -b newbranch** - Create a new branch and check out to it.

  • git status - See those files modified from the last commit.

  • git diff - List modifications from the last commit.

  • git add . - Add the changes to commit.

  • git commit - Finish a commit.

  • git checkout branch - Check out to branch.

  • git log - The changes is traced.

Compiling and Running NEMU

NEMU (NJU Emulator) is a simple but complete full-system emulator designed for teaching purposes. Currently, it supports x86, mips32, riscv32, and riscv64. To build programs run above NEMU, refer to the AM project.

南大计算机系统基础实验PA0笔记相关推荐

  1. ics计算机基础,南大计算机系统基础实验 ics2020,pa0

    了解到这个南大的这个实验不错,记录一下自己的进度,也给后来者一些参考. 1.相关资料 PA项目官方地址:https://nju-projectn.github.io/ics-pa-gitbook/ic ...

  2. 南大计算机系统基础实验 ics2020,pa0

    文章目录 **1.相关资料** **2.遇到的问题解决办法** (1)环境问题: (2)官方文档 **3.总结** 1.相关资料 PA项目官方地址:https://nju-projectn.githu ...

  3. 计算机系统基础实验报告

    计算机系统基础实验报告 语言 C++ 编译器 Dev C++ 实验一:数的机器级表示 编写无符号数的转换: unsigned int unsignedToValue(char binary[],int ...

  4. 计算机系统基础实验-LinkLab实验

    这是大三时的实验课,很久以前的东西,应要求放出来,做的不是很好.linux永远都是很重要的,希望我和大家都记得这个.实际上做到第五阶段我就不会了. 实验课程名称:计算机系统基础 实验项目名称:Link ...

  5. 华中科技大学计算机系统基础实验3报告,华中科技大学计算机系统基础实验报告...

    华中科技大学计算机系统基础实验报告 1 课 程 实 验 报 告 课程名称: 计算机系统基础 专业班级: 学 号: 姓 名: 指导教师: 报告日期: 2016年 5月 24 日 计算机科学与技术学院2 ...

  6. 计算机系统基础实验:认识logisim软件、门电路逻辑功能测试(仿真)

    通过logisim对逻辑电路进行分析 文章目录 目录 文章目录 前言 一.使用工具 二.实验过程 1.门电路绘制 2.真值表 总结 前言 计算机系统基础也开了实验课,实验内容是利用logisim软件进 ...

  7. 华中科技大学计算机系统基础实验3报告,华中科技大学计算机系统基础实验报告.doc...

    文档介绍: 课程实验报告课程名称:计算机系统基础专业班级:学号:姓名:指导教师:报告日期:2016年5月24日计算机科学与技术学院目录实验1: 2实验2: 9实验3: 22实验总结 30 实验1:数据 ...

  8. 北京邮电大学计算机系统基础实验,第1章 计算机系统基础85666.ppt

    第1章 计算机系统基础85666 盘青梅 gdpqm@126.com 总结:计算机的发展阶段 冯·诺依曼计算机模型(P14) 总线系统结构图 总线(Bus)是计算机各部件传输信息的公共通道.有数据总线 ...

  9. 计算机系统基础实验01运算器算术运算

    计算机系统基础 运算器算术运算 实验目的 掌握ALU的算术运算原理,熟悉ALU数据传送通路和数据传送方式. 实验环境 微机,配置Windows操作系统.LC-3仿真机软件. 实验内容 ALU数据传送通 ...

  10. 南大计算机系统实验PA0 Compiling and Running NEMU报错解决方法

    根据pa0的指引,在pa0下第一次运行make menuconfig时,系统会作出如下回应 /home/lee/Desktop/ysyx-workbench/nemu/scripts/config.m ...

最新文章

  1. LEMP构建高性能WEB服务器(第三版)
  2. MATLAB-算术运算
  3. 论文笔记:CycleGAN
  4. Sharepoint client model 中出现Cannot invoke HTTP DAV request. There is a pending query 的解决办法...
  5. java继承方法规则或规律
  6. cognos report在做同比时遇到的问题解决方法
  7. 机器学习中的无监督学习_无监督机器学习中聚类背后的直觉
  8. C++::探索对象模型
  9. mybatis支持驼峰自动转换sql吗_SpringBoot整合mybatis——配置mybatis驼峰命名规则自动转换...
  10. python init方法做了什么_Python类方法、__new__方法和__init__方法分别是什么
  11. Java中竟有18种队列?45张图!安排
  12. python爬取小说项目概述_Python实战项目网络爬虫 之 爬取小说吧小说正文
  13. 中国历史上最牛气的十大豪言壮语
  14. 20200102每日一句
  15. narwal无法连接机器人_知了连接型智能营销机器人——重新定义AI客服
  16. AFA人工鱼群算法函数优化求解实例C++(2020.11.4)
  17. 并发之Striped64(l累加器)
  18. 运筹说 第75期 | 数学家欧拉也玩跨界
  19. PTA基础编程题目集
  20. 策略评价1:根据交易信号Signal,1.提取交易记录,2.绝对收益和相对收益,3.交易与不交易对比,4.收盘价最大回撤,5.资金最大回撤。6.可视化图形回测。

热门文章

  1. python中的计数函数_Python Numpy统计函数
  2. 区块链钱包之ETH钱包生成
  3. Android 图片压缩也即生成缩略图方法
  4. 伴随矩阵介绍及C++实现
  5. HFSS仿真结果输出
  6. 项目管理模式:项目型、职能型、矩阵型
  7. HDLBITS 练习 卡诺图化简部分
  8. eJOI2019 简要题解
  9. vs2019控件灰化无法使用怎么解决
  10. ubuntu16.04之间实现桌面共享