Definition: | integer cs = init_cs() |
Description: | Create a new critical section. |
Comments: | init_cs() should normally be invoked before any create_thread() that may use it; on seeing an init_cs()
within a thread my immediate suspicion would be that the programmer was attempting to create a thread-specific
critical section, which has no possible practical value, if no other thread can get at it to lock it.
As per enter_cs, there is a hidden internal critical section ("stdcs") for use in simple once-only initialisation cases where lock contention is not considered a significant issue. If you have no further use for a critical section, dispose of it using delete_cs(). |
Example: |
mycs = init_cs() ... enter_cs(mycs) ... leave_cs(mycs) ... delete_cs(mycs) |
Example Program: | demo\rosetta\AtomicUrpdates.exw |
See Also: | delete_cs, enter_cs, try_cs, leave_cs, create_thread |
