FreeBSD/sys/kern/kern_acct.c
/*
 * The main loop for the dedicated kernel thread that periodically calls
 * acctwatch().
 */
The main loop for the dedicated kernel thread that periodically calls
acctwatch().
The main loop for the dedicated kernel thread that periodically calls acctwatch () .
static void
acct_thread(void *dummy)
{
	u_char pri;
	pri = PRI_MAX_KERN;
	thread_lock(curthread);
	sched_prio(curthread, pri);
	thread_unlock(curthread);
	sx_xlock(&acct_sx);
	if (acct_state & ACCT_RUNNING) {
		sx_xunlock(&acct_sx);
		kproc_exit(0);
	}
	acct_state |= ACCT_RUNNING;
	while (!(acct_state & ACCT_EXITREQ)) {
		acctwatch();
		if (!(acct_state & ACCT_EXITREQ)) {
			sx_sleep(&acct_state, &acct_sx, 0, "-",
			    acctchkfreq * hz);
		}
	}
	acct_state = 0;
	sx_xunlock(&acct_sx);
	kproc_exit(0);
}
static void acct_thread ( void * dummy ) { u_char pri ; pri = PRI_MAX_KERN ; thread_lock ( curthread ) ; sched_prio ( curthread , pri ) ; thread_unlock ( curthread ) ; sx_xlock ( & acct_sx ) ; if ( acct_state & ACCT_RUNNING ) { sx_xunlock ( & acct_sx ) ; kproc_exit ( 0 ) ; } acct_state |= ACCT_RUNNING ; while ( ! ( acct_state & ACCT_EXITREQ ) ) { acctwatch ( ) ; if ( ! ( acct_state & ACCT_EXITREQ ) ) { sx_sleep ( & acct_state , & acct_sx , 0 , " " , acctchkfreq * hz ) ; } } acct_state = 0 ; sx_xunlock ( & acct_sx ) ; kproc_exit ( 0 ) ; }
The main loop for the dedicated kernel thread that periodically calls
 acctwatch().
The main loop for the dedicated kernel thread that periodically calls acctwatch () .
/* This is a low-priority kernel thread. */ /* If another accounting kthread is already running, just die. */ /* Loop until we are asked to exit. */ /* Perform our periodic checks. */ /*
		 * We check this flag again before sleeping since the
		 * acctwatch() might have shut down accounting and asked us
		 * to exit.
		 */ /*
	 * Acknowledge the exit request and shutdown.  We clear both the
	 * exit request and running flags.
	 */