init_cs
| Definition: | integer cs = init_cs() |
| Description: | Create a new critical section. |
| pwa/p2js: | Not supported. |
| 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)
For a complete runnable program, see demo\rosetta\AtomicUrpdates.exw |
| Implementation: | via :%pInitCS in builtins\VM\pHeap.e (an autoinclude). |
| See Also: | delete_cs, enter_cs, try_cs, leave_cs, create_thread |