Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #585

Re: usage of vyukov's mpsc queue

From Ephi Sinowitz <ephisinowitz@yahoo.com>
Newsgroups comp.programming.threads
Date 2011-09-21 06:58 -0400
Message-ID <2011092106580817537-ephisinowitz@yahoocom> (permalink)
References <3b312755-24d8-4505-8cfe-1644c458c4d5@j1g2000yqn.googlegroups.com> <4E79BA45.B3622870@web.de>
Subject Re: usage of vyukov's mpsc queue

Show all headers | View raw


On 2011-09-21 10:19:49 +0000, Alexander Terekhov said:

> Ephi Sinowitz wrote:
>> 
>> Hi,
>> I implemented the queue 
>> http://www.1024cores.net/home/lock-free-algorithms/queues/intrusive-m...
>> with a signaling mechanism for the consumer.
>> Do I need to ensure visibility somehow before setting the event since
>> I'm not spinning in the consumer? How?
>> Producers:
>> ----------------
>> vyukov_queue.push(item);
>> SetEvent(m_queueEvent);
>> Consumer:
>> ---------------
>> for(;;)
>> {
>> WaitForSingleObject(m_queueEvent, INFINITE);
>> while (void* item = vyukov_queue.pop())
>> {
>> // do work
>> }
>> }
>> For reference here is the push()
>> void MPSC_Queue::push(void* item)
>> {
>> item->next = NULL;
>> void* old_head = InterlockedExchangePointer((void *volatile
>> *)&m_head, item);
>> // BLOCK POINT
>> old_head->next = item;  // Do I need to ensure this is visible to
>> the consumer thread?
>> }
> 
> Yes, you need to make old_head->next = item store atomic-release store.

So another interlocked exchange should take care of it.

> 
> Consumer's m_tail->next load must be atomic-acquire load.

Why I don't see any contention here. Just to ensure we are talking 
about the same thing. (The link in the original post was a little off.)
http://www.1024cores.net/home/lock-free-algorithms/queues/intrusive-mpsc-node-based-queue


Producer's 

> RMW can be totally relaxed with respect to memory barriers.
> 
> regards,
> alexander.

Back to comp.programming.threads | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

usage of vyukov's mpsc queue Ephi Sinowitz <esinowitz.public@gmail.com> - 2011-09-20 06:55 -0700
  Re: usage of vyukov's mpsc queue Joshua Maurice <joshuamaurice@gmail.com> - 2011-09-20 17:19 -0700
    Re: usage of vyukov's mpsc queue Ephi Sinowitz <esinowitz.public@gmail.com> - 2011-09-20 18:35 -0700
      Re: usage of vyukov's mpsc queue Ephraim Sinowitz <ephisinowitz@yahoo.com> - 2011-09-21 06:42 -0400
  Re: usage of vyukov's mpsc queue Joshua Maurice <joshuamaurice@gmail.com> - 2011-09-21 00:26 -0700
  Re: usage of vyukov's mpsc queue Alexander Terekhov <terekhov@web.de> - 2011-09-21 12:19 +0200
    Re: usage of vyukov's mpsc queue Alexander Terekhov <terekhov@web.de> - 2011-09-21 12:34 +0200
    Re: usage of vyukov's mpsc queue Ephi Sinowitz <ephisinowitz@yahoo.com> - 2011-09-21 06:58 -0400
      Re: usage of vyukov's mpsc queue Alexander Terekhov <terekhov@web.de> - 2011-09-21 14:02 +0200
        Re: usage of vyukov's mpsc queue Ephi Sinowitz <esinowitz.public@gmail.com> - 2011-09-21 06:08 -0700
          Re: usage of vyukov's mpsc queue Alexander Terekhov <terekhov@web.de> - 2011-09-21 15:18 +0200
            Re: usage of vyukov's mpsc queue Ephi Sinowitz <esinowitz.public@gmail.com> - 2011-09-21 06:56 -0700
              Re: usage of vyukov's mpsc queue Alexander Terekhov <terekhov@web.de> - 2011-09-21 17:06 +0200
                Re: usage of vyukov's mpsc queue Ephi Sinowitz <esinowitz.public@gmail.com> - 2011-09-21 09:16 -0700
                Re: usage of vyukov's mpsc queue Alexander Terekhov <terekhov@web.de> - 2011-09-21 18:20 +0200
  Re: usage of vyukov's mpsc queue Dmitriy Vyukov <dvyukov@gmail.com> - 2011-09-21 09:58 -0700
    Re: usage of vyukov's mpsc queue Alexander Terekhov <terekhov@web.de> - 2011-09-21 19:33 +0200
      Re: usage of vyukov's mpsc queue dvyukov@google.com - 2011-10-02 04:13 -0700
        Re: usage of vyukov's mpsc queue Alexander Terekhov <terekhov@web.de> - 2011-10-04 12:15 +0200
    Re: usage of vyukov's mpsc queue Ephi Sinowitz <esinowitz.public@gmail.com> - 2011-09-21 11:04 -0700
      Re: usage of vyukov's mpsc queue Ephi Sinowitz <esinowitz.public@gmail.com> - 2011-09-21 11:17 -0700
      Re: usage of vyukov's mpsc queue "Chris M. Thomasson" <cristom@charter.net> - 2011-09-24 22:44 -0700

csiph-web