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