I am trying to debug a multi-threaded NLM...
Articles and Tips: qna
01 Mar 2003
Q.
I am trying to debug a multi-threaded NLM application. I am using the sleep() function (from the static Watcom libraries) at certain places in the code, where I suspect the application abends my server. The sleep() function should allow all debugging to get into a log file before the abend occurs.
My intention is to see in the debug log what is actually going on. It seems that function sleep() halts the thread from which it was called while other threads continue executing. Am I right here?
My question is: does the sleep() function makes current thread sleep while other threads continue executing, or does the whole module with all its threads sleep?
A.
Short answer: You pass milliseconds to delay(), seconds to sleep(), and delay() does not consume CPU cycles but sleep() does. Delay blocks the calling thread on a semaphore for the amount of time you specify. Delay only sleeps the current thread--all other threads continue execution.
EnterCritSec will stop all of your NLMs co-operative threads from being scheduled until you call ExitCritSec. I stress the co-operative bit because threads in a sister NLM or interrupt time code will still be executed.
* Originally published in Novell AppNotes
Disclaimer
The origin of this information may be internal or external to Novell. While Novell makes all reasonable efforts to verify this information, Novell does not make explicit or implied claims to its validity.