




已阅读5页,还剩4页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
新乡学院计算机与信息工程学院实 验 报 告课程名称 操作系统原理 专 业 计算机科学与技术 班 级 3班 学 号 2013052701xx 姓 名 xxx 实验成绩 任课教师 xxx 2013年 12月 3日实验名称链表的应用姓 名xxx成 绩实验地点A14-322实验时间2013年12月 3日一、 实验目的与要求实验目的:进一步熟悉linux中链表的应用实验要求:认真二、 操作步骤1、编写list.c文件代码,代码如下:#include #include #include #include MODULE_LICENSE(GPL);MODULE_AUTHOR(XIYOU);#define N 10/链表节点struct numlist int num;/数据struct list_head list;struct numlist numhead;/头节点static int _init doublelist_init(void)/初始化头节点struct numlist *listnode;struct list_head *pos;struct numlist *p;int i;printk(doublelist is starting.n);INIT_LIST_HEAD(&numhead.list);/建立N个节点,依次加入到链表当中for (i = 0; i num = i + 1;list_add_tail(&listnode-list, &numhead.list);printk(Node %d has added to the doublelist.n, i + 1);/遍历链表i = 1;list_for_each(pos, &numhead.list) p = list_entry(pos, struct numlist, list);printk(Node %ds data:%dn, i, p-num);i+;return 0;static void _exit doublelist_exit(void)struct list_head *pos, *n;struct numlist *p;int i;/依次删除N个节点i = 1;list_for_each_safe(pos, n, &numhead.list) /为了安全删除节点而进行的遍历list_del(pos);/从双链表中删除当前节点p = list_entry(pos, struct numlist, list);/得到当前数据节点的首地址,即指针kfree(p);/释放该数据节点所占空间printk(Node %d has removed from the doublelist.n, i+);printk(doublelist is exiting.n);module_init(doublelist_init);module_exit(doublelist_exit);2编写Makefile文件代码,代码如下:obj-m :=list.o #产生list模块的目标文件CURRENT_PATH :=$(shell pwd) #模块所在的当前路径LINUX_KERNEL :=$(shell uname -r) #Linux内核源代码的当前版本LINUX_KERNEL_PATH :=/lib/modules/$(shell uname -r)/build#Linux内核源代码的绝对路径all:make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) modules #编译模块clean:make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) clean #清理3、行编译:在list.c和Makefile文件的当前路径执行make命令。得到模块文件。4、加载模块:依然是在当前路径执行insmod list.ko5、查看模块列表:执行命令lsmod6、卸载模块:执行命令rmmod list7、查看输出信息:执行tail 命令三、 实验结果1. 在模块文件list.c和Makefile当前打开终端,输入make 命令之后,所在的文件会编译出其他文件rootlocalhost 桌面# ls123 list.ko list.o Makefile tools2.c list.ko.unsigned list.txt modules.order 第二个实验list.c list.mod.c hellomod.c Module.symvers 第一个实验list.c list.mod.o Makefile result2. 在运行插入模块insmod 之后,出现执行插入模块操作后,再次查看模块列表就会看到hellomod模块存在。rootlocalhost 桌面# insmod list.korootlocalhost 桌面# lsmodModule Size Used bylist 792 0 3. 执行卸载模块命令后就会发现list 模块从模块列表中消失。rootlocalhost 桌面# lsmodModule Size Used byvfat 8575 0 fat 47049 1 vfatusb_storage 39108 0 fuse 56800 2 4. 执行dmesg命令可以看到输出信息。usb 2-1.1: new high speed USB device number 4 using ehci_hcdusb 2-1.1: New USB device found, idVendor=0951, idProduct=1643usb 2-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3usb 2-1.1: Product: DataTraveler G3usb 2-1.1: Manufacturer: Kingstonusb 2-1.1: SerialNumber: 001CC05FE932FB90A92B25A0usb 2-1.1: configuration #1 chosen from 1 choicescsi5 : SCSI emulation for USB Mass Storage devicesusb-storage: device found at 4usb-storage: waiting for device to settle before scanningusb-storage: device scan completescsi 5:0:0:0: Direct-Access Kingston DataTraveler G3 1.00 PQ: 0 ANSI: 0 CCSsd 5:0:0:0: Attached scsi generic sg1 type 0sd 5:0:0:0: sdb 15644912 512-byte logical blocks: (8.01 GB/7.45 GiB)sd 5:0:0:0: sdb Write Protect is offsd 5:0:0:0: sdb Mode Sense: 0b 00 00 08sd 5:0:0:0: sdb Assuming drive cache: write throughsd 5:0:0:0: sdb Assuming drive cache: write through sdb: sdb1sd 5:0:0:0: sdb Assuming drive cache: write throughsd 5:0:0:0: sdb Attached SCSI removable diskSELinux: initialized (dev sdb1, type vfat), uses genfs_contextsusb 2-1.1: USB disconnect, device number 4No module found in objectdoublelist is starting.Node 1 has added to the doublelist.Node 2 has added to the doublelist.Node 3 has added to the doublelist.Node 4 has added to the doublelist.Node 5 has added to the doublelist.Node 6 has added to the doublelist.Node 7 has added to the doublelist.Node 8 has added to the doublelist.Node 9 has added to the doublelist.Node 10 has added to the doublelist.Node 1s data:1Node 2s data:2Node 3s data:3Node 4s data:4Node 5s data:5Node 6s data:6Node 7s data:7Node 8s data:8Node 9s data:9Node 10s data:10Node 1 has removed from the doublelist.Node 2 has removed from the doublelist.Node 3 has removed from the doublelist.Node 4 has removed from the doublelist.Node 5 has removed from the doublelist.Node 6 has rem
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 毛皮柔软度智能提升-洞察及研究
- 用户行为特征分析与情感预测-洞察及研究
- 南阳一中高二年级2025年秋期第一次月考数学答案
- 舞蹈教育国际化发展-洞察及研究
- 学生酒店安全培训课件
- 疾病预后评估体系-洞察及研究
- 注册计量师一级考试题及答案
- 中级经济师考试商业专业知识与实务考试试题及答案
- 纸船承重策划
- 慢阻肺营养治疗课件
- 大学安全纪律教育主题班会
- 2025年新版汉字听写大赛题库及参考答案
- 钢筋混凝土管道施工方案
- 小学数学新教材中“图形与几何”领域的内容结构分析
- DB32-T 4981-2024 公路水运工程平安工地建设规范
- 垃圾分类标准体系构建研究
- 新建屋顶分布式光伏发电项目施工方案
- 新生儿病房探视制度
- 2024年《13464电脑动画》自考复习题库(含答案)
- 给我一颗原始星球 (小镇舍长)
- 第一次月考卷(扬州专用)-2024-2025学年七年级数学上学期第一次月考模拟卷(江苏专用)
评论
0/150
提交评论