comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: STM32F4 Discovery, communication and libraries
Date: Sun, 31 Aug 2014 21:41:15 +0300
Date: 2014-08-31T21:41:15+03:00	[thread overview]
Message-ID: <c6h8ieFfss4U1@mid.individual.net> (raw)
In-Reply-To: <1xrcksk78afho$.xz6vgakq9o4t.dlg@40tude.net>

On 14-08-31 10:02 , Dmitry A. Kazakov wrote:
> On Fri, 29 Aug 2014 19:31:00 +0300, Niklas Holsti wrote:
> 
>> For example (from memory, not tested):
> 
> [...]
> 
>> Did that answer your question?
> 
> Sort of.

Good.

> No_Local_Protected_Objects means all requests are pre-allocated at the
> library level and distributed by another protected object? With busy
> waiting for a free request?

No, the _request_ in my example code is not a protected object; it is an
ordinary record type. It _refers_ to a protected object which is a kind
of "I/O wait object".

The PO "wait object" is of course statically allocated (by Ravenscar
rules). Any task that will issue I/O requests must allocate such a PO
for itself. (If the task uses several different I/O servers, which have
different "wait object" types, the task has to allocate one PO for each
such I/O server it will use.)

(Oh well, of course one could also statically allocate a shared pool of
such POs and use some kind of protocol by which tasks can reserve a PO
from the pool when they need one, but why make things difficult?)

The example code I gave assumed that each client issues at most one
request at a time, to one server, and then waits for the request to be
completed. This requires one request object (which can be locally
allocated, or can even have value-semantics and be constructed in the
I/O call as in my example code), and one PO, which can be reused for any
number of requests.

By adding request identifiers and other data-structure complexities one
can implement multiple concurrent requests, waiting for any one of
multiple requests to complete ("select"), etc.

> When I evaluated Ravenscar for our middleware (long ago), the concern was
> publisher/subscriber services. I/O queue viewed as one of them. I didn't
> consider a solution like yours because the requirement was that more than
> one task could await for same I/O event. You reserve the event for single
> task and other publisher/subscriber services (e.g. the data logger, network
> data server, health monitor etc) may not use it because of
> Max_Protected_Entries = 1. The event cannot propagate because of
> No_Requeue_Statements. Tasks could flood the queue with their
> requests/events but they cannot do that for more than one queue.

You list a lot of things there... I don't really see how they are
related to each other, or if they are separate problems.

If for some reason you want to wake up two tasks when one I/O finishes,
the sample principle can be used: record two references, to two
protected objects - one per task - in the I/O request, and signal both
of them when the I/O completes.

For publish/subscribe, I would do something like this (not tested):


   protected type Mailbox_T
   --
   -- Each subscriber has an object of this type.
   --
   is

      procedure Signal (Event : in Event_Data_T);
      -- Called by the Publisher (through Publication_Channel, see
      -- below) to broadcast the Event to each subscriber.

      procedure Get_Last (
         Signalled : out Boolean;
         Event     : out Event_Data_T);
      -- Called by the Subscriber to poll (ask) if a new
      -- Event has been Signalled (i.e. non-blocking).

      entry Await (Event : out Event_Data_T);
      -- Called by the Subscriber when it wants to wait for
      -- the next broadcast Event.
   ...

   end Mailbox_T;


   type Mailbox_Ref is access all Mailbox_T;
   -- What the Publisher knows about a Subscriber.


   protected Publication_Channel is

      procedure Subscribe (
         Mailbox : in     Mailbox_Ref;
         Success :    out Boolean);
      -- Called by a new Subcriber.
      -- Enters the Mailbox (reference) in the subscriber list, or
      -- fails if the list is full (Success returned as False).

      procedure Publish (Event : in Event_Data_T);
      -- Called by the Publisher to broadcast a new Event
      -- to all subscribers in the list, by calling the Signal
      -- operation of the Mailbox for each subscriber.

   private

      Subscribers : array (1 .. 100) of Mailbox_Ref;

      Num_Subscribers : Natural := 0;
      -- The active subscriptions are indexed 1 .. Num_Subscribers.

   end Publication_Channel;


Depending on the timing and on whether it is important not to lose any
events, Mailbox_T may need an internal Event queue, or there may be a
global queue of past events to which the queue in Mailbox_T holds
references, and other such data structure refinements, all orthogonal to
Ravenscar constraints.

> It might do what you wanted, but it does not look scalable for the OP's
> purpose.

So far, I don't see anything in the OP's requirements that could not be
implemented with Ravenscar tasking.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
      .      @       .


  parent reply	other threads:[~2014-08-31 18:41 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-26 22:38 STM32F4 Discovery, communication and libraries roy.emmerich
2014-08-27  2:40 ` Luke A. Guest
2014-08-27 12:35   ` Roy Emmerich
2014-08-27  7:41 ` Dmitry A. Kazakov
2014-08-27 13:35   ` Roy Emmerich
2014-08-27 16:00     ` Dmitry A. Kazakov
2014-08-27 13:08 ` Dennis Lee Bieber
2014-08-27 15:44   ` Roy Emmerich
2014-08-28  1:37     ` Dennis Lee Bieber
2014-08-27 16:03   ` Roy Emmerich
2014-08-28  1:48     ` Dennis Lee Bieber
2014-08-28 10:12       ` Roy Emmerich
2014-08-28 13:00         ` Dmitry A. Kazakov
2014-08-28 16:28           ` Mike Silva
2014-08-28 17:03             ` Roy Emmerich
2014-08-28 20:09             ` Dmitry A. Kazakov
2014-08-28 20:34               ` embeddedrelatedmike
2014-08-29  7:34                 ` Dmitry A. Kazakov
2014-08-29 15:59                   ` Niklas Holsti
2014-08-29 16:59                     ` [OT] Ravenscar (the place, not profile), was: " Simon Clubley
2014-08-29 17:18                       ` Niklas Holsti
2014-08-29 17:31                         ` Simon Clubley
2014-08-30 14:55                           ` Dennis Lee Bieber
2014-08-29 17:59                       ` Jeffrey Carter
2014-08-29 23:30                       ` Randy Brukardt
2014-08-30 11:25                         ` Simon Clubley
2014-08-31 11:09                           ` Phil Thornley
2014-08-30 12:36                         ` Peter Chapin
2014-08-31 18:37                         ` Dirk Craeynest
2014-08-31 19:38                           ` Simon Clubley
2014-08-29 17:24                   ` Mike Silva
2014-08-29 23:35                     ` Randy Brukardt
2014-08-29 13:06                 ` Dennis Lee Bieber
2014-08-29 16:52                   ` Niklas Holsti
2014-08-31  0:49                     ` Shark8
2014-08-28 21:17               ` Niklas Holsti
2014-08-29  0:07                 ` Roy Emmerich
2014-08-29 17:58                   ` Niklas Holsti
2014-08-29  7:41                 ` Dmitry A. Kazakov
2014-08-29 16:31                   ` Niklas Holsti
2014-08-29 16:47                     ` Roy Emmerich
2014-08-29 19:41                       ` Niklas Holsti
2014-08-30 22:00                         ` Roy Emmerich
2014-08-31 10:08                           ` Simon Wright
2014-09-01 20:15                           ` Niklas Holsti
2014-09-01 21:11                             ` Jeffrey Carter
2014-08-31  4:54                       ` gvdschoot
2014-09-09 19:17                         ` Roy Emmerich
2014-09-09 20:20                           ` Mike Silva
     [not found]                             ` <a54dcc42-d4e2-4d53-b381-2bb7a0eef1ee@googlegroups.com>
2014-09-10  1:41                               ` Dennis Lee Bieber
2014-09-10  8:52                                 ` Roy Emmerich
2014-09-10 13:05                                   ` Dennis Lee Bieber
2014-09-10 17:16                                     ` Simon Wright
     [not found]                               ` <a2e59fce-751c-46a0-90f3-80430c627732@googlegroups.com>
2014-09-10  7:22                                 ` Dmitry A. Kazakov
2014-09-10  9:35                                 ` Roy Emmerich
2014-09-10 14:11                               ` Stephen Leake
2014-09-10 17:46                                 ` Jeffrey Carter
2014-09-10 18:37                                   ` Dmitry A. Kazakov
2014-09-11  9:53                                   ` Stephen Leake
2014-09-11 17:19                                     ` Jeffrey Carter
2014-09-10 20:58                               ` Brian Drummond
2014-09-10 23:40                                 ` Dennis Lee Bieber
2014-08-29 16:58                     ` Niklas Holsti
2014-08-31  7:02                     ` Dmitry A. Kazakov
2014-08-31 15:44                       ` Brad Moore
2014-08-31 16:15                         ` Dmitry A. Kazakov
2014-09-01 16:15                           ` Brad Moore
2014-09-01 16:42                             ` Dmitry A. Kazakov
2014-08-31 18:41                       ` Niklas Holsti [this message]
2014-09-01 16:42                         ` Dmitry A. Kazakov
2014-09-01 17:21                           ` G.B.
2014-09-02  8:21                             ` Dmitry A. Kazakov
2014-09-02 13:04                               ` G.B.
2014-09-02 14:18                                 ` Dmitry A. Kazakov
2014-09-02 16:44                               ` Jeffrey Carter
2014-09-02 19:02                                 ` Niklas Holsti
2014-09-02 23:19                               ` Randy Brukardt
2014-09-03  1:40                                 ` gdotone
2014-09-04  9:26                                   ` Roy Emmerich
2014-09-04 17:58                                     ` Niklas Holsti
2014-09-05 11:47                                       ` Simon Clubley
2014-09-09 19:04                                         ` Roy Emmerich
2014-09-01 18:39                           ` Niklas Holsti
2014-09-02  8:19                             ` Dmitry A. Kazakov
2014-08-28 13:10         ` Dennis Lee Bieber
2014-08-29  2:52           ` Dennis Lee Bieber
2014-09-20 20:50   ` David Thompson
2014-08-27 16:17 ` Mike Silva
2014-08-27 16:36   ` Roy Emmerich
2014-08-27 16:58     ` Simon Clubley
2014-08-29 19:36 ` johnscpg
2014-08-30 15:06   ` Stephen Leake
2014-09-02 21:40 ` rrr.eee.27
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox