tty_lock()

Lock the TTYCTRL structure to prevent modification by other threads

Synopsis:

#include <sys/io-char.h>

int tty_lock( TTYCTRL *ctrl );

Arguments:

ctrl
A pointer to TTYCTRL structure to be locked.

Description:

The tty_lock() function locks the TTYCTRL structure to prevent modification by other threads. If the structure object is already locked, then the calling thread blocks until it has acquired the structure lock. When the function returns, the structure object is locked and owned by the calling thread. If the structure object is already locked, then attempting to lock the structure again using the thread that already owns it will result in a deadlock. Unlocking a structure locked by a different thread causes undefined behavior. By default, if a thread with a higher priority than the structure lock owner attempts to lock it, then the effective priority of the current owner is increased to that of the higher-priority blocked thread waiting for the structure lock. The owner returns to its real priority when it unlocks the structure. If a signal is delivered to a thread that's waiting for a structure lock, the thread resumes waiting for the lock after returning from the signal handler.

Returns:

EOK
Success.
EAGAIN
The structure couldn't be locked because the maximum number of recursive locks has been exceeded.
EDEADLK
A deadlock condition was detected.
EFAULT
A fault occurred when the kernel tried to access the buffers provided.
EINTR
The thread waiting for structure lock was unblocked by a call to phread_mutex_wakeup_np() executed on the underlying locking mechanism (QNX OS extension).
EINVAL
The structure locking mechanism is corrupted.
ENOTRECOVERABLE
The locking mechanism is corrupted and not recoverable.
EOWNERDEAD
The process containing the previous owning thread terminated while holding the structure lock. The calling thread acquires the lock; it's up to the new owner to make the state consistent (see pthread_mutex_consistent()).

Classification:

QNX OS

Safety:
Cancellation point No
Signal handler No
Thread Yes
Page updated: