From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,d495ab2e69ad1962 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!postnews.google.com!k79g2000hse.googlegroups.com!not-for-mail From: brodax Newsgroups: comp.lang.ada Subject: Re: Ravenscar-compliant bounded buffer Date: Wed, 05 Sep 2007 01:17:11 -0700 Organization: http://groups.google.com Message-ID: <1188980231.579119.265840@k79g2000hse.googlegroups.com> References: <1188914005.607732.277400@57g2000hsv.googlegroups.com> <1xnpics66h1c9.js3eyt5bsx1e.dlg@40tude.net> NNTP-Posting-Host: 151.70.131.39 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1188980231 11223 127.0.0.1 (5 Sep 2007 08:17:11 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 5 Sep 2007 08:17:11 +0000 (UTC) In-Reply-To: <1xnpics66h1c9.js3eyt5bsx1e.dlg@40tude.net> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: k79g2000hse.googlegroups.com; posting-host=151.70.131.39; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Xref: g2news2.google.com comp.lang.ada:1747 Date: 2007-09-05T01:17:11-07:00 List-Id: 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).