<lancer6238@[EMAIL PROTECTED]
> wrote in message
news:597b7a22-235d-4099-9302-ea0969b7b698@[EMAIL PROTECTED]
> On Sep 29, 5:49 am, "Chris M. Thomasson" <n...@[EMAIL PROTECTED]
> wrote:
>> "Chris M. Thomasson" <n...@[EMAIL PROTECTED]
> wrote in
>> messagenews:PQSDk.4183$Bt7.1369@[EMAIL PROTECTED]
>>
>>
>>
>> > <lancer6...@[EMAIL PROTECTED]
> wrote in message
>>
>news:a099c363-65be-4a41-b080-03caadbddac1@[EMAIL PROTECTED]
>> [...]
>>
>> > So, do_Awork is a producer right?
>
> Yes.
>
>>
>> Please clarify... do_Awork and do_BCDwork can run concurrently within
the
>> global queue impl right? I am curious as to what the queue impl looks
>> like.
>
> It's a circular queue. do_Awork and do_BCDwork should be able to run
> concurrently. Specifically, do_Awork puts items into the queue and
> do_BCDwork removes items from the queue. Ideally, do_Awork should
> write to the queue faster than do_BCDwork can read from the queue, and
> when this does not happen, i.e. do_BCDwork attempts to read an item
> that hasn't been written to the queue yet, it should wait till
> do_Awork has completed writing that item to the queue. Also, more than
> one thread should run do_BCDwork concurrently, with each thread
> reading a different item in the queue, and only one thread runs
> do_Awork.
If your sure that the queue itself does not have a bug, fine. If so, your
experiencing a signaling bug. If not, well, ****%t happens and the queue
needs to be "reexamined"...
>> > Humm... Well, a seg-fault does not always indicate a problem with
>> > misusing
>> > a condvar. Your usually going to get a deadlock. If you think that
the
>> > misuse of a condvar is causing a seg-fault then its probably because
>> > its
>> > allowing multiple threads to access a data-structure which simply
>> > cannot
>> > tolerate it. Are you sure that the implementation of the global queue
>> > is
>> > correct? After you switch over to the semaphore solution proposes
>> > else-thread and run the program, are you still getting seg-faults?
For
>> > some reason, I think the problem may be in the global queue impl...
>
> The seg fault may also be caused by the consumer threads running
> do_BCDwork accessing an item in the queue that hasn't been completely
> written to the queue yet, because the consumer threads have been woken
> too early by the producer thread. I'm trying to correct this problem.
Well, using a semaphore like Szabolcs suggested would solve that. Since,
according to you, do_Awork and do_BCDwork do not need to be under the
protection of a common mutex, well, then a semaphore would be fine. Your
consumers will not get signaled unless the producer has created something
and _fully_ committed into the queue logic indeed. Have you tried using a
semaphore? Do you still experience a seg-fault? Also, if your using POSIX
semaphore, again, please keep in mind that the error condition `EINTR'
can,
and probably WILL, occur every now and then...


|