From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: tasking design considerations
Date: Fri, 20 Jan 2017 15:11:55 +0100
Date: 2017-01-20T15:11:55+01:00 [thread overview]
Message-ID: <o5t5ra$k1k$1@gioia.aioe.org> (raw)
In-Reply-To: 7552bc76-fba8-4208-b855-e47140986488@googlegroups.com
On 20/01/2017 13:32, rrr.eee.27@gmail.com wrote:
> On Friday, January 20, 2017 at 9:42:36 AM UTC+1, Dmitry A. Kazakov wrote:
> ...
>> 2. You don't need a protected object or other locking method because a
>> FIFO with a single writer and a single reader is task-safe (can be
>> designed lock-free).
>
> I don't understand. It might be that the task reading the FIFO
> starts while a callback is active adding a message to the FIFO. I think there
> must be a lock to exclude reading and writing the FIFO at the same time.
No. The idea is as follows. The FIFO is a ring buffer. Reader moves the
out-index in the buffer. Writer does the in-index (after placing an
element). Index I/O is atomic. The space to read is between out- and
in-indices. The space to write in outside that. They don't overlap, thus
no exclusion is needed.
[ You can find an implementation here
http://www.dmitry-kazakov.de/ada/components.htm#10.1 ]
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2017-01-20 14:11 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
2017-01-20 8:42 ` Dmitry A. Kazakov
2017-01-20 12:32 ` rrr.eee.27
2017-01-20 14:11 ` Dmitry A. Kazakov [this message]
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