黑龙江大学“操作系统课程设计”总结报告内容摘要:

i)。 if(i!=0){ printf(name:)。 scanf(%s,name)。 } switch(i){ 12 case 1: removeNode(name,DCTs)。 break。 case 2: tmp=findByName(name,COCTs)。 if(tmp==NULL) printf(%cError:can39。 t find %s!\n,BEEP,name)。 else if(get_child_count(tmp,DCTs)0) //子节点个数 printf(%cError:can39。 t remove %s!\n,BEEP,name)。 else removeNode(name,COCTs)。 break。 case 3: tmp=findByName(name,CHCTs)。 if(tmp==NULL) printf(%cError:can39。 t find %s!\n,BEEP,name)。 else if(get_child_count(tmp,COCTs)0) printf(%cError:can39。 t remove %s!\n,BEEP,name)。 else removeNode(name,CHCTs)。 break。 case 0: return。 } }} void allocate_channel(struct Node *node,struct PCB *p){ if(p==NULL) return。 if(nodeprocess==NULL){ 13 nodeprocess=p。 block(blocked,p)。 } else block(nodeready,p)。 } void allocate_controller(struct Node *node,struct PCB *p){ if(p==NULL) return。 if(nodeprocess==NULL){ nodeprocess=p。 allocate_channel(nodeparent,p)。 } else block(nodeready,p)。 } void allocate_device(struct Node *node,struct PCB *p){ if(p==NULL) return。 if(nodeprocess==NULL){ nodeprocess=p。 allocate_controller(nodeparent,p)。 } else block(nodeready,p)。 } void allocate(){ char name[10]。 struct Node *node。 14 if(running==NULL) return。 printf(device name:)。 scanf(%s,name)。 node=findByName(name,DCTs)。 if(node==NULL){ printf(Can39。 t find %s!\n,name)。 return。 } allocate_device(node,running)。 } void release_channel(struct Node *node,struct PCB *p){ if(nodeprocess==p){ nodeprocess=NULL。 allocate_channel(node,removeFirst(nodeready))。 add(ready,remove_process(blocked,p))。 if(running==NULL) running=removeFirst(ready)。 } else{ add(ready,remove_process(nodeready,p))。 if(running==NULL) running=removeFirst(ready)。 } } 15 void release_controller(struct Node *node,struct PCB *p){ if(nodeprocess==p){ nodeprocess=NULL。 allocate_controller(node,removeFirst(nodeready))。 release_channel(nodeparent,p)。 } else{ add(ready,remove_process(nodeready,p))。 if(running==NULL) running=removeFirst(ready)。 } } void release(){ char name[10]。 struct Node *node。 struct PCB *p。 printf(device name:)。 scanf(%s,name)。 node=findByName(name,DCTs)。 if(node==NULL || nodeprocess==NULL) return。 p=nodeprocess。 nodeprocess=NULL。 allocate_device(node,removeFirst(nodeready))。 release_controller(nodeparent,p)。 } void display_process_status(struct Node *node){//显示节点的占用进 16 程以及等待进程信息 struct PCB *p=nodereadynext。 if(nodeprocess!=NULL) printf(%s,nodeprocessname)。 while(p!=NULL){ printf(%s,pname)。 p=pnext。 } printf(\n)。 } void display_status(){//显示设备状态 struct Node *chct=CHCTsnext,*coct,*dct。 while(chct!=NULL){ printf(%s,chctname)。 display_process_status(chct)。 coct=COCTsnext。 while(coct!=NULL){ if(coctparent==chct){ printf(\t%s,coctname)。 display_process_status(coct)。 dct=DCTsnext。 while(dct!=NULL){ if(dctparent==coct){ printf(\t\t%s,dctname)。 display_process_status(dct)。 } dct=dctnext。 } } 17 coct=coctnext。 } chct=chctnext。 } } 小结 四、 文件管理 目的 通过 利用磁盘文件 ,完成 操作系统的文件管理功能 ,掌握 包括目录结构的管理、外存空间的分配与释放以及空闲空间管理三部分。 完成的内容 通过初始化操作建立一个 模拟外存空间的虚拟磁盘文件,在该文件中保存目录和文件内容。 创建该文件时应创建初始的根目录内容、文件分配表。 文件目录项(可以采用 FCB 格式)应包括类型(目录 or 文件)、创建日期、大小、第一个磁盘块块号。 显示命令提示符“ $”,并根据输入命令完成相应的文件操作:  MD(创建子目录):创建目录文件,并在父目录文件中增加目录项。  C。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。