umem_update_thread.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "umem_base.h"
#include "vmem_base.h"
#include <signal.h>
/*
* we use the _ version, since we don't want to be cancelled.
*/
/*ARGSUSED*/
static void *
umem_update_thread(void *arg)
{
int in_update = 0;
(void) mutex_lock(&umem_update_lock);
ASSERT(umem_st_update_thr == 0);
for (;;) {
if (in_update) {
in_update = 0;
/*
* we wait until now to set the next update time
* so that the updates are self-throttling
*/
}
switch (umem_reaping) {
case UMEM_REAP_DONE:
case UMEM_REAP_ADDING:
break;
case UMEM_REAP_ACTIVE:
umem_reap_next = gethrtime() +
break;
default:
umem_reaping == UMEM_REAP_ADDING ||
break;
}
/*
* Time to run an update
*/
(void) mutex_unlock(&umem_update_lock);
/*
* umem_cache_update can use umem_add_update to
* request further work. The update is not complete
* until all such work is finished.
*/
(void) mutex_lock(&umem_update_lock);
in_update = 1;
continue; /* start processing immediately */
}
/*
* if there is no work to do, we wait until it is time for
* next update, or someone wakes us.
*/
(void) _cond_timedwait(&umem_update_cv,
&umem_update_lock, &abs_time);
}
}
/* LINTED no return statement */
}
int
{
ASSERT(umem_update_thr == 0);
/*
* The update thread handles no signals
*/
(void) sigfillset(&sigmask);
return (1);
}
umem_update_thr = 0;
return (0);
}