do wakeup() only when someone is waiting for us.
This commit is contained in:
parent
104f2a80df
commit
44d0d57217
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sysmon_envsys.c,v 1.7 2003/08/11 14:24:41 yamt Exp $ */
|
||||
/* $NetBSD: sysmon_envsys.c,v 1.8 2003/08/11 15:07:14 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 Zembu Labs, Inc.
|
||||
|
@ -41,7 +41,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.7 2003/08/11 14:24:41 yamt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.8 2003/08/11 15:07:14 yamt Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/conf.h>
|
||||
|
@ -244,7 +244,7 @@ sysmon_envsys_register(struct sysmon_envsys *sme)
|
|||
{
|
||||
int error = 0;
|
||||
|
||||
KASSERT((sme->sme_flags & SME_FLAG_BUSY) == 0);
|
||||
KASSERT((sme->sme_flags & (SME_FLAG_BUSY | SME_FLAG_WANTED)) == 0);
|
||||
simple_lock(&sysmon_envsys_list_slock);
|
||||
|
||||
if (sme->sme_envsys_version != SYSMON_ENVSYS_VERSION) {
|
||||
|
@ -272,6 +272,7 @@ sysmon_envsys_unregister(struct sysmon_envsys *sme)
|
|||
|
||||
simple_lock(&sysmon_envsys_list_slock);
|
||||
while (sme->sme_flags & SME_FLAG_BUSY) {
|
||||
sme->sme_flags |= SME_FLAG_WANTED;
|
||||
ltsleep(sme, PWAIT, "smeunreg", 0, &sysmon_envsys_list_slock);
|
||||
}
|
||||
LIST_REMOVE(sme, sme_list);
|
||||
|
@ -296,6 +297,7 @@ again:
|
|||
if (idx >= sme->sme_fsensor &&
|
||||
idx < (sme->sme_fsensor + sme->sme_nsensors)) {
|
||||
if (sme->sme_flags & SME_FLAG_BUSY) {
|
||||
sme->sme_flags |= SME_FLAG_WANTED;
|
||||
ltsleep(sme, PWAIT, "smefind", 0,
|
||||
&sysmon_envsys_list_slock);
|
||||
goto again;
|
||||
|
@ -322,7 +324,8 @@ sysmon_envsys_release(struct sysmon_envsys *sme)
|
|||
KASSERT(sme->sme_flags & SME_FLAG_BUSY);
|
||||
|
||||
simple_lock(&sysmon_envsys_list_slock);
|
||||
sme->sme_flags &= ~SME_FLAG_BUSY;
|
||||
wakeup(sme);
|
||||
if (sme->sme_flags & SME_FLAG_WANTED)
|
||||
wakeup(sme);
|
||||
sme->sme_flags &= ~(SME_FLAG_BUSY | SME_FLAG_WANTED);
|
||||
simple_unlock(&sysmon_envsys_list_slock);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sysmonvar.h,v 1.9 2003/08/11 14:24:41 yamt Exp $ */
|
||||
/* $NetBSD: sysmonvar.h,v 1.10 2003/08/11 15:07:14 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 Zembu Labs, Inc.
|
||||
|
@ -69,10 +69,11 @@ struct sysmon_envsys {
|
|||
|
||||
u_int sme_fsensor; /* sensor index base, from sysmon */
|
||||
u_int sme_nsensors; /* sensor count, from driver */
|
||||
int sme_flags;
|
||||
int sme_flags; /* SME_FLAG_ flags defined below */
|
||||
};
|
||||
|
||||
#define SME_FLAG_BUSY 0x00000001 /* sme is busy */
|
||||
#define SME_FLAG_WANTED 0x00000002 /* someone waiting for this */
|
||||
|
||||
#define SME_SENSOR_IDX(sme, idx) ((idx) - (sme)->sme_fsensor)
|
||||
|
||||
|
|
Loading…
Reference in New Issue