Cicode Programming Reference > Cicode Function Categories > Task Functions Introduction > LeaveCriticalSection

LeaveCriticalSection

Relinquishes the current thread's ownership of a critical section (shared critical resource). Once ownership is relinquished, access to the critical section is available to the next thread that requests it (using the EnterCriticalSection() function). If a thread has been waiting for access, it will be granted at this point.

LeaveCriticalSection() needs to be called once for each EnterCriticalSection() used.

Note: This function is process-based, not computer-based, and so will only prevent access to a critical section within a single process. This function only works between Cicode tasks within the same process.

Syntax

LeaveCriticalSection(sName)

sName:

The name of the critical section. The name needs to be entered in quotation marks.

Return Value

This function does not return a value.

Related Functions

EnterCriticalSection

Example

/* Request access to critical section, execute code and relinquish 
ownership of critical section. */
FUNCTION
MyCriticalFunction()
EnterCriticalSection("MyCritical");
// critical code is placed here
LeaveCriticalSection("MyCritical");
END

See Also

Task Functions