Il 09/10/2013 11:55, Stefan Hajnoczi ha scritto: > + /* Take a ticket */ > + unsigned int ticket = r->tail++; > + > + if (r->nesting > 0) { > + if (qemu_thread_is_self(&r->owner_thread)) { > + r->tail--; /* put ticket back, we're nesting */ > + } else {
ticket is dead in the "nested" path, why not move it (and the increment) directly after the else? Otherwise, the code is very nice. It's very interesting that no pthread mutex is held in the rfifolock critical section, so that the thread that holds the next ticket has a chance to be woken up. Paolo