HR> Most (but not all) OS/2 APIs calls DosExitCritSec() under cover. So
HR> you should not use any API (system, runtime, library) unless you know
HR> that this function would never call a system API.
Actually, that's not quite the right explanation.
The reason not to call APIs is as explained in the CP Guide and Reference.
(The CPREF talks about "dynamic link library calls", but it is really talking
about APIs in any arbitrary libraries. Even statically linked libraries can
be a problem if they use semaphores internally.) If a second thread had been
already in that API when it was blocked by the first thread entering the
criticical section, then that second thread will possibly be holding a mutex
semaphore that restricts access to the internals of that API. If the first
thread then attempts to use that API, it will block on the mutex whilst
holding the critical section, and the two threads will be deadlocked.
¯ JdeBP ®
--- FleetStreet 1.22 NR
2604/104
* Origin: JdeBP's point, using Squish (2:257/609.3)
|