lockuninit man page on DragonFly

Man page or keyword search:  
man Server   44335 pages
apropos Keyword Search (all sections)
Output format
DragonFly logo
[printable version]

LOCK(9)			 BSD Kernel Developer's Manual		       LOCK(9)

NAME
     lockinit, lockcount, lockmgr, lockstatus, lockmgr_printinfo — lockmgr
     family of functions

SYNOPSIS
     #include <sys/types.h>
     #include <sys/lock.h>

     void
     lockinit(struct lock *lkp, char *wmesg, int timo, int flags);

     void
     lockuninit(struct lock *lkp);

     int
     lockcount(struct lock *lkp);

     int
     lockcountnb(struct lock *lkp);

     int
     lockmgr(struct lock *lkp, u_int flags);

     int
     lockstatus(struct lock *lkp, struct thread *td);

     void
     lockmgr_printinfo(struct lock *lkp);

DESCRIPTION
     The lockinit() function is used to initialize a lock.  It must be called
     before any operation can be performed on a lock.  Its arguments are:

     lkp    A pointer to the lock to initialize.

     wmesg  The lock message.  This is used for both debugging output and
	    tsleep(9).

     timo   The timeout value passed to tsleep(9).

     flags  The flags the lock is to be initialized with.

	    LK_NOWAIT	   Do not sleep while acquiring the lock.

	    LK_SLEEPFAIL   Fail after a sleep.

	    LK_CANRECURSE  Allow recursive exclusive locks.

	    LK_TIMELOCK	   Use timo during a sleep; otherwise, 0 is used.

     The lockuninit() function destroys a lock that was previously initialized
     using lockinit().

     The lockcount() function returns a count of the number of exclusive locks
     and shared locks held against the lock lkp.

     The lockcountnb() function is a non-blocking counter-part of lockcount().
     which, can be safely used in assertion statements e.g. a KASSERT(9).

     The lockmgr() function handles general locking functionality within the
     kernel, including support for shared and exclusive locks, and recursion.
     lockmgr() is also able to upgrade and downgrade locks.

     Its arguments are:

     lkp    A pointer to the lock to manipulate.

     flags  Flags indicating what action is to be taken.

	    LK_SHARED	    Acquire a shared lock.  If an exclusive lock is
			    currently held, it will be downgraded.

	    LK_EXCLUSIVE    Acquire an exclusive lock.	If an exclusive lock
			    is already held, and LK_CANRECURSE is not set, the
			    system will panic(9).

	    LK_DOWNGRADE    Downgrade exclusive lock to a shared lock.	Down‐
			    grading a shared lock is not permitted.  If an
			    exclusive lock has been recursed, all references
			    will be downgraded.

	    LK_EXCLUPGRADE  Upgrade a shared lock to an exclusive lock.	 Fails
			    with EBUSY if there is someone ahead of you in
			    line waiting for an upgrade.  If this call fails,
			    the shared lock is lost.  Attempts to upgrade an
			    exclusive lock will cause a panic(9).

	    LK_UPGRADE	    Upgrade a shared lock to an exclusive lock.	 If
			    this call fails, the shared lock is lost.
			    Attempts to upgrade an exclusive lock will cause a
			    panic(9).

	    LK_RELEASE	    Release the lock.  Releasing a lock that is not
			    held can cause a panic(9).

	    LK_SLEEPFAIL    Fail if operation has slept.

	    LK_NOWAIT	    Do not allow the call to sleep.  This can be used
			    to test the lock.

	    LK_CANRECURSE   Allow recursion on an exclusive lock.  For every
			    lock there must be a release.

     The lockstatus() function returns the status of the lock in relation to
     the thread passed to it.  Note that if td is NULL and an exclusive lock
     is held, LK_EXCLUSIVE will be returned.

     The lockmgr_printinfo() function prints debugging information about the
     lock.  It is used primarily by VOP_PRINT(9) functions.

RETURN VALUES
     The lockcount() function returns an integer greater than or equal to
     zero.

     The lockmgr() function returns 0 on success and non-zero on failure.

     The lockstatus() function returns:

     LK_EXCLUSIVE  An exclusive lock is held by the thread td.

     LK_EXCLOTHER  An exclusive lock is held by someone other than the thread
		   td.

     LK_SHARED	   A shared lock is held.

     0		   The lock is not held by anyone.

FILES
     The lock manager itself is implemented within the file
     /sys/kern/kern_lock.c.  Data structures and function prototypes for the
     lock manager are in /sys/sys/lock.h.

ERRORS
     lockmgr() fails if:

     [EBUSY]		LK_NOWAIT was set, and a sleep would have been
			required.

     [ENOLCK]		LK_SLEEPFAIL was set and lockmgr() did sleep.

     [EINTR]		PCATCH was set in the lock priority, and a signal was
			delivered during a sleep.  Note the ERESTART error
			below.

     [ERESTART]		PCATCH was set in the lock priority, a signal was
			delivered during a sleep, and the system call is to be
			restarted.

     [EWOULDBLOCK]	a non-zero timeout was given, and the timeout expired.

LOCKS
     Upgrade attempts that fail result in the loss of the lock that is cur‐
     rently held.  Also, it is invalid to upgrade an exclusive lock, and a
     panic(9) will be the result of trying.

SEE ALSO
     panic(9), tsleep(9), VOP_PRINT(9)

HISTORY
     The lock manager appeared in DragonFly 1.0.

     The lock manager API first appeared in 4.4BSD-Lite2.

AUTHORS
     This man page was written by Chad David ⟨davidc@acns.ab.ca⟩.

BSD				 July 26, 2010				   BSD
[top]

List of man pages available for DragonFly

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net