Your SlideShare is downloading. ×
  • Like
Program tpse
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Program tpse

  • 107 views
Published

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
107
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
7
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. program tpse;uses crt ;type processus=record n1:0..20; n2:0..20; tab:array[1..20,1..16]of integer; end; processeur=array[1..16] of integer; var w,r:processus; p:processeur;procedure init_processeur(var p:processeur);var i:integer;beginfor i:=1 to 16 do p[i]:=0;end;procedure remplire_ready(var r:processus;nb1:integer);var m,n,i:integer;begini:=r.n2+1;for m:=i to i+nb1-1 dobeginif(r.n2<15)then begin r.n1:=r.n1+1; r.n2:=r.n2+1;
  • 2. for n:=1 to 16 do r.tab[m,n]:=1; r.tab[m,10]:=r.n1; end;end;end;procedure afficher_processus(w:processus);var m,n:integer;beginfor m:=1 to w.n2 do begin for n:=1 to 16 do write(w.tab[m,n]:4); writeln; end;end;procedure affiche_processeur (p:processeur);var i:integer;beginfor i:=1 to 16 do write(p[i]:4);writeln;end;procedure transition_ready_to_run(var r:processus;var p:processeur);var i,j:integer;beginfor i:=1 to 16 do p[i]:= r.tab[1,i];for i:=2 to r.n2 do for j:=1 to 16 do r.tab[i-1,j]:=r.tab[i,j];r.n2:=r.n2-1;end;
  • 3. procedure transition_ran_ready (var p:processeur;var r:processus);var i:integer;beginif (r.n2<20)then begin r.n2:=r.n2+1; for i:=1 to 16 do r.tab [r.n2,i]:=p[i]; r.tab[r.n2,6]:=1; end;p[1]:=0;end;procedure transition_wate_to_ready(var r,w :processus);var i:integer;beginif (r.n2<15) then begin r.n2:=r.n2+1; for i:=1 to 16 do r.tab [r.n2,i]:=w.tab[w.n2,i]; end;w.n2:=w.n2-1;end;procedure transition_run_to_wait(var w:processus;var p:processeur);var i:integer;beginif (w.n2<15) then begin w.n2:=w.n2+1;
  • 4. for i:=1 to 16 do w.tab [w.n2,i]:=p[i]; end;p[1]:=0;end; procedure teste(var r,w:processus;var p:processeur); begin if (p[1]=0)then transition_ready_to_run(r,p) else if (p[5]=0) then transition_run_to_wait(w,p) else if(p[6]=0)then transition_ran_ready (p,r); if (w.tab[w.n2,5]=1)then transition_wate_to_ready(r,w); if(p[1]=0)then transition_ready_to_run(r,p); end;procedure help;beginwriteln (1:remplir la matrice ready);writeln(2:entre le bit que vous voulez metre a 0 dans le processeur);writeln(3:entre le bit que vous voulez metre a 1 dans le processeur);writeln(4:metre a 1 le 5éme bit de dernier ligne dans W);writeln(5:afficher le processeur);
  • 5. writeln(6:afficher les processus ready);writeln(7:afficher les processus wait);writeln(8:help);end;var choix:char; k:integer;begintextcolor(20);clrscr;init_processeur(p);r.n2:=0;r.n1:=0;w.n2:=0;w.n1:=0;writeln (1:remplir la matrice ready);writeln(2:entre le bit que vous voulez metre a 0 dans le processeur);writeln(3:entre le bit que vous voulez metre a 1 dans le processeur);writeln(4:metre a 1 le 5éme bit de dernier ligne dans W);writeln(5:afficher le processeur);writeln(6:afficher les processus ready);writeln(7:afficher les processus wait);
  • 6. writeln(8:help);repeatwrite(entre votre choix: );readln(choix);case choix of1:begin write(entre le nombre de processus: ); readln(k); remplire_ready(r,k); end;2:begin readln(k); if(k<17)and(k<>10)then p[k]:=0; end;3:begin readln(k); if(k<17)and(k<>10)then p[k]:=1; end;4:w.tab[w.n2,5]:=1;5:affiche_processeur(p);6:afficher_processus(r);7:afficher_processus(w);8:help;end;teste(r,w,p);until(choix=q);end.