* The main loop for the dedicated kernel thread that periodically calls * acctwatch(). */
| 615 | * acctwatch(). |
| 616 | */ |
| 617 | static void |
| 618 | acct_thread(void *dummy) |
| 619 | { |
| 620 | u_char pri; |
| 621 | |
| 622 | /* This is a low-priority kernel thread. */ |
| 623 | pri = PRI_MAX_KERN; |
| 624 | thread_lock(curthread); |
| 625 | sched_prio(curthread, pri); |
| 626 | thread_unlock(curthread); |
| 627 | |
| 628 | /* If another accounting kthread is already running, just die. */ |
| 629 | sx_xlock(&acct_sx); |
| 630 | if (acct_state & ACCT_RUNNING) { |
| 631 | sx_xunlock(&acct_sx); |
| 632 | kproc_exit(0); |
| 633 | } |
| 634 | acct_state |= ACCT_RUNNING; |
| 635 | |
| 636 | /* Loop until we are asked to exit. */ |
| 637 | while (!(acct_state & ACCT_EXITREQ)) { |
| 638 | /* Perform our periodic checks. */ |
| 639 | acctwatch(); |
| 640 | |
| 641 | /* |
| 642 | * We check this flag again before sleeping since the |
| 643 | * acctwatch() might have shut down accounting and asked us |
| 644 | * to exit. |
| 645 | */ |
| 646 | if (!(acct_state & ACCT_EXITREQ)) { |
| 647 | sx_sleep(&acct_state, &acct_sx, 0, "-", |
| 648 | acctchkfreq * hz); |
| 649 | } |
| 650 | } |
| 651 | |
| 652 | /* |
| 653 | * Acknowledge the exit request and shutdown. We clear both the |
| 654 | * exit request and running flags. |
| 655 | */ |
| 656 | acct_state = 0; |
| 657 | sx_xunlock(&acct_sx); |
| 658 | kproc_exit(0); |
| 659 | } |
nothing calls this directly
no test coverage detected