2010/3/3 Slava Pestov <[email protected]>

> A similar issue occurs on Windows under VirtualBox. Doug and I tried a
> workaround similar to yours but it doesn't work too well if the Factor
> side of things doesn't poll the nano-counter often enough.
>

Another solution would be to retry until the counter is indeed monotonic,
with some kind of hard limit, as in:

  void factor_vm::primitive_nano_count()
 {
-       u64 nanos = nano_count();
-       if(nanos < last_nano_count) critical_error("Monotonic counter
decreased",0);
-       last_nano_count = nanos;
-       ctx->push(from_unsigned_8(nanos));
+       // Jump through hoops to get a monotonic value even when
+       // running from inside VirtualBox.
+       // http://www.virtualbox.org/ticket/6318
+       for (int i = 0; i < 8; i++) {
+               u64 nanos = nano_count();
+               if(nanos < last_nano_count) continue;
+               last_nano_count = nanos;
+               ctx->push(from_unsigned_8(nanos));
+               return;
+       }
+       critical_error("Monotonic counter decreased",0);
 }

as it looks like the counter sometimes goes backwards but doesn't jump far
ahead.

That should work best (at the price of more system calls in buggy situation)
but is not 100% foolproof, even if the probability of failure when the
system reports 8 misplaced values in a row is kinda low.

Perhaps the best thing to do is to report this to the VirtualBox guys
> and wait for them to fix it.
>

I reported it just after sending my mail:
http://www.virtualbox.org/ticket/6318

In the meantime, we can accomodate a local patch to Factor.

  Sam
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to