|
IDL Reference Guide: Procedures and Functions |
|
The SEM_LOCK function attempts to gain the lock on an existing semaphore (created by a call to the SEM_CREATE function) for the current IDL process. Once the lock has been obtained by one IDL process, other IDL processes will not be able to gain the lock until the SEM_RELEASE process is called within the IDL process that owns the lock.
Result = SEM_LOCK(strName)
The result is 1 (one) if the lock on the specified semaphore was successfully obtained, or 0 (zero) if the lock could not be obtained.
A scalar string containing the name associated with the semaphore. This is the name used when creating the semaphore with SEM_CREATE.
None
This example illustrates the way semaphores operate using two independent IDL sessions on the same machine.
status = SEM_CREATE('semaphore1')
This creates a semaphore called "semaphore1".
status = SEM_LOCK('semaphore1')
If the lock is obtained, status is set equal to 1.
status = SEM_CREATE('semaphore1')
status = SEM_LOCK('semaphore1')
Since the lock is owned by session 1, status is set equal to 0 (the lock was not obtained).
SEM_RELEASE, 'semaphore1'
status = SEM_LOCK('semaphore1')
In this case, status is set equal to 1, indicating session 2 now has the lock
SEM_DELETE, 'semaphore1'
This removes the reference to the semaphore in session 2, but does not destroy the actual semaphore in the operating system.
SEM_DELETE, 'semaphore1'
This removes both the reference to the semaphore in session 1 and the actual semaphore in the operating system, because:
SEM_CREATE, SEM_DELETE, SEM_RELEASE
IDL Online Help (March 06, 2007)