Example #1
0
/* sleeps # of seconds */
void esleep(double seconds_to_sleep)
{
    struct timeval tval;
    static double clk_tck_val = 0;
    double total = seconds_to_sleep;	/* total sleep asked for */
    double started = etime();	/* time when called */
    double left = total;
    if (seconds_to_sleep <= 0.0)
	return;
    if (clk_tck_val <= 0) {
	clk_tck_val = clk_tck();
    }
    do {
	if (left < clk_tck_val && esleep_use_yield) {
	    sched_yield();
	} else {
	    tval.tv_sec = (long) left;	/* double->long truncates, ANSI */
	    tval.tv_usec = (long) ((left - (double) tval.tv_sec) * 1000000.0);
	    if (tval.tv_sec == 0 && tval.tv_usec == 0) {
		tval.tv_usec = 1;
	    }
	    if (select(0, NULL, NULL, NULL, &tval) < 0) {
		if (errno != EINTR) {
		    break;
		}
	    }
	}
	left = total - etime() + started;
    }
    while (left > 0 && (left > clk_tck_val && esleep_use_yield));
    return;
}
Example #2
0
void
Client_Peer::crash(void)
{
  Crasher * crasher = new Crasher;

  ACE_Time_Value clk_tck (0, Clock_Ticks::get_usecs_per_tick ());
  ACE_Reactor * reactor = this->orb_->orb_core()->reactor();
  reactor->schedule_timer(crasher, 0, clk_tck);
}
Example #3
0
int
Sleeper::handle_timeout (ACE_Time_Value const & ,
                         void const *)
{
  // ACE_DEBUG((LM_DEBUG, "(%P|%t) - Sleeper::handle_timeout()\n"));
  ACE_Time_Value clk_tck (0, Clock_Ticks::get_usecs_per_tick ());
  this->orb_->perform_work(clk_tck);

  return 0;
}
Example #4
0
static int
freq_pstat_getprocessor (int help)
{
#if HAVE_PSTAT_GETPROCESSOR && HAVE_PSP_ITICKSPERCLKTICK
  struct pst_processor  p;

  HELP ("pstat_getprocessor() psp_iticksperclktick");

  if (pstat_getprocessor (&p, sizeof(p), 1, 0) != -1)
    {
      long  c = clk_tck();
      speed_cycletime = 1.0 / (c * p.psp_iticksperclktick);
      if (speed_option_verbose)
        printf ("Using pstat_getprocessor() psp_iticksperclktick %lu and clk_tck %ld for cycle time %.3g\n",
                (unsigned long) p.psp_iticksperclktick, c,
                speed_cycletime);
      return 1;
    }
#endif
  return 0;
}