File tree Expand file tree Collapse file tree
test/fs/integration/virtio_block Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -142,21 +142,38 @@ void OS::start(const char* cmdline)
142142
143143void OS::event_loop ()
144144{
145- while (power_) {
146- int rc;
147-
145+ while (power_)
146+ {
148147 // add a global symbol here so we can quickly discard
149148 // event loop from stack sampling
150149 asm volatile (
151150 " .global _irq_cb_return_location;\n "
152151 " _irq_cb_return_location:" );
153152
154- // XXX: temporarily ALWAYS sleep for 0.5 ms. We should ideally ask Timers
155- // for the next immediate timer to fire (the first from the "scheduled" list
156- // of timers?)
157- rc = solo5_yield (solo5_clock_monotonic () + 500000ULL ); // now + 0.5 ms
153+ int res = 0 ;
154+ auto nxt = Timers::next ();
155+ if (nxt == std::chrono::nanoseconds (0 ))
156+ {
157+ // no next timer, just wait a while
158+ res = solo5_yield (solo5_clock_monotonic () + 500000000ULL ); // 500 ms
159+ // printf("Waiting, next is indeterminate...\n");
160+ }
161+ else if (nxt == std::chrono::nanoseconds (1 ))
162+ {
163+ // there is an imminent or activated timer, don't wait
164+ // printf("Not waiting, imminent timer...\n");
165+ }
166+ else
167+ {
168+ res = solo5_yield (solo5_clock_monotonic () + nxt.count ());
169+ // printf("Waiting %llu nanos\n", nxt.count());
170+ }
171+
172+ // handle any activated timers
158173 Timers::timers_handler ();
159- if (rc) {
174+ if (res != 0 )
175+ {
176+ // handle any network traffic
160177 for (auto & nic : hw::Devices::devices<hw::Nic>()) {
161178 nic->poll ();
162179 break ;
Original file line number Diff line number Diff line change @@ -10,11 +10,10 @@ project (test_virtioblk)
1010
1111set (SERVICE_NAME "VirtioBlk test" )
1212set (BINARY "virtioblk" )
13- set (MAX_MEM 128)
1413set (SOURCES
1514 service.cpp
1615 )
1716
18- set (DRIVERS virtioblk)
17+ set (DRIVERS virtioblk solo5blk )
1918
2019include ($ENV{INCLUDEOS_PREFIX} /includeos/post.service.cmake )
You can’t perform that action at this time.
0 commit comments