* Handle all events for specified time on this CPU */
| 153 | * Handle all events for specified time on this CPU |
| 154 | */ |
| 155 | static int |
| 156 | handleevents(sbintime_t now, int fake) |
| 157 | { |
| 158 | sbintime_t t, *hct; |
| 159 | struct trapframe *frame; |
| 160 | struct pcpu_state *state; |
| 161 | int usermode; |
| 162 | int done, runs; |
| 163 | |
| 164 | CTR3(KTR_SPARE2, "handle at %d: now %d.%08x", |
| 165 | curcpu, (int)(now >> 32), (u_int)(now & 0xffffffff)); |
| 166 | done = 0; |
| 167 | if (fake) { |
| 168 | frame = NULL; |
| 169 | usermode = 0; |
| 170 | } else { |
| 171 | frame = curthread->td_intr_frame; |
| 172 | usermode = TRAPF_USERMODE(frame); |
| 173 | } |
| 174 | |
| 175 | state = DPCPU_PTR(timerstate); |
| 176 | |
| 177 | runs = 0; |
| 178 | while (now >= state->nexthard) { |
| 179 | state->nexthard += tick_sbt; |
| 180 | runs++; |
| 181 | } |
| 182 | if (runs) { |
| 183 | hct = DPCPU_PTR(hardclocktime); |
| 184 | *hct = state->nexthard - tick_sbt; |
| 185 | if (fake < 2) { |
| 186 | hardclock(runs, usermode); |
| 187 | done = 1; |
| 188 | } |
| 189 | } |
| 190 | runs = 0; |
| 191 | while (now >= state->nextstat) { |
| 192 | state->nextstat += statperiod; |
| 193 | runs++; |
| 194 | } |
| 195 | if (runs && fake < 2) { |
| 196 | statclock(runs, usermode); |
| 197 | done = 1; |
| 198 | } |
| 199 | if (profiling) { |
| 200 | runs = 0; |
| 201 | while (now >= state->nextprof) { |
| 202 | state->nextprof += profperiod; |
| 203 | runs++; |
| 204 | } |
| 205 | if (runs && !fake) { |
| 206 | profclock(runs, usermode, TRAPF_PC(frame)); |
| 207 | done = 1; |
| 208 | } |
| 209 | } else |
| 210 | state->nextprof = state->nextstat; |
| 211 | if (now >= state->nextcallopt || now >= state->nextcall) { |
| 212 | state->nextcall = state->nextcallopt = SBT_MAX; |
no test coverage detected