comp.lang.ada
 help / color / mirror / Atom feed
From: "Björn Lundin" <b.f.lundin@gmail.com>
Subject: Re: tasking design considerations
Date: Fri, 20 Jan 2017 09:29:50 +0100
Date: 2017-01-20T09:29:50+01:00	[thread overview]
Message-ID: <o5shmo$cfq$1@dont-email.me> (raw)
In-Reply-To: <396469b6-6efe-49e7-914b-9226637e031e@googlegroups.com>

On 2017-01-20 09:07, rrr.eee.27@gmail.com wrote:
> I want now create a protected object stack. The callbacks from channel A fill the stack on the top. 
> A cyclic task with a cycle time T reads and removes all collected messages from the bottom of the stack. 

Instead of polling the stack, you could have a an entry with a barrier
in the PO that the task hangs upon.

the PO would then have

  procedure Put_On_Stack(Msg)
  entry Get_From_Stack(Msg) when Cnt > 0;
  function Count return Natural;
  private
    Cnt : Natural := 0;


  Put_On_Stack increases Cnt
  Get_On_Stack decreases Cnt

The task could then do

loop
  Get_From_Stack(msg); -- <-- entry with barrier
  exit when msg = exit_message;
  process(msg)
end loop;

The barrier/guard on the entry would be 'stack is not empty'

and to bring the task down at exit of process,
define an exit message and put that in the bottom of the stack for fast
exit, or on the top if processing the whole stack is more important than
a fast exit

--
Björn

  reply	other threads:[~2017-01-20  8:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-20  8:07 tasking design considerations rrr.eee.27
2017-01-20  8:29 ` Björn Lundin [this message]
2017-01-20  8:42 ` Dmitry A. Kazakov
2017-01-20 12:32   ` rrr.eee.27
2017-01-20 14:11     ` Dmitry A. Kazakov
2017-01-20 16:01 ` Jeffrey R. Carter
replies disabled

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