@RequestMutexSemaphore
Syntax
@RequestMutexSemaphore(MUTEXSEMAPHOREHANDLE);
@RequestMutexSemaphore(MUTEXSEMAPHOREHANDLE;FNTIMEOUT);
Description
Requests and, on success, locks the mutex semaphore with the mutex semaphore handle (MSH) MUTEXSEMAPHOREHANDLE.
On success, @True is returned; otherwise @ERROR.
If FN FNTIMEOUT is specified, waiting for the mutex semaphore is aborted after FN FNTIMEOUT milliseconds.
In this case, @ERROR returned.
If FN FNTIMEOUT is not specified, or -1 for FN FNTIMEOUT) the function waits until the mutex semaphore is available.
A mutex semaphore can be owned/requested by only one task at a time.
(This is used to allow only one task at a time to execute certain parts of a script exclusively.)
For example, access to a GLOBAL counter variable thas is to be continuously incremented by multiple tasks.
Example: @RequestMutexSemaphore(MUTEXSEMAPHOREHANDLE);
TEXTSEMAPHORENAME:="TEST_SEMAPHORE_NAME";
MSH:=@CreateMutexSemaphore(TEXTSEMAPHORENAME);
@RequestMutexSemaphore(MSH);
@ReleaseMutexSemaphore(MSH);
MSH:=@CloseMutexSemaphore(MSH);
A mutex semaphore with the name "TEST_SEMAPHORE_NAME" is created, requested/locked, released/unlocked, and closed again.
Note : This text was machine-translated and may contain inaccuracies.
