When a task has more than one thread is running, steps must be taken to ensure that only one thread at a time makes use of certain run-time library functions. A thread can ensure that this rule is not broken by waiting for the semaphore par_sema before using one of these functions.
After finishing with the run-time library, the thread should signal par_sema so that other threads can get access.
par_sema is also used by all the functions of the par package. For this reason, you must not call one of the other par package functions from a thread which has already claimed par_sema as described above.
Note that par_sema is initialized automatically by the run-time library. Do not try to initialize it in your own code.
|