void OS::event_loop() { while (power_) { int rc; // add a global symbol here so we can quickly discard // event loop from stack sampling asm volatile( ".global _irq_cb_return_location;\n" "_irq_cb_return_location:" ); // XXX: temporarily ALWAYS sleep for 0.5 ms. We should ideally ask Timers // for the next immediate timer to fire (the first from the "scheduled" list // of timers?) rc = solo5_poll(solo5_clock_monotonic() + 500000ULL); // now + 0.5 ms Timers::timers_handler(); if (rc) { for(auto& nic : hw::Devices::devices<hw::Nic>()) { nic->poll(); break; } } } MYINFO("Stopping service"); Service::stop(); MYINFO("Powering off"); solo5_poweroff(); }
void OS::block() { // Increment level blocking_level += 1; // Increment highest if applicable if (blocking_level > highest_blocking_level) highest_blocking_level = blocking_level; int rc; rc = solo5_poll(solo5_clock_monotonic() + 50000ULL); // now + 0.05 ms if (rc == 0) { Timers::timers_handler(); } else { for(auto& nic : hw::Devices::devices<hw::Nic>()) { nic->poll(); break; } } // Decrement level blocking_level -= 1; }
CAMLprim value caml_poll(value v_until) { CAMLparam1(v_until); CAMLlocal1(work_to_do); uint64_t until = (Int64_val(v_until)); int rc = solo5_poll(until); work_to_do = Val_bool(rc); CAMLreturn(work_to_do); }