equal
deleted
inserted
replaced
77 */ |
77 */ |
78 #include <sys/timex.h> |
78 #include <sys/timex.h> |
79 #include <sys/inttypes.h> |
79 #include <sys/inttypes.h> |
80 |
80 |
81 /* |
81 /* |
82 * clock is called straight from |
82 * clock() is called straight from the clock cyclic; see clock_init(). |
83 * the real time clock interrupt. |
|
84 * |
83 * |
85 * Functions: |
84 * Functions: |
86 * reprime clock |
85 * reprime clock |
87 * schedule callouts |
86 * schedule callouts |
88 * maintain date |
87 * maintain date |
312 static void calcloadavg(int, uint64_t *); |
311 static void calcloadavg(int, uint64_t *); |
313 static int genloadavg(struct loadavg_s *); |
312 static int genloadavg(struct loadavg_s *); |
314 static void loadavg_update(); |
313 static void loadavg_update(); |
315 |
314 |
316 void (*cmm_clock_callout)() = NULL; |
315 void (*cmm_clock_callout)() = NULL; |
317 |
316 void (*cpucaps_clock_callout)() = NULL; |
318 #ifdef KSLICE |
|
319 int kslice = KSLICE; |
|
320 #endif |
|
321 |
317 |
322 static void |
318 static void |
323 clock(void) |
319 clock(void) |
324 { |
320 { |
325 kthread_t *t; |
321 kthread_t *t; |
511 } |
507 } |
512 } while ((cp = cp->cpu_next) != cpu_list); |
508 } while ((cp = cp->cpu_next) != cpu_list); |
513 |
509 |
514 /* |
510 /* |
515 * Do tick processing for all the active threads running in |
511 * Do tick processing for all the active threads running in |
516 * the system. |
512 * the system. We're trying to be more fair by walking the |
517 */ |
513 * list of CPUs starting from a different CPUs each time. |
518 cp = cpu_list; |
514 */ |
|
515 cp = clock_cpu_list; |
519 nrunning = 0; |
516 nrunning = 0; |
520 do { |
517 do { |
521 klwp_id_t lwp; |
518 klwp_id_t lwp; |
522 int intr; |
519 int intr; |
523 int thread_away; |
520 int thread_away; |
647 if ((!thread_away) && (lbolt - t->t_lbolt != 0)) { |
644 if ((!thread_away) && (lbolt - t->t_lbolt != 0)) { |
648 t->t_lbolt = lbolt; |
645 t->t_lbolt = lbolt; |
649 clock_tick(t); |
646 clock_tick(t); |
650 } |
647 } |
651 |
648 |
652 #ifdef KSLICE |
|
653 /* |
|
654 * Ah what the heck, give this kid a taste of the real |
|
655 * world and yank the rug out from under it. |
|
656 * But, only if we are running UniProcessor. |
|
657 */ |
|
658 if ((kslice) && (ncpus == 1)) { |
|
659 aston(t); |
|
660 cp->cpu_runrun = 1; |
|
661 cp->cpu_kprunrun = 1; |
|
662 } |
|
663 #endif |
|
664 if (!exiting) |
649 if (!exiting) |
665 mutex_exit(plockp); |
650 mutex_exit(plockp); |
666 } while ((cp = cp->cpu_next) != cpu_list); |
651 } while ((cp = cp->cpu_next) != clock_cpu_list); |
|
652 |
|
653 clock_cpu_list = clock_cpu_list->cpu_next; |
667 |
654 |
668 /* |
655 /* |
669 * bump time in ticks |
656 * bump time in ticks |
670 * |
657 * |
671 * We rely on there being only one clock thread and hence |
658 * We rely on there being only one clock thread and hence |
679 * thread to support the membership protocol in a clustered |
666 * thread to support the membership protocol in a clustered |
680 * system. Copy the function pointer so that we can reset |
667 * system. Copy the function pointer so that we can reset |
681 * this to NULL if needed. |
668 * this to NULL if needed. |
682 */ |
669 */ |
683 if ((funcp = cmm_clock_callout) != NULL) |
670 if ((funcp = cmm_clock_callout) != NULL) |
|
671 (*funcp)(); |
|
672 |
|
673 if ((funcp = cpucaps_clock_callout) != NULL) |
684 (*funcp)(); |
674 (*funcp)(); |
685 |
675 |
686 /* |
676 /* |
687 * Wakeup the cageout thread waiters once per second. |
677 * Wakeup the cageout thread waiters once per second. |
688 */ |
678 */ |