[Orca-dev] Orcallator.se timestamp patch

Dmitry Berezin dberezin at surfside.rutgers.edu
Tue Jun 15 08:28:16 PDT 2004


Blair,

Here is the patch to make orcallator.se sleep to exact multiple of interval
that we have discussed. I suspect that you might not like one-liners like
this one "orca_sleep(((now + 5) < sleep_till ? now + 5 : sleep_till));",
which I like to use. If this is the problem, I suggest a couple of
alternatives -
  1. Create a variable and use if-then-else to assign it a value of either
"now + 5" or "sleep_till" and then call orca_sleep(<variable>).
  2. Use if-then-else to call orca_sleep(now + 5) or orca_sleep(sleep_till).
  3. Define a macro that chooses the smaller of two values and use it in
calls to orca_sleep.

I'd stick with what I have, but if I had to choose out of the three above,
number 2 is probably the cleaner one.

  -Dmitry.


> Hi Dmitry,
> 
> Yes, we should definitely change this.
> 
> Instead of just fixing now to be an integer multiple of interval, I'd
> rather see
> this fixed so that the calls to sleep() sleep till an integer multiple of
> interval.
> 
> We should also probably not just do something like
> 
> sleep(sleep_till - now)
> 
> because now with the fractional seconds may be closer to (int)(now+1) than
> (int)now and after the sleep() we're much of the way into the proper
> second, so
> by the time that now = time(0) is reached in  So we could do something
> like this
> 
> #include <time.se>
> #include <unistd.se>
> 
>    timeval_t now[1];
>    ulong sleep_time;
> 
>    gettimeofday(now, 0);
>    while (sleep_till > now[0].tv_sec) {
>      sleep_time = sleep_till - now[0].tv_sec;
>      sleep_time = 1000000*sleep_time - now[0].tv_usec;
>      usleep(sleep_time);
>      gettimeofday(now, 0);
>    }
> 
> The proper patch should fix both the measure_web and the
> sleep_till_and_count_new_processes code paths.
> 
> There's a lot of different places in orcallator.se where sleep() is
> called.  I
> think we should have a single function that sleeps till the specified time
> that
> all these different locations call.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: orcallator-patch-timestamp2
Type: application/octet-stream
Size: 2165 bytes
Desc: not available
Url : /pipermail/orca-dev/attachments/20040615/91338ec9/attachment.obj 


More information about the Orca-dev mailing list