.
.
1.
2.
3.
4.
5.
.
: : ;
:
1.Avail able 2.Max 3.All ocati on 4.Need :
pi
:
step1 RequestNeed, goto step2;
step2 RequestAvailable, goto step3;
step3:
Av ailableAvailableRequest;
AllocationAllocationRequest;
NeedNeedRequest
1
:
Work:ARRAY1..m Finish:ARRAY1..n : step 1:
of integer; of Boolean;
W o r kAv ail abl e;
Fin ishfalse;
step 2i: a. Fin ishf alse; b.NeedWork;
goto step4 step3
WorkWorkAllocation;
Fin ishtrue;
goto step2
step 4i,Finishtrue,
. 1.
2.:
2
3.:
4.
3
5.
. :
i n cl u de st dl i b. hin cludestdio.h define smax 10 define pmax 6
4
typedef struct
char devicename;
int stotal; int allocation; int available;
dev ice;
device systemdevicesmax;
char setdevicenamedevice
char chH; forint j0;jn;j
int i;
fori0;in;i
ifai.devicenamech
ch;
break;
return ch;
int finddeviceindexdevice
forint i0;isbsm;i
ifai.devicenamename return i;
void main
int iftc1;
int gn;
int dqsbs0;
char devicename,a; int jcs;
int maxpmaxsmax;
int allocationpmaxsmax; int needpmaxsmax;
a,int n
a,char name,int sbsm
5
int requestsmax; int jch;
int availablesmax; bool finishpmax; int mir;
int st; whileiftc
printf0:1:2:3:4:5:;
scanfd,gn; switchgn
case 0:
iftc0; break;
systemdev icedqsbs.allocation0;
case 1:
printf:; scanfd,systemdevicedqsbs.stotal;
systemdev icedqsbs.availablesystemdevicedqsbs.stotal systemdev icedqsbs.allocation;
ifdqsbs0
systemdev icedqsbs.devicenameH; dqsbs;
break;
else
systemdev icedqsbs.devicenamesetdevicenamesystemdevice,dqsbs; dqsbs;
break;
case 2:
printf:; scanfc,a;
scanfc,dev icename; scanfc,a;
6
int sbifinddeviceindexsystemdevice,devicename,dqsbs; printfc,devicename;
forint msbi;mdqsbs1;m systemdev icemsystemdev icem1;
dqsbs; break;
case 3:
printfscanfc,a; scanfc,dev icename; scanfc,a;
:n;
printfint i;
:n;
scanfd,i;
int sbifinddeviceindexsystemdevice,devicename,dqsbs; systemdev icesbi.stotali;
break;
case 4:
forint i0;idqsbs;i
printfc,d,d,dn ,systemdevicei.devicename,systemdevicei stotal,systemdev icei.allocation,systemdev icei.available;
.
break;
case 5:
int iftcmn1; whileiftcmn
printf
2 ;
int gnh;
:0
1
scanfd,gnh; switchgnh
case 0:
7
:,jci;
:,jci;
forint
printfd
scanfd,allocationjcit;
allocationjcit;
iftcmn0;
break; case 1:
systemdev icex.allocationallocationmx; fort0;tsmax;t
systemdev icet.allocation;
a v a il a bl et 0; fort0;tdqsbs;t
av ailabletsystemdevicet.stotal printfd,availablet;
int t;
printf:;
scanfd,jcs;
forint i0;ipmax;i
forint j0;jsmax;j
maxij0; allocationij0;
n e ed i j 0;
jci0;jcijcs;jci
fort0;tdqsbs;t scanfd,maxjcit;
printfdfort0;tdqsbs;t
fort0;tsmax;t
n eedjcitmaxjcit
forint x0;xsmax;x
forint m0;mjcs;m
8
:;
case 2:
printf
scanfd,jch; forint ri0;rismax;ri
requestri0;
int sqsbzl;
printf:;
scanfd,sqsbzl; scanfc,a;
forint i0;isqsbzl;i
printf:; scanfc,dev icename;
scanfc,a;
break;
int sbifinddev iceindexsystemdev ice,devicename,dqsbs;
printf:;
int sqsbsm; scanfd,sqsbsm;
scanfc,a; requestsbisqsbsm;
formir0;mirsmax;mir
if r equ estm ir needj chm irbreak;
ifmir!smax
printf!n;
else
forint i0;ipmax;i finishifalse;
int worksmax;
forint w0;wsmax;w
9
finishnfalse;n
forint k0;kjcs;k
forint n 0;njcs
forst0;stsmax;st
! n;
ifneednstworkst break;
ifstsmax
forint z0;zsmax;z workz allocationnz ;
finishntrue;
int p0; forp0;pjcs;p
iffin ishpfalse
printf!n; break;
ifpjcs
printf
break;
10
workwavailablewrequestw; allocationjchwrequestw;
n eedj chw requestw ;
.
.
!
.
1.3
2.3. 3 4.
11
Reviews
There are no reviews yet.