When a program calls exit(), all threads in that program are normally terminated at their current execution point. If a thread holds a mutex semaphore, that semaphore changes state to "Owner died". Any code that subseqently tries to request that semaphore will fail.
To avoid
this in OS/2, surround the protected code with calls to
DosEnterMustComplete() and DosExitMustComplete(). This prevents
the thread from terminating until the Must Complete section
ends.