erreurs programme sémaphores
Bonsoir,
S'il vous plait je ne sais pas programmer en Ada et je dois arriver à compiler ce programme. le prof l'a écrit vite ou les élèves ont mal copié ou les deux parce- qu’il contient beaucoup d'erreurs!
c'est un programme de synchronisation moyennant les sémaphores.
Merci beaucoup pour toute aide !
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
with ada.calcular,ada.text_io;
use ....;
procedure Q2 is
protected type Semaphore(Init:Integer:=1) is
entry P;procedure V;
private Compteur:Integer:=Init;
end Semaphore;
protected body Semaphore is
Entry P when Compteur>0 is begin
Compteur:=Compteur-1; end P;
procedure V is begin
Compteur:=Compteur+1; end V;
end Semaphore;
nb:constant;u,t,huit,seise:time;
Protected Type AC is
Procedure Initialisation
procedure date_ticket;
Entity App_client(ng:positive);
Private
n-t-i:natural:=1;// n° ticket ?
n-c-a-s:natural:=1; //n° client à servir
end AC
Protected body is
Protected dde_t is
x:natural:=(n-t-i)-(n-c-a-s);
Put_line("vs êtes N"&n-t-i'img&"E"&x'img&" en attente");--B
n-t-i:=n-t-i+1;
end dde_ticket; // dde_ticket c'est demande ticket
Entity App_client(ng:positive)
when n-c-a<n-t-i is
B
put_line ("le clt"& n-c-a-s'img&"est appelle au ghichet'&ng'img");
n-c-a=n-c-a+1;
end Ap_c;
end AC;
a:ac;
Task clt;
Task Type Guichet(ng:positive);
Task body clt is
B
t:=clock;huit-t-(seconds(t)-8-3600);
while(clock>hut and clock<seise)loop
a.d_ticket;
delay 20.0;
a.initialisation
delay until seise+16+3600;
end loop
end clt;
s.semaphore(1);
Task body Guichet is
B
while(c>h and c<seise)loop
SP;
a.Ap_client;
SV;
delay 10.0;
end loop;
end Ghuichet;
Type ptr acess Ghuichet;
tg:array(1..n)of ptr;
Begin
for i in 1..n loop
tg(i)=new Ghuichet(i);
end
end Q2; |