예제 #1
0
  INativeCondVar::Result	LinuxCondVar::wait(Time const & timeout, bool lockMutex)
  {
    pthread_mutex_t*		mutex = reinterpret_cast<pthread_mutex_t *>(_mutex.getNative());
    int				ret;
    timespec			ts;

    if (lockMutex)
      ownLock();
    if (timeout != Time::Zero)
      {
  	get_clocktime(&ts);
  	ts.tv_nsec += timeout.getNano();
  	ts.tv_sec += timeout.getSeconds();
  	ret = pthread_cond_timedwait(&_condvar, mutex, &ts);
  	if (ret == ETIMEDOUT)
  	  return (INativeCondVar::Timeout);
      }
    else
      ret = pthread_cond_wait(&_condvar, mutex);
    if (lockMutex)
      ownUnlock();
    if (ret == 0)
      return (INativeCondVar::NoError);
    return (INativeCondVar::Failed);
  }
예제 #2
0
/**
 * Hook function to be called when the scheduler performs some interesting
 * action.
 */
void buffered_trace_task_hook( TRACE_TASK_HOOK_SIGNATURE )
{
#if BUFFERED_TRACE_USE_CLOCKTIME
    CLOCKTIME_T clocktime = get_clocktime( );
#endif /* BUFFERED_TRACE_USE_CLOCKTIME */

    /* Create a new trace activity */
    trace_log_action_t new_action;
    new_action.task_tcb = task_storeinfo( p, (char *) TaskName, TCBNumber );
    new_action.action   = action;

    /* Add this action to the trace log */
    add_action( ticks,
#if BUFFERED_TRACE_USE_CLOCKTIME
            clocktime,
#endif /* BUFFERED_TRACE_USE_CLOCKTIME */
            new_action,
            WICED_FALSE );
} /* buffered_trace_task_hook */
예제 #3
0
파일: jitter.c 프로젝트: traveller42/ntpsec
void jitter(const iomode mode)
{
	l_fp tr;
	int i;
	double gtod[NBUF];

	/*
	 * Force pages into memory
	 */
	for (i = 0; i < NBUF; i ++)
	    gtod[i] = 0;

	/*
	 * Construct gtod array
	 */
	for (i = 0; i < NBUF; i ++) {
		get_clocktime(&tr);
		LFPTOD(&tr, gtod[i]);
	}

	/*
	 * Write out gtod array for later processing with Matlab
	 */
	average = 0;
	for (i = 0; i < NBUF - 2; i++) {
		gtod[i] = gtod[i + 1] - gtod[i];
		if (mode == raw)
			printf("%13.9f\n", gtod[i]);
		average += gtod[i];
	}

	if (mode == raw)
	    exit(0);
	
	/*
	 * Sort the gtod array and display deciles
	 */
	qsort(gtod, NBUF, sizeof(gtod[0]), doublecmp);
	average = average / (NBUF - 2);
	if (mode == json) {
		fprintf(stdout, "{\"Average\":%13.9f,", average);
		fprintf(stdout, "\"First rank\":[");
		for (i = 0; i < NSAMPLES; i++) {
		    fprintf(stdout, "%13.9f", gtod[i]);
		    if (i < NSAMPLES - 1)
			fputc(',', stdout);
		    fputs("],", stdout);
		}
		fprintf(stdout, "\"Last rank\":");
		for (i = NBUF - 12; i < NBUF - 2; i++) {
		    fprintf(stdout, "%13.9f\n", gtod[i]);
		    if (i < NSAMPLES - 1)
			fputc(',', stdout);
		    fputs("]}\n", stdout);
		}
	}
	else if (mode != raw)
	{
		fprintf(stdout, "Average %13.9f\n", average);
		fprintf(stdout, "First rank\n");
		for (i = 0; i < NSAMPLES; i++)
		    fprintf(stdout, "%2d %13.9f\n", i, gtod[i]);
		fprintf(stdout, "Last rank\n");
		for (i = NBUF - 12; i < NBUF - 2; i++)
		    fprintf(stdout, "%2d %13.9f\n", i, gtod[i]);
	}

	exit(0);
}