[Click] NotifierQueue on multi-threaded Click problem.

Joonwoo Park joonwpark81 at gmail.com
Fri Sep 7 14:32:17 EDT 2007


Hi Beyers.

2007/9/8, Beyers Cronje <bcronje at gmail.com>:
>
> Hi Joonwoo,
>
> > I think the enq() and deq() has problem.
> > As you said, one enq() and one deq() can be run concurrently.
> > But operation of the code, '_tail = next' of enq() and '_head =
> > next_i(_head)' is not atomic (I mean the equalizer)
> > because of _tail and _head is INT.
> > Therefore the code 'if (next != _head) {' of push() and 'if (_head !=
> > _tail)' of pull() cannot be worked correctly.
> > So I think these are should be atomic.
>
> Note I'm fairly new to multithreading so excuse any ignorance on my part.
>
> Correct me if I'm wrong here, but isn't the worst that could happen:
>
>  (1) pull() might see an empty queue in the case where push() adds a packet
> to an empty queue at the same time. Not really a problem as pull will get
> this packet the next time it's scheduled.

Yes, task goes sleep when it sees empty packet from push(), but It's
ok because of the push() wake it up when a new packet is avalible.

> (2) enq()  might incorrectly drop a packet in the event of a full queue and
> pull() is run at the same time. This will only drop 1 packet in the event of
> a 'full' queue.

Can I know why do you think like that?
It seems ok to me if _head and _tail is atomic value.

Joonwoo Park

>
> Or am I missing something?
>
> Beyers
>


More information about the click mailing list