Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
6
Task/Mutex/Ada/mutex-1.ada
Normal file
6
Task/Mutex/Ada/mutex-1.ada
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
protected type Mutex is
|
||||
entry Seize;
|
||||
procedure Release;
|
||||
private
|
||||
Owned : Boolean := False;
|
||||
end Mutex;
|
||||
10
Task/Mutex/Ada/mutex-2.ada
Normal file
10
Task/Mutex/Ada/mutex-2.ada
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
protected body Mutex is
|
||||
entry Seize when not Owned is
|
||||
begin
|
||||
Owned := True;
|
||||
end Seize;
|
||||
procedure Release is
|
||||
begin
|
||||
Owned := False;
|
||||
end Release;
|
||||
end Mutex;
|
||||
15
Task/Mutex/Ada/mutex-3.ada
Normal file
15
Task/Mutex/Ada/mutex-3.ada
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
declare
|
||||
M : Mutex;
|
||||
begin
|
||||
M.Seize; -- Wait infinitely for the mutex to be free
|
||||
... -- Critical code
|
||||
M.Release; -- Release the mutex
|
||||
...
|
||||
select
|
||||
M.Seize; -- Wait no longer than 0.5s
|
||||
or delay 0.5;
|
||||
raise Timed_Out;
|
||||
end select;
|
||||
... -- Critical code
|
||||
M.Release; -- Release the mutex
|
||||
end;
|
||||
Loading…
Add table
Add a link
Reference in a new issue