b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * CDDL HEADER START
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * The contents of this file are subject to the terms of the
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * Common Development and Distribution License (the "License").
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * You may not use this file except in compliance with the License.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * See the License for the specific language governing permissions
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * and limitations under the License.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * When distributing Covered Code, include this CDDL HEADER in each
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * If applicable, add the following below this CDDL HEADER, with the
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * fields enclosed by brackets "[]" replaced with your own identifying
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * information: Portions Copyright [yyyy] [name of copyright owner]
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * CDDL HEADER END
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * Public interface to mutual exclusion locks. See mutex(9F) for details.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * The basic mutex type is MUTEX_ADAPTIVE, which is expected to be used
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * in almost all of the kernel. MUTEX_SPIN provides interrupt blocking
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * and must be used in interrupt handlers above LOCK_LEVEL. The iblock
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * cookie argument to mutex_init() encodes the interrupt level to block.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * The iblock cookie must be NULL for adaptive locks.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * MUTEX_DEFAULT is the type usually specified (except in drivers) to
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * mutex_init(). It is identical to MUTEX_ADAPTIVE.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * MUTEX_DRIVER is always used by drivers. mutex_init() converts this to
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * either MUTEX_ADAPTIVE or MUTEX_SPIN depending on the iblock cookie.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * Mutex statistics can be gathered on the fly, without rebooting or
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * recompiling the kernel, via the lockstat driver (lockstat(7D)).
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rosstypedef enum {
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross MUTEX_ADAPTIVE = 0, /* spin if owner is running, otherwise block */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross/* See the real sys/mutex.h */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross#endif /* _KERNEL */
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross#define MUTEX_NOT_HELD(x) (!mutex_owned(x) || panicstr)
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * We're simulating the kernel mutex API here, and the
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross * user-level has a different signature, so rename.
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Rossextern void kmutex_init(kmutex_t *, char *, kmutex_type_t, void *);
b819cea2f73f98c5662230cc9affc8cc84f77fcfGordon Ross#endif /* _SYS_MUTEX_H */