教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 政务民生 >

操作系统2014课程设计(3)

来源:网络收集 时间:2026-07-24
导读: if((w=sem[se].firstwr)==NIL) sem[se].firstwr=exe; else { while(pcb[w].nextwr!=NIL) w=pcb[w].nextwr; pcb[w].nextwr=exe; } } v(se,ad) int se; char ad; { if(++sem[se].value>0) return(FALSE); wakeup(se);

if((w=sem[se].firstwr)==NIL) sem[se].firstwr=exe; else {

while(pcb[w].nextwr!=NIL) w=pcb[w].nextwr; pcb[w].nextwr=exe; } } v(se,ad) int se; char ad; {

if(++sem[se].value>0) return(FALSE); wakeup(se);

savearea[exe][1]=ad; savearea[exe][0]=i; return(TRUE); }

wakeup(se) int se; { int w;

w=sem[se].firstwr; if(w!=NIL) {

sem[se].firstwr=pcb[w].nextwr; pcb[w].status='r';

printf(\ } }

process1() {

if(addr=='a') goto a1; if(addr=='b') goto b1; if(addr=='c') goto c1; if(addr=='d') goto d1; if(addr=='e') goto e1; if(addr=='f') goto f1;

for(i=0; i<3;i++)/*如果程序执行超过5次,则*/ {

printf(\ if(p(0,'a')) break; /*process 1 is blocked*/

a1: printf(\ if(timeint('b')) break; /*time silce interrupt*/ b1: printf(\

printf(\calls V on semaphorel and quit cretical section 1.\\n\

if(v(0,'c')) break; /*wake up a blocked process*/ c1: printf(\ if(p(1,'d')) break;

d1: printf(\ if(timeint('e')) break; e1: printf(\

printf(\calls V on semaphore2 and quit cretical section2.\\n\

if(v(1,'f')) break; /*wake up a block process*/ f1: printf(\

}

if(i<3) return; eexit(0); }

process2() {

if(addr=='a') goto a2; if(addr=='b') goto b2; if(addr=='c') goto c2; if(addr=='d') goto d2; if(addr=='e') goto e2; if(addr=='f') goto f2; for(i=1;i<6;++i) {

printf(\ if(p(1,'a')) break; /*process2 is blocked*/

a2: printf(\ if(timeint('b')) break; b2: printf(\

printf(\section2.\\n\

if(v(1,'c')) break; /*wake up a blocked process*/ c2: printf(\ if(p(0,'d')) break; /*process2 is blocked*/ d2: printf(\ if(timeint('e')) break; e2: printf(\

printf(\call V on semaphorel and quit cretical setion2\\n\

if(v(0,'f')) break; /*wkup up a block process*/

f2: printf(\ }

if(i<6) return; eexit(1); }

process3() {

if(addr=='a') goto a3; if(addr=='b') goto b3; if(addr=='c') goto c3; for(i=1;i<6;++i) {

printf(\ if(p(1,'a')) break; /*process3 is blocked*/

a3: printf(\ if(timeint('b')) break; b3: printf(\

printf(\ calls V on semaphore and quit cretical section.\\n\

if(v(1,'c')) break; /*wake up a blocked process */ c3: printf(\ }

if(i<6) return; eexit(2); } eexit(n) int n; {

pcb[n].status='c';

printf(\ exe=NIL; } main() {

int j=0; int k; char m;

printf(\ init();

printf(\

printf(\ for(;;) {

j=j+1;

printf(\ //scanf(\ getchar();

if((k=scheduler())!=NIL) {

switch(k) {

case 0: process1(); break;

case 1: process2(); break;

case 2: process3(); break;

…… 此处隐藏:169字,全部文档内容请下载后查看。喜欢就下载吧 ……
操作系统2014课程设计(3).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/447902.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)