884 * At the moment avenrun[] can only hold 31
885 * bits of load average as it is a signed
886 * int in the API. We need to ensure that
887 * hp_avenrun[i] >> (16 - FSHIFT) will not be
888 * too large. If it is, we put the largest value
889 * that we can use into avenrun[i]. This is
890 * kludgey, but about all we can do until we
891 * avenrun[] is declared as an array of uint64[]
892 */
893 if (hp_avenrun[i] < ((uint64_t)1<<(31+16-FSHIFT)))
894 avenrun[i] = (int32_t)(hp_avenrun[i] >>
895 (16 - FSHIFT));
896 else
897 avenrun[i] = 0x7fffffff;
898
899 cpupart = cp_list_head;
900 do {
901 calcloadavg(genloadavg(&cpupart->cp_loadavg),
902 cpupart->cp_hp_avenrun);
903 } while ((cpupart = cpupart->cp_next) != cp_list_head);
904
905 /*
906 * Wake up the swapper thread if necessary.
907 */
908 if (runin ||
909 (runout && (avefree < desfree || wake_sched_sec))) {
910 t = &t0;
911 thread_lock(t);
912 if (t->t_state == TS_STOPPED) {
913 runin = runout = 0;
914 wake_sched_sec = 0;
915 t->t_whystop = 0;
916 t->t_whatstop = 0;
917 t->t_schedflag &= ~TS_ALLSTART;
918 THREAD_TRANSITION(t);
919 setfrontdq(t);
920 }
921 thread_unlock(t);
922 }
923 }
924
925 /*
926 * Wake up the swapper if any high priority swapped-out threads
927 * became runable during the last tick.
928 */
929 if (wake_sched) {
930 t = &t0;
931 thread_lock(t);
932 if (t->t_state == TS_STOPPED) {
933 runin = runout = 0;
934 wake_sched = 0;
935 t->t_whystop = 0;
936 t->t_whatstop = 0;
937 t->t_schedflag &= ~TS_ALLSTART;
938 THREAD_TRANSITION(t);
939 setfrontdq(t);
940 }
941 thread_unlock(t);
942 }
943 }
944
945 void
946 clock_init(void)
947 {
948 cyc_handler_t clk_hdlr, lbolt_hdlr;
949 cyc_time_t clk_when, lbolt_when;
950 int i, sz;
951 intptr_t buf;
952
953 /*
954 * Setup handler and timer for the clock cyclic.
955 */
956 clk_hdlr.cyh_func = (cyc_func_t)clock;
957 clk_hdlr.cyh_level = CY_LOCK_LEVEL;
958 clk_hdlr.cyh_arg = NULL;
959
960 clk_when.cyt_when = 0;
961 clk_when.cyt_interval = nsec_per_tick;
|
884 * At the moment avenrun[] can only hold 31
885 * bits of load average as it is a signed
886 * int in the API. We need to ensure that
887 * hp_avenrun[i] >> (16 - FSHIFT) will not be
888 * too large. If it is, we put the largest value
889 * that we can use into avenrun[i]. This is
890 * kludgey, but about all we can do until we
891 * avenrun[] is declared as an array of uint64[]
892 */
893 if (hp_avenrun[i] < ((uint64_t)1<<(31+16-FSHIFT)))
894 avenrun[i] = (int32_t)(hp_avenrun[i] >>
895 (16 - FSHIFT));
896 else
897 avenrun[i] = 0x7fffffff;
898
899 cpupart = cp_list_head;
900 do {
901 calcloadavg(genloadavg(&cpupart->cp_loadavg),
902 cpupart->cp_hp_avenrun);
903 } while ((cpupart = cpupart->cp_next) != cp_list_head);
904 }
905 }
906
907 void
908 clock_init(void)
909 {
910 cyc_handler_t clk_hdlr, lbolt_hdlr;
911 cyc_time_t clk_when, lbolt_when;
912 int i, sz;
913 intptr_t buf;
914
915 /*
916 * Setup handler and timer for the clock cyclic.
917 */
918 clk_hdlr.cyh_func = (cyc_func_t)clock;
919 clk_hdlr.cyh_level = CY_LOCK_LEVEL;
920 clk_hdlr.cyh_arg = NULL;
921
922 clk_when.cyt_when = 0;
923 clk_when.cyt_interval = nsec_per_tick;
|