From: brodax <matteo.bordin@gmail.com>
Subject: Re: Ravenscar-compliant bounded buffer
Date: Wed, 05 Sep 2007 01:17:11 -0700
Date: 2007-09-05T01:17:11-07:00 [thread overview]
Message-ID: <1188980231.579119.265840@k79g2000hse.googlegroups.com> (raw)
In-Reply-To: <1xnpics66h1c9.js3eyt5bsx1e.dlg@40tude.net>
As I wrote in a previous post, I would suggest always thinking in
terms of building blocks: sporadic entities, cyclic entities and
(entry-less) protected entities. By following this approach you have
several main advantages: for example the system is *practically*
amenable to static timing analysis.
Just to make an example of a sporadic building block:
generic
with procedure Sporadic_Operation;
Task_Priority : Priority;
--minimum interarrival time
MAT : Positive;
Max_Pending : Positive;
package Sporadic_Entity is
-- Invoking this procedure release the sporadic task
procedure Release;
private
protected type Protocol is
entry Wait(Release_Time : out Time);
procedure Release;
private
Barrier : Boolean := False;
Pending : Integer := 0;
end Protocol;
task type Thread(P : Priority; Interval : Positive) is
pragma Priority(P);
end Thread;
T : Thread(Task_Priority, MAT);
end Sporadic_Entity;
package body Sporadic_Entity is
P : Protocol;
-------------
-- Release --
-------------
procedure Release is
begin
P.Release;
end Release;
--------------
-- Protocol --
--------------
protected body Protocol is
procedure Update_Barrier is
begin
Barrier := (Pending > 0);
end Update_Barrier;
----------
-- Wait --
----------
entry Wait(Release_Time : out Time) when Barrier is
begin
Release_Time := Clock;
Pending := Pending - 1;
Update_Barrier;
end Wait;
-------------
-- Release --
-------------
procedure Release is
begin
if Pending < Max_Pending then
Pending := Pending + 1;
Update_Barrier;
end if;
end Release;
end Protocol;
------------
-- Thread --
------------
task body Thread is
Next_Time : Time := System_Release_Time;
-- System_Release_Time is a system-wide constant specifying the
release time of all
--+ tasks in the system
begin
delay until Next_Time;
loop
P.Wait(Next_Time);
Sporadic_Operation;
Next_Time := Next_Time + Milliseconds(MAT);
delay until Next_Time;
end loop;
end Thread;
end Sporadic_Entity;
Basically the sporadic building block let you instantiate a Ravenscar
compliant sporadic task enforcing a minimum interarrival time. Please
note that with this pattern you are sure by construction that at most
1 task is queued on an entry. The pattern can be easily extended to
include parameters for the sporadic operation (just put a queue where
parameters are stored inside Protocol). The Reader/Writer are
naturally sporadic, as they are release by an event (the buffer is non-
empty/non-full). The Buffer is an entry-less protected object. Then
you can put the logic for the release of the Reader/Writer inside the
buffer: for example, every time the Writer writes a value, it may
release the Reader (by invoking Reader.Release); and the Writer is
released either by writing on a non-full (after writing) buffer or by
the Reader when it reads on the last position of the buffer (the state
of the buffer changes from full to non-full).
next prev parent reply other threads:[~2007-09-05 8:17 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-04 13:53 Ravenscar-compliant bounded buffer Maciej Sobczak
2007-09-05 3:00 ` Steve
2007-09-05 7:38 ` Maciej Sobczak
2007-09-06 4:04 ` Steve
2007-09-06 14:06 ` Robert A Duff
2007-09-06 15:36 ` Dmitry A. Kazakov
2007-09-07 2:36 ` Robert A Duff
2007-09-06 21:13 ` Maciej Sobczak
2007-09-07 2:41 ` Robert A Duff
2007-09-07 11:56 ` anon
2007-09-07 19:44 ` Maciej Sobczak
2007-09-08 0:16 ` anon
2007-09-08 1:19 ` Larry Kilgallen
2007-09-08 5:13 ` anon
2007-09-08 22:06 ` Larry Kilgallen
2007-09-09 2:17 ` anon
2007-09-09 12:07 ` Larry Kilgallen
2007-09-09 13:10 ` Markus E L
2007-09-11 2:44 ` Randy Brukardt
2007-09-08 11:50 ` Niklas Holsti
2007-09-08 12:01 ` Pascal Obry
2007-09-08 17:13 ` anon
2007-09-08 17:11 ` anon
2007-09-08 19:14 ` Markus E L
2007-09-09 14:54 ` anon
2007-09-09 16:01 ` Markus E L
2007-09-09 10:38 ` Gautier
2007-09-09 11:41 ` anon
2007-09-09 13:19 ` Markus E L
2007-09-09 13:52 ` Pascal Obry
2007-09-09 15:22 ` anon
2007-09-09 16:03 ` Markus E L
2007-09-10 0:05 ` Larry Kilgallen
2007-09-10 3:10 ` Markus E L
2007-09-09 16:05 ` Markus E L
2007-09-09 18:40 ` Ed Falis
2007-09-09 19:11 ` Markus E L
2007-09-09 10:57 ` Gautier
2007-09-09 14:49 ` anon
2007-09-09 15:08 ` Pascal Obry
2007-09-09 15:38 ` Markus E L
2007-09-09 19:12 ` Niklas Holsti
2007-09-09 19:28 ` Ed Falis
2007-09-10 12:51 ` Colin Paul Gloster
2007-09-07 1:38 ` Steve
2007-09-07 2:47 ` Robert A Duff
2007-09-05 7:46 ` Dmitry A. Kazakov
2007-09-05 8:17 ` brodax [this message]
2007-09-05 8:30 ` Jean-Pierre Rosen
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox