![操作系統(tǒng)課程設(shè)計(jì)-模擬文件系統(tǒng)_第1頁(yè)](http://file1.renrendoc.com/fileroot_temp2/2020-7/17/ad8c0c35-f2bd-4109-8120-246fdc869e88/ad8c0c35-f2bd-4109-8120-246fdc869e881.gif)
![操作系統(tǒng)課程設(shè)計(jì)-模擬文件系統(tǒng)_第2頁(yè)](http://file1.renrendoc.com/fileroot_temp2/2020-7/17/ad8c0c35-f2bd-4109-8120-246fdc869e88/ad8c0c35-f2bd-4109-8120-246fdc869e882.gif)
![操作系統(tǒng)課程設(shè)計(jì)-模擬文件系統(tǒng)_第3頁(yè)](http://file1.renrendoc.com/fileroot_temp2/2020-7/17/ad8c0c35-f2bd-4109-8120-246fdc869e88/ad8c0c35-f2bd-4109-8120-246fdc869e883.gif)
![操作系統(tǒng)課程設(shè)計(jì)-模擬文件系統(tǒng)_第4頁(yè)](http://file1.renrendoc.com/fileroot_temp2/2020-7/17/ad8c0c35-f2bd-4109-8120-246fdc869e88/ad8c0c35-f2bd-4109-8120-246fdc869e884.gif)
![操作系統(tǒng)課程設(shè)計(jì)-模擬文件系統(tǒng)_第5頁(yè)](http://file1.renrendoc.com/fileroot_temp2/2020-7/17/ad8c0c35-f2bd-4109-8120-246fdc869e88/ad8c0c35-f2bd-4109-8120-246fdc869e885.gif)
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、目錄第1章 需求分析.1第2章 概要設(shè)計(jì).12.1 系統(tǒng)的主要功能.12.2系統(tǒng)模塊功能結(jié)構(gòu).12.3運(yùn)行環(huán)境要求.22.4數(shù)據(jù)結(jié)構(gòu)設(shè)計(jì).2第3章 詳細(xì)設(shè)計(jì).33.1模塊設(shè)計(jì).33.2算法流程圖.3第4章 系統(tǒng)源代碼.4第5章 系統(tǒng)測(cè)試及調(diào)試.45.1運(yùn)行結(jié)果及分析.45.2系統(tǒng)測(cè)試結(jié)論.5第6章 總結(jié)與體會(huì).6第7章 參考文獻(xiàn).6附錄.7第1章 需求分析通過(guò)模擬文件系統(tǒng)的實(shí)現(xiàn),深入理解操作系統(tǒng)中文件系統(tǒng)的理論知識(shí), 加深對(duì)教材中的重要算法的理解。同時(shí)通過(guò)編程實(shí)現(xiàn)這些算法,更好地掌握操作系統(tǒng)的原理及實(shí)現(xiàn)方法,提高綜合運(yùn)用各專業(yè)課知識(shí)的能力;掌握操作系統(tǒng)結(jié)構(gòu)、實(shí)現(xiàn)機(jī)理和各種典型算法,系統(tǒng)地了解操
2、作系統(tǒng)的設(shè)計(jì)和實(shí)現(xiàn)思路,并了解操作系統(tǒng)的發(fā)展動(dòng)向和趨勢(shì)。模擬二級(jí)文件管理系統(tǒng)的課程設(shè)計(jì)目的是通過(guò)研究linux的文件系統(tǒng)結(jié)構(gòu),模擬設(shè)計(jì)一個(gè)簡(jiǎn)單的二級(jí)文件系統(tǒng),第一級(jí)為主目錄文件,第二級(jí)為用戶文件。第2章 概要設(shè)計(jì)2.1 系統(tǒng)的主要功能1) 系統(tǒng)運(yùn)行時(shí)根據(jù)輸入的用戶數(shù)目創(chuàng)建主目錄2) 能夠?qū)崿F(xiàn)下列命令:l login 用戶登錄create 建立文件l read 讀取文件write 寫(xiě)入文件l delete 刪除文件mkdir 建立目錄cd 切換目錄logout 退出登錄2.2系統(tǒng)模塊功能結(jié)構(gòu)2.3運(yùn)行環(huán)境要求操作系統(tǒng)windows xp ,開(kāi)發(fā)工具vc+6.02.4數(shù)據(jù)結(jié)構(gòu)設(shè)計(jì)用戶結(jié)構(gòu):賬號(hào)與密
3、碼結(jié)構(gòu)typedef struct userschar name8;char pwd10;users;本系統(tǒng)有8個(gè)默認(rèn)的用戶名,前面是用戶名,后面為密碼,用戶登陸時(shí)只要輸入正確便可進(jìn)入系統(tǒng),否則提示失敗要求重新輸入。users usrarray8 =usr1,usr1,usr2,usr2,usr3,usr3,usr4,usr4,usr5,usr5,usr6,usr6,usr7,usr7,usr8,usr8,;(3)數(shù)據(jù)結(jié)構(gòu)說(shuō)明a)文件結(jié)構(gòu)鏈表struct fnodechar filenamefilename_length;int isdir;int isopen;char content255
4、;fnode *parent;fnode *child;fnode *prev;fnode *next;b)函數(shù)介紹fnode *initfile(char filename,int isdir);/初始化文件或目錄void createroot();/建立系統(tǒng)根目錄int run();系統(tǒng)運(yùn)行int findpara(char *topara);對(duì)參數(shù)進(jìn)行處理bool chklogin(char *users, char *pwd);檢查賬號(hào)與口令void help();命令列表int mkdir();建立目錄int create();建立文件int read();讀取文件int write
5、();寫(xiě)入文件int del();刪除文件int cd();切換目錄int dir();文件與目錄列表第3章 詳細(xì)設(shè)計(jì)3.1模塊設(shè)計(jì)此課程設(shè)計(jì)把文本作為研究對(duì)象來(lái)模擬操作系統(tǒng)的文件系統(tǒng)工作過(guò)程。所以用一個(gè)字符串?dāng)?shù)組來(lái)模擬磁盤(pán)空間,顧名思義,模擬磁盤(pán)提供字符的存儲(chǔ)服務(wù)。所有用戶構(gòu)成一個(gè)數(shù)組,每個(gè)數(shù)組元素是一個(gè)結(jié)構(gòu)體,每個(gè)結(jié)構(gòu)體包括三部分,用戶的用戶名、用戶密碼和文件鏈表(由于模擬文件系統(tǒng)的文件數(shù)量不多,故文件表采用線性鏈表來(lái)存儲(chǔ)。線性表每個(gè)結(jié)點(diǎn)放置一個(gè)文件的fcb,其中存儲(chǔ)一個(gè)文件的信息,文件名、長(zhǎng)度、類型、創(chuàng)建時(shí)間等);磁盤(pán)空間分配表,采用鏈表結(jié)構(gòu),每個(gè)節(jié)點(diǎn)保存模擬磁盤(pán)的一個(gè)邏輯塊的信息,包括
6、塊的最大長(zhǎng)度,文件占用長(zhǎng)度,占用標(biāo)志。如果占用標(biāo)志為0,即該空間可分配給文件。初始化磁盤(pán)空間分配表鏈表,首先把整個(gè)模擬磁盤(pán)作來(lái)一塊,并置占用位為0。當(dāng)有進(jìn)程申請(qǐng)磁盤(pán)空間時(shí),從頭開(kāi)始遍歷,檢查占用位,如果該塊為可分配,則檢查塊大小,若塊長(zhǎng)度大于或等于申請(qǐng)空間大小,則把塊的前一部分(等于申請(qǐng)大?。┓峙浣o文件,并置標(biāo)志位為占用。剩下的大小作來(lái)一個(gè)新塊,作來(lái)一個(gè)新節(jié)點(diǎn)插入到原節(jié)點(diǎn)的后邊,標(biāo)志位為可用。這樣就實(shí)現(xiàn)了模擬磁盤(pán)的線性分配。3.2算法流程圖模擬二級(jí)文件系統(tǒng)主界面用戶登錄切換目錄退出登錄建立目錄刪除文件寫(xiě)入文件讀取文件建立文件第4章 系統(tǒng)源代碼見(jiàn)附錄第5章 系統(tǒng)測(cè)試及調(diào)試5.1運(yùn)行結(jié)果及分析5.
7、2系統(tǒng)測(cè)試結(jié)論從運(yùn)行結(jié)果截圖中可以看到,程序分別執(zhí)行了它所包含的7個(gè)功能,并且每個(gè)功能都能正確的執(zhí)行。若程序執(zhí)行開(kāi)始,三次都未輸入正確的帳號(hào)和密碼,程序會(huì)退出不再執(zhí)行。第6章 總結(jié)與體會(huì)雖然我們做過(guò)很多次課程設(shè)計(jì)了,但是感覺(jué)自己還有好多需要學(xué)習(xí)的地方,接到題目要求時(shí),設(shè)計(jì)大體的框架,考慮好所使用的數(shù)據(jù)結(jié)構(gòu),然后用高級(jí)編程語(yǔ)言分模塊的把架子的思路編寫(xiě)出來(lái),調(diào)試,運(yùn)行,再看看是不是符合題目的要求,上網(wǎng)找些資料,看看想想是不是要提高要求,才可以滿足實(shí)際的需要,最后把收集的勞動(dòng)成果組合起來(lái),一個(gè)小程序終于成型了,雖然每次的過(guò)程差不多都一樣,但是每次都會(huì)有不同的體會(huì)。通過(guò)本次的課程設(shè)計(jì),使我能夠正確運(yùn)用
8、操作系統(tǒng)課程中所學(xué)的基本理論和知識(shí),加深了對(duì)文件系統(tǒng)基本概念的理解,以及磁盤(pán)文件系統(tǒng)的文件操作。在設(shè)計(jì)過(guò)程中,查詢了不少相關(guān)資料,不斷的發(fā)現(xiàn)問(wèn)題、提出問(wèn)題、解決問(wèn)題。在對(duì)自己所編寫(xiě)的源程序段的糾錯(cuò)的過(guò)程中,使我更好的理解了操作系統(tǒng)中文件系統(tǒng)的理論知識(shí),同時(shí)在編程時(shí)用到了模塊化的設(shè)計(jì)思想,這種編程方法可以使我們的編程變的更簡(jiǎn)單,可以使我們的查錯(cuò)與糾錯(cuò)變的更方便??偟膩?lái)說(shuō)通過(guò)這次的設(shè)計(jì)的學(xué)習(xí)使我學(xué)到了很多在平時(shí)的學(xué)習(xí)中學(xué)不到的很多東西,通過(guò)這次課程設(shè)計(jì),使我對(duì)操作系統(tǒng)和編程產(chǎn)生興趣,我想我會(huì)在這條路上繼續(xù)前進(jìn)下去。我相信,只要不斷的嚴(yán)格要求自己,注意培養(yǎng)自己的思維能力,就一定會(huì)有更大更輝煌的發(fā)展和
9、提高。第7章 參考文獻(xiàn)操作系統(tǒng)原理實(shí)驗(yàn)教程,清華大學(xué)出版社 胡峰松主編操作系統(tǒng)實(shí)驗(yàn)教程,清華大學(xué)出版社 張麗芬等 編著計(jì)算機(jī)操作系統(tǒng)實(shí)驗(yàn)教程,清華大學(xué)出版社 顏彬等編著附錄系統(tǒng)的主要源代碼#include stdio.h#include iostream.h#include string.h#include iomanip.h#define filename_length 10 /文件名稱長(zhǎng)度#define command_length 10 /命令行長(zhǎng)度#define para_length 30 /參數(shù)長(zhǎng)度/賬號(hào)結(jié)構(gòu)typedef struct userschar name8;char p
10、wd10;users;/文件結(jié)構(gòu)struct fnodechar filenamefilename_length;int isdir;int isopen;char content255;fnode *parent;fnode *child;fnode *prev;fnode *next;/賬號(hào)users usrarray8 =usr1,usr1,usr2,usr2,usr3,usr3,usr4,usr4,usr5,usr5,usr6,usr6,usr7,usr7,usr8,usr8,;fnode *initfile(char filename,int isdir);void createro
11、ot();int run();int findpara(char *topara);bool chklogin(char *users, char *pwd);void help();int mkdir();int create();int read();int write();int del();int cd();int dir();fnode *root,*recent,*temp,*ttemp;char parapara_length,commandcommand_length,tempparapara_length,recentparapara_length;/創(chuàng)建文件與目錄結(jié)點(diǎn)fno
12、de* initfile(char filename,int isdir)fnode *node=new fnode;strcpy(node-filename,filename);node-isdir=isdir;node-isopen=0;node-parent=null;node-child=null;node-prev=null;node-next=null;return node;/創(chuàng)建文件存儲(chǔ)結(jié)點(diǎn)void createroot ()recent=root=initfile(/,1);root-parent=null;root-child=null;root-prev=root-nex
13、t=null;strcpy(para,/);int mkdir()temp=initfile( ,1);cintemp-filename;if(recent-child=null)temp-parent=recent;temp-child=null;recent-child=temp;temp-prev=temp-next=null;elsettemp=recent-child;while(ttemp-next)ttemp=ttemp-next;if(strcmp(ttemp-filename,temp-filename)=0&ttemp-isdir=1)printf(對(duì)不起,目錄已存在!);
14、return 1;ttemp-next=temp;temp-parent=null;temp-child=null;temp-prev=ttemp;temp-next=null;return 1;int create()temp=initfile( ,0);cintemp-filename;cintemp-content;if(recent-child=null)temp-parent=recent;temp-child=null;recent-child=temp;temp-prev=temp-next=null;cout文件建立成功!child;while(ttemp-next)ttemp
15、=ttemp-next;if(strcmp(ttemp-filename,temp-filename)=0&ttemp-isdir=0)printf(對(duì)不起,文件已存在!);return 1;ttemp-next=temp;temp-parent=null;temp-child=null;temp-prev=ttemp;temp-next=null;cout文件建立成功!endl;return 1;int dir()int i=0,j=0;temp=new fnode;temp=recent;if(temp!=root)cout .child=null)couttotal: directors
16、 i files j child;while(temp)if(temp-isdir)cout filenameendl;i+;elsecout filenamenext;couttotal: directors ifiles j filename;if(recent-child=null)cout文件不存在!child-filename,filename)=0)coutchild-contentchild;while(temp-next)if(strcmp(temp-next-filename,filename)=0)coutnext-contentendl;return 1;cout文件不存
17、在!filename;if(recent-child=null)cout文件不存在!child-filename,filename)=0)recent-child-isopen=1;/設(shè)置文件標(biāo)記為打開(kāi)cinrecent-child-content;recent-child-isopen=0;/設(shè)置文件標(biāo)記為關(guān)閉cout文件寫(xiě)入成功!child;while(temp-next)if(strcmp(temp-next-filename,filename)=0)recent-child-isopen=1;/設(shè)置文件標(biāo)記為打開(kāi)cintemp-next-content;recent-child-iso
18、pen=0;/設(shè)置文件標(biāo)記為關(guān)閉cout文件寫(xiě)入成功!endl;return 1;cout文件不存在!topara;if(strcmp(topara,.)=0)int i;while(recent-prev)recent=recent-prev;if(recent-parent)recent=recent-parent;i=strlen(para);while(parai!=/ & i0) i-;if(i!=0)parai=0;elseparai+1=0;elsefindpara(topara);return 1;int findpara(char *topara)int i=0;int si
19、gn=1;if(strcmp(topara,/)=0)recent=root;strcpy(para,/);return 1;temp=recent;strcpy(temppara,para);if(topara0=/)recent=root-child;i+;strcpy(para,/);elseif(recent!=null & recent!=root)strcat(para,/);if(recent & recent-child)if(recent-isdir)recent=recent-child;elseprintf(路徑錯(cuò)誤!n);return 1;while(ichild)i+
20、;if(recent-isdir)recent=recent-child;elseprintf(路徑錯(cuò)誤n);return 0;strcat(para,/);while(toparai!=/ & ifilename,recentpara)!=0 | (recent-isdir!=1) & recent-next!=null)recent=recent-next;if(strcmp(recent-filename,recentpara)=0)if(recent-isdir=0)strcpy(para,temppara);recent=temp;printf(是文件不是目錄。n);return 0
21、;strcat(para,recent-filename);if(strcmp(recent-filename,recentpara)!=0 | recent=null)strcpy(para,temppara);recent=temp;printf(輸入路徑錯(cuò)誤n);return 0;return 1;int del()char filenamefilename_length;cinfilename;temp=new fnode;if(recent-child)temp=recent-child;while(temp-next & (strcmp(temp-filename,filename
22、)!=0 | temp-isdir!=0)temp=temp-next;if(strcmp(temp-filename,filename)!=0)cout不存在該文件!endl;return 0;elsecout不存在該文件!parent=null)temp-prev-next=temp-next;if(temp-next)temp-next-prev=temp-prev;temp-prev=temp-next=null;elseif(temp-next)temp-next-parent=temp-parent;temp-parent-child=temp-next;delete temp;cout文件已刪除!endl;bool chklogin(char *users, char *pwd)int i;for(i=0; i8; i+)if( (strcmp(users,)=0) & (strcmp(pwd,usrarrayi.pwd)=0)return true;return false;void help(void)cout 命 令 一 覽 endl;coutendl;coutcreate: 建立文件。 endl;coutread: 讀取文件。 endl;coutwr
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 家裝工程簡(jiǎn)易協(xié)議條款
- 機(jī)械設(shè)備進(jìn)口物流代理協(xié)議
- 劇院改造貸款協(xié)議
- 廣告牌運(yùn)輸與安裝合同
- 服裝物流服務(wù)協(xié)議模板
- 展覽館混凝土配送承包協(xié)議
- 國(guó)際體育用品居間協(xié)議
- 咖啡館裝修合作協(xié)議
- 爬升模板滑膜施工方案
- 便利店水電改造合同
- 閱讀理解特訓(xùn)卷-英語(yǔ)四年級(jí)上冊(cè)譯林版三起含答案
- 國(guó)庫(kù)集中支付培訓(xùn)班資料-國(guó)庫(kù)集中支付制度及業(yè)務(wù)操作教學(xué)課件
- 屋面及防水工程施工(第二版)PPT完整全套教學(xué)課件
- 詩(shī)詞寫(xiě)作入門(mén)課件
- 2023年上海青浦區(qū)區(qū)管企業(yè)統(tǒng)一招考聘用筆試題庫(kù)含答案解析
- 2023年高一物理期末考試卷(人教版)
- 2023版押品考試題庫(kù)必考點(diǎn)含答案
- 空氣能熱泵安裝示意圖
- 建筑工程施工質(zhì)量驗(yàn)收規(guī)范檢驗(yàn)批填寫(xiě)全套表格示范填寫(xiě)與說(shuō)明
- 最新《工會(huì)基礎(chǔ)知識(shí)》試題庫(kù)及答案1000題【完美打印版】
- 辦公家具項(xiàng)目實(shí)施方案、供貨方案
評(píng)論
0/150
提交評(píng)論