コード例 #1
0
STATUS
h2initGlob(int ticksPerSec)
{

#ifdef __XENO__
    /* Lock process in RAM */
    mlockall(MCL_CURRENT | MCL_FUTURE);
#endif
    /* init error msgs for sub-libraries without specific init functions */
    h2evnRecordH2ErrMsgs();
    h2semRecordH2ErrMsgs();
    smObjRecordH2ErrMsgs();

    /* OS level initialization */
    if (osInit(ticksPerSec) == ERROR) {
	return ERROR;
    }
    setvbuf(stdout, (char *)NULL, _IOLBF, 0);
    setvbuf(stderr, (char *)NULL, _IOLBF, 0);

    /* attach to h2 devices */
    if (h2devAttach() == ERROR) {
	printf("Error: could not find h2 devices\n"
		"Did you execute `h2 init' ?\n");
	return ERROR;
    }
    /* attach to shared memory */
    if (smMemAttach() == ERROR) {
	printf("Error: could not attach shared memory\n");
	return ERROR;
    }

    /* Start h2 timers if a clock is available */
    if (ticksPerSec != 0) {
	if (h2timerInit() == ERROR) {
	    return ERROR;
	}
    }
    h2timeInit();
    printf("%s execution environment version %s\n"
	"Copyright (c) 1999-2011 CNRS-LAAS\n",
	PACKAGE_NAME, PACKAGE_VERSION);

    return OK;
}
コード例 #2
0
int
pocoregress_init(void)
{
	H2TIMESPEC ts;
	H2TIME h2time;
	int i;
	unsigned long t1, oldtick = tickGet();

	h2timeInit();

	for (i = 0; i < 300; i++) {
		h2GetTimeSpec(&ts);
		h2timeFromTimespec(&h2time, &ts);
		printf("%02d ticks -> %lu %lu\n", i, h2time.ntick, tickGet());
		t1 = tickGet();
		while (tickGet() == t1)
			;
	}
	return 0;
}