comp.lang.ada
 help / color / mirror / Atom feed
From: Charles Hixson <charleshixsn@earthlink.net>
Subject: Re: asynchronous task communication
Date: Sat, 05 Jan 2013 12:19:02 -0800
Date: 2013-01-05T12:19:02-08:00	[thread overview]
Message-ID: <4OCdnRkrDcOrEXXNnZ2dnUVZ_q2dnZ2d@earthlink.com> (raw)
In-Reply-To: <50e5755c$0$9517$9b4e6d93@newsspool1.arcor-online.net>

On 01/03/2013 04:11 AM, Georg Bauhaus wrote:
> On 03.01.13 02:30, Charles Hixson wrote:
>> I guess a part of the question is "What is the overhead on a protected
>> variable?". If it's small, then I'd prefer to have one attached to
>> every cell, as it eliminates one centralized spot of contention, and
>> means that slightly simpler messages can be passed.
>
> Chances are that a protected object employs a locking mechanism
> of the OS (at least in a "PC run-time"). This is probably not the
> fastest, leanest thing to have. However, I guess you could use
> CAS based access to the letter boxes, in particular if the number
> of messages is fixed.
>
> Pat Rogers has illustrated an example, also referred to in Ada
> Gems #93 and #98,
> http://benchmarksgame.alioth.debian.org/u32q/program.php?test=chameneosredux&lang=gnat&id=2
>
> http://www.adacore.com/adaanswers/gems/gem-93-high-performance-multi-core-programming-part-1/
>
>
Unfortunately, the size is not fixed.  I can say that there is one 
mailbox per cell, but the number of cells is not fixed either.  And 
while I'm planning on limiting the size (capacity) of the mailbox, the 
largest size is expected to be far larger than the mean size.

OTOH, simplifying things is that the mailbox has only one reader, and 
writers, except the reader, can only append.  Also, the reader, "takes 
possession" of the contents of the mailbox, and replaces it with an 
empty mailbox.  At least that's my current design.  I've been 
contemplating a modified design where the mailbox is "attached" to the 
cell, and hold both out-going and in-coming messages.   There would also 
need to be a "letter-carrier" that collected and distributed the 
messages.  This would reduce the sync requirements to a boolean flag set 
and cleared by the mailbox accessors that said whether the mailbox was 
busy.  If it was busy, the accessing task could decide whether to wait a 
bit or to do something else and the try again.  This would require a 
"clear and set" on the flag, but nowhere else.
This modified design appears clearly superior if there are enough tasks 
that one can be assigned to be the letter-carrier, and I guess that if I 
arrange it to be inactive most of the time it might work even on my 
limited system.  (Actually the real design would then make the cell 
logically dependent on the mailbox, as in normal operation the mailbox 
could control the rolling in of the cell from secondary storage. 
Perhaps only occasionally would the entire roster of cells be 
sequentially activated.)

This idea for a design modification is because an investigation of 
sizing constraints shows that the original design it totally impossible 
on my system.  Even this redesigned system may need to be modified so 
that mailboxes spend much of their time on disk, if I can devise a way 
to enable this.  Perhaps some sort of rolling activation.  Virtual 
memory isn't a plausible answer because the program needs to be able to 
save its state quickly and shutdown...and then to pick-up where it left 
off.  (But this is getting far away from the original problem of 
concurrent design, which now looks solved...I've got in hand a design 
for a CAS based stack, which is all that the mailbox needs, though I 
need to modify it a bit to "popall" rather than simply "pop".)



  parent reply	other threads:[~2013-01-05 20:19 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-31  0:16 asynchronous task communication Charles Hixson
2012-12-31  9:04 ` Simon Wright
2012-12-31 11:49   ` Simon Wright
2012-12-31 10:50 ` J-P. Rosen
2012-12-31 12:09 ` Georg Bauhaus
2012-12-31 18:52   ` Charles Hixson
2012-12-31 20:18     ` Shark8
2012-12-31 21:09     ` Niklas Holsti
2012-12-31 22:15       ` Randy Brukardt
2013-01-01  3:58         ` Charles Hixson
2013-01-01  4:48           ` tmoran
2013-01-01 17:59             ` Charles Hixson
2013-01-01  3:51       ` Charles Hixson
2013-01-01  9:59         ` Dmitry A. Kazakov
2013-01-01 10:38         ` Brian Drummond
2013-01-01 12:32         ` Jeffrey Carter
2013-01-01 18:21           ` Charles Hixson
2013-01-01 18:54             ` Robert A Duff
2013-01-02  7:36               ` Charles Hixson
2013-01-02  9:55                 ` Dmitry A. Kazakov
2013-01-02 19:02                   ` Charles Hixson
2013-01-02 20:35                     ` Dmitry A. Kazakov
2013-01-03  0:20                       ` Charles Hixson
2013-01-03  6:34                         ` Charles Hixson
2013-01-03  8:50                         ` Dmitry A. Kazakov
2013-01-03 19:01                           ` Charles Hixson
2013-01-03 10:01                         ` J-P. Rosen
2013-01-03 19:29                           ` Charles Hixson
2013-01-04  8:17                             ` J-P. Rosen
2013-01-05  4:31                               ` Charles Hixson
2013-01-09  8:34                                 ` Stephen Leake
2013-01-03 22:27                         ` Randy Brukardt
2013-01-05  5:18                           ` Charles Hixson
2013-01-05  8:48                             ` Niklas Holsti
2013-01-06 22:55                               ` Charles Hixson
2013-01-07  0:38                                 ` tmoran
2013-01-07  6:07                                 ` Shark8
2013-01-07 10:49                                 ` Brian Drummond
2013-01-07 18:27                                   ` Jeffrey Carter
2013-01-08 12:02                                     ` Brian Drummond
2013-01-08 17:12                                       ` Jeffrey Carter
2013-01-08 18:18                                         ` Simon Wright
2013-01-08 20:29                                           ` Dmitry A. Kazakov
2013-01-08 21:01                                           ` Jeffrey Carter
2013-01-08 21:14                                             ` Simon Wright
2013-01-08 22:11                                               ` Randy Brukardt
2013-01-08 22:52                                               ` Jeffrey Carter
2013-01-08 22:26                                         ` Brian Drummond
2013-01-08  2:41                             ` Randy Brukardt
2013-01-02 22:43         ` Niklas Holsti
2013-01-03  1:30           ` Charles Hixson
2013-01-03 12:11             ` Georg Bauhaus
2013-01-03 13:17               ` Dmitry A. Kazakov
2013-01-05 20:19               ` Charles Hixson [this message]
2013-01-07  4:01                 ` Shark8
2013-01-01 19:59     ` J-P. 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