- Linux 基础入门(新版)
- C 语言实现 Linux Shell 命令解释器
- C 语言实现 Linux touch 命令
- C 语言实现多线程排序
- 多线程生产者消费者模型仿真停车场
- 在 Github Pages 上部署自己的简历
- Linux 系统安装及配置邮件服务器
- Shell 脚本实现 Linux 系统监控
- C 语言实现 Linux 网络嗅探器
- Vim 编辑器
- Ansible 基础教程
- C 语言实现聊天室软件
- Linux 防火墙技术
- Linux 系统搭建及配置 DNS 服务器
- Linux 系统监控实战
- 操作系统原理与实践
- 实验环境的工作模式
- 使用方法
- Linux 系统安装配置版本控制服务器
- LAMP 部署及配置
- Linux 内核分析
- 正则表达式基础
- TCP/IP 网络协议基础
- Linux Web 运维(Nginx)实战
- Linux 命令实例练习
- 高级 Bash 脚本编程指南
- Memcache 基础教程
- 操作系统实验-基于 uCore OS
- Linux 系统编程
第 1 节 lab0
> [提示] > 实验素材来源于 > - uCoreLab 实验指导书 > - uCoreLab 源代码 > - MOOC OS 课程视频 如有问题需要询问,请访问 > - 课程问答和交流区 > 当前 OS 课程实验相关源码已经放在/home/shiyanlou/ucore_lab 目录下
0: 看课程视频并阅读实验文档
观看 MOOC OS 课程视频 中与 lab0 相关的内容 阅读 uCoreLab 实验指导书 中与 lab0 相关的文档 > 假定缺省目录是/home/shiyanlou/ucore_lab 目录下
开始动手实验!
1: 了解汇编
Try below command
$cd related_info/lab0
$gcc -S -m32 lab0_ex1.c
Then you will get lab_ex1.S. Try to understand the content & relation of C file and S file.
2: 用 gdb 调试
Try below command
$cd related_info/lab0
$gcc -g -m32 lab0_ex2.c
Then you will get a.out. Try to use gdb to debug lab0_ex2.
3: 掌握指针和类型转换相关的C编程
对于如下的代码段,
...
#define STS_CG32 0xC // 32-bit Call Gate
#define STS_IG32 0xE // 32-bit Interrupt Gate
#define SETGATE(gate, istrap, sel, off, dpl) { \
(gate).gd_off_15_0 = (uint32_t)(off) & 0xffff; \
(gate).gd_ss = (sel); \
(gate).gd_args = 0; \
(gate).gd_rsv1 = 0; \
(gate).gd_type = (istrap) ? STS_TG32 : STS_IG32; \
(gate).gd_s = 0; \
(gate).gd_dpl = (dpl); \
(gate).gd_p = 1; \
(gate).gd_off_31_16 = (uint32_t)(off) >> 16; \
}
/* Gate descriptors for interrupts and traps */
struct gatedesc {
unsigned gd_off_15_0 : 16; // low 16 bits of offset in segment
unsigned gd_ss : 16; // segment selector
unsigned gd_args : 5; // # args, 0 for interrupt/trap gates
unsigned gd_rsv1 : 3; // reserved(should be zero I guess)
unsigned gd_type : 4; // type(STS_{TG,IG32,TG32})
unsigned gd_s : 1; // must be 0 (system)
unsigned gd_dpl : 2; // descriptor(meaning new) privilege level
unsigned gd_p : 1; // Present
unsigned gd_off_31_16 : 16; // high bits of offset in segment
};
...
如果在其他代码段中有如下语句,
unsigned intr;
intr=8;
SETGATE(intr, 0,1,2,3);
请问执行上述指令后, intr 的值是多少?
具体方法 :Try below command
$cd related_info/lab0
gcc -g -m32 lab0_ex3.c 2>&1|tee make.log
If you get gcc's error, try to read make.log and fix the bugs. If gcc successed, then you will get a.out. Try to answer below question.
4: 掌握通用链表结构相关的C编程
用在 related_info/lab0/list.h
中定义的结构和函数来实现一个小应用程序完成一个基于此链表的数据对象的访问操作。 可参考 related_info/lab0/lab0_ex4.c
如果完成了 lab0 的实验要求,恭喜你,可以进入 lab1 了!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论