C and C++

Concurrency Models: Blocking Functions

Blocking functions don't allow their calling process to continue until they return, but can take a long time to do so: many wait for external events of some kind. A call to a function that is modeled as a blocking function will trigger a Blocking in Critical Section warning if the calling process is holding a lock.



Blocking Functions

CodeSonar ships with library models that allow it to recognize various blocking functions. Some examples are listed below.

Blocking functions recognized include...
CMX-RTX K_Event_Wait()
FreeRTOS vTaskDelay()
libc sleep()
Netscape Portable Runtime (NSPR) PR_CWait()
Win32 Sleep()

Creating New Models

If you are authoring a model for a blocking function, it is usually best to have the model call the already-modeled function that is most similar. This will ensure that CodeSonar correctly treats the function as blocking, and includes it in the appropriate checks.

If no existing model is appropriate, write your model using the extension functions provided. In particular, your model should call csonar_blocking_function(): see the function documentation for an annotated example.