コード例 #1
0
ファイル: odp_ipsec.c プロジェクト: mitra/odp-mppa
static int my_nanosleep(struct timespec *ts){
	uint64_t freq = 600000000ULL;

	uint64_t tdiff = (ts->tv_sec * freq) + ((ts->tv_nsec * freq) / 1000000000ULL);
	uint64_t now = __k1_read_dsu_timestamp();
	while(now + tdiff > __k1_read_dsu_timestamp())
		__k1_cpu_backoff(1000);
	return 0;
}
コード例 #2
0
ファイル: odp_sleep.c プロジェクト: kalray/odp-mppa
static int my_nanosleep(struct timespec *ts){
	uint64_t freq = __bsp_frequency;
	uint64_t tdiff = (ts->tv_sec * freq) + ((ts->tv_nsec * freq) / 1000000000ULL);

#ifdef MAGIC_SCALL
 	uint64_t divisor = __k1_read_dsu_timestamp_divisor();
	uint64_t dsu_ts = __k1_read_dsu_timestamp();
	uint64_t cc = dsu_ts * divisor;
	uint64_t target = cc + tdiff;;
	return __k1_syscall2(MAGIC_SCALL_SLEEP, target & 0xffffffffULL, target >> 32);
#else
	while(tdiff > INT32_MAX){
		__k1_cpu_backoff(INT32_MAX);
		tdiff -= INT32_MAX;
	}
	__k1_cpu_backoff(tdiff);
	return 0;
#endif
}