




已閱讀5頁,還剩4頁未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
新鄉(xiāng)學(xué)院計(jì)算機(jī)與信息工程學(xué)院實(shí) 驗(yàn) 報(bào) 告課程名稱 操作系統(tǒng)原理 專 業(yè) 計(jì)算機(jī)科學(xué)與技術(shù) 班 級(jí) 3班 學(xué) 號(hào) 2013052701xx 姓 名 xxx 實(shí)驗(yàn)成績(jī) 任課教師 xxx 2013年 12月 3日實(shí)驗(yàn)名稱鏈表的應(yīng)用姓 名xxx成 績(jī)實(shí)驗(yàn)地點(diǎn)A14-322實(shí)驗(yàn)時(shí)間2013年12月 3日一、 實(shí)驗(yàn)?zāi)康呐c要求實(shí)驗(yàn)?zāi)康模哼M(jìn)一步熟悉linux中鏈表的應(yīng)用實(shí)驗(yàn)要求:認(rèn)真二、 操作步驟1、編寫list.c文件代碼,代碼如下:#include #include #include #include MODULE_LICENSE(GPL);MODULE_AUTHOR(XIYOU);#define N 10/鏈表節(jié)點(diǎn)struct numlist int num;/數(shù)據(jù)struct list_head list;struct numlist numhead;/頭節(jié)點(diǎn)static int _init doublelist_init(void)/初始化頭節(jié)點(diǎn)struct numlist *listnode;struct list_head *pos;struct numlist *p;int i;printk(doublelist is starting.n);INIT_LIST_HEAD(&numhead.list);/建立N個(gè)節(jié)點(diǎn),依次加入到鏈表當(dāng)中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個(gè)節(jié)點(diǎn)i = 1;list_for_each_safe(pos, n, &numhead.list) /為了安全刪除節(jié)點(diǎn)而進(jìn)行的遍歷list_del(pos);/從雙鏈表中刪除當(dāng)前節(jié)點(diǎn)p = list_entry(pos, struct numlist, list);/得到當(dāng)前數(shù)據(jù)節(jié)點(diǎn)的首地址,即指針kfree(p);/釋放該數(shù)據(jù)節(jié)點(diǎn)所占空間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 #產(chǎn)生list模塊的目標(biāo)文件CURRENT_PATH :=$(shell pwd) #模塊所在的當(dāng)前路徑LINUX_KERNEL :=$(shell uname -r) #Linux內(nèi)核源代碼的當(dāng)前版本LINUX_KERNEL_PATH :=/lib/modules/$(shell uname -r)/build#Linux內(nèi)核源代碼的絕對(duì)路徑all:make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) modules #編譯模塊clean:make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) clean #清理3、行編譯:在list.c和Makefile文件的當(dāng)前路徑執(zhí)行make命令。得到模塊文件。4、加載模塊:依然是在當(dāng)前路徑執(zhí)行insmod list.ko5、查看模塊列表:執(zhí)行命令lsmod6、卸載模塊:執(zhí)行命令rmmod list7、查看輸出信息:執(zhí)行tail 命令三、 實(shí)驗(yàn)結(jié)果1. 在模塊文件list.c和Makefile當(dāng)前打開終端,輸入make 命令之后,所在的文件會(huì)編譯出其他文件rootlocalhost 桌面# ls123 list.ko list.o Makefile tools2.c list.ko.unsigned list.txt modules.order 第二個(gè)實(shí)驗(yàn)list.c list.mod.c hellomod.c Module.symvers 第一個(gè)實(shí)驗(yàn)list.c list.mod.o Makefile result2. 在運(yùn)行插入模塊insmod 之后,出現(xiàn)執(zhí)行插入模塊操作后,再次查看模塊列表就會(huì)看到hellomod模塊存在。rootlocalhost 桌面# insmod list.korootlocalhost 桌面# lsmodModule Size Used bylist 792 0 3. 執(zhí)行卸載模塊命令后就會(huì)發(fā)現(xiàn)list 模塊從模塊列表中消失。rootlocalhost 桌面# lsmodModule Size Used byvfat 8575 0 fat 47049 1 vfatusb_storage 39108 0 fuse 56800 2 4. 執(zhí)行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等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 熟食夜市活動(dòng)方案
- 燕窩公司年會(huì)活動(dòng)方案
- 愛國主義活動(dòng)策劃方案
- 愛就說出來活動(dòng)方案
- 愛心協(xié)會(huì)校內(nèi)活動(dòng)方案
- 愛牙日節(jié)日活動(dòng)方案
- 爸爸去哪兒繪本活動(dòng)方案
- 牙齒矯正活動(dòng)方案
- 物業(yè)公司共青團(tuán)活動(dòng)方案
- 物業(yè)公司年初活動(dòng)方案
- 中國思想史課件
- 重癥肺炎個(gè)案護(hù)理查房
- 2023消防系統(tǒng)驗(yàn)收記錄表室內(nèi)給水系統(tǒng)室內(nèi)消火栓
- 教育部中小學(xué)心理健康教育特色學(xué)校標(biāo)準(zhǔn)
- 植保無人機(jī)作業(yè)情況記錄表
- 北師大版小學(xué)六年級(jí)數(shù)學(xué)下冊(cè)教學(xué)工作總結(jié)
- 工業(yè)相機(jī)與機(jī)器視覺知識(shí)考試題庫及答案
- (完整word版)人教版九年級(jí)英語課文原文word版
- 三菱通用變頻器D700使用手冊(cè)
- 分期付款合同協(xié)議
- 埃得新材料有限公司年產(chǎn)10425噸聚苯醚及5000噸鄰甲酚項(xiàng)目環(huán)境影響報(bào)告書
評(píng)論
0/150
提交評(píng)論