TsctlTWILockDesc

From embeddedTS Manuals

This function acquires or releases the TWI resource lock. The lock must be acquired before calling other TWI functions.

The num parameter is 0.

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

NONBLOCKING: If the TWI 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
};