Hi,
This isn't enough code to determine why your stack overflows (no code for the "block()", "deQueue()" and "queue()" functions, and also no way to tell if relevant pieces of data are marked as "volatile" or not).
However, I have a feeling your code isn't correct - the lock needs to be atomic so that there's no race conditions when different CPUs try to get the same lock at the same time. Note: I assume you do care about multi-CPU.
jrussel316 wrote:Also, any general information about good methods for debugging problems like this where the bug is a result of the interactions of many different pieces of code running in different processes would be helpful.
For this specific problem, I'd start by replacing the mutex with a simple spinlock to see if that fixes things. Then I'd try to test each smaller piece by itself (e.g. write some temporary code to test the "block()" function by itself, then do the same for the "deQueue()" function, then the "queue()" function).
Alternatively you could try single-stepping with the Bochs debugger, or inserting things at strategic locations in the code. For example (using Bochs with the "0xE9 I/O port hack" enabled), you could do "outportb(0xE9, '+')" when a task is being put on a queue, "outportb(0xE9, '-')" when a task is removed from the queue, and "outportb(0xE9, '!')" when the queue becomes empty. In this case you might get something like "+-!++--!" which looks good, or "+++-++-++++-" which would probably indicate that the same task is being put on the queue more than once, or "+-!-----+-----" which might indicate that the same task is being removed from the queue more than once.
Cheers,
Brendan