Print this page
usr/src/lib/libfakekernel/common/mutex.c
*** 8,18 ****
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*/
/*
! * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
* Copyright 2017 RackTop Systems.
*/
/*
* mutex(9f)
--- 8,18 ----
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*/
/*
! * Copyright 2018 Nexenta Systems, Inc. All rights reserved.
* Copyright 2017 RackTop Systems.
*/
/*
* mutex(9f)
*** 29,40 ****
int _lwp_mutex_unlock(lwp_mutex_t *);
int _lwp_mutex_trylock(lwp_mutex_t *);
extern clock_t ddi_get_lbolt(void);
static const lwp_mutex_t default_mutex =
! {{0, 0, 0, {USYNC_THREAD}, _MUTEX_MAGIC},
{{{0, 0, 0, 0, 0, 0, 0, 0}}}, 0};
/* ARGSUSED */
void
kmutex_init(kmutex_t *mp, char *name, kmutex_type_t typ, void *arg)
--- 29,41 ----
int _lwp_mutex_unlock(lwp_mutex_t *);
int _lwp_mutex_trylock(lwp_mutex_t *);
extern clock_t ddi_get_lbolt(void);
+ /* See: head/synch.h ERRORCHECKMUTEX */
static const lwp_mutex_t default_mutex =
! {{0, 0, 0, {USYNC_THREAD|LOCK_ERRORCHECK}, _MUTEX_MAGIC},
{{{0, 0, 0, 0, 0, 0, 0, 0}}}, 0};
/* ARGSUSED */
void
kmutex_init(kmutex_t *mp, char *name, kmutex_type_t typ, void *arg)
*** 51,62 ****
}
void
kmutex_enter(kmutex_t *mp)
{
VERIFY(0 == _lwp_mutex_lock(&mp->m_lock));
! mp->m_owner = _curthread();
}
int
mutex_tryenter(kmutex_t *mp)
{
--- 52,66 ----
}
void
kmutex_enter(kmutex_t *mp)
{
+ kthread_t *t = _curthread();
+
+ VERIFY(mp->m_owner != t);
VERIFY(0 == _lwp_mutex_lock(&mp->m_lock));
! mp->m_owner = t;
}
int
mutex_tryenter(kmutex_t *mp)
{