TsctlDIOLockDesc

From embeddedTS Manuals

This function acquires or releases the DIO resource lock. The lock must be acquired before calling other DIO functions if there is any chance of another process trying to simultaneously access the DIO. The DIO lock also automatically set the mode of the pin corresponding to the DIO to DIO mode. If the lock is not acquired, the ModeSet of the Pin class must be called appropriately to do this (if needed).

The num parameter is the DIO number to lock.

The value of flags must be a bitwise OR of the following:

NONBLOCKING: If the DIO lock can be immediately acquired (without blocking) then it is and the call succeeds, otherwise the lock is not acquired and the call fails.

SHARED: If this flag is set, then a shared (read) lock will be attempted, otherwise an exclusive (write) lock will be attempted. An exclusive lock requires that no shared locks be held before it will succeed. A shared lock requires that no exclusive locks be help before it will succeed. Locking favors readers so as to prevent reader starvation.

NOUNLOCK: Normally, if the thread calling this function holds other locks and this function will block, the other locks held are temporarily dropped and are then re-acquired before the call returns, in order to prevent deadlock. Therefore, the call will not fail, but it could block indefinitely. However if this flag is present, then if other locks are held and the call would block, the function returns failure. Note: deadlock detection is currently disabled pending debugging efforts

This function returns a positive value on success, and a negative value on failure.

enum {
NONBLOCKING=1, SHARED=2, NOUNLOCK=4
};