static __inline void get_tstamp (DWORD *ts) { ts[0] = ts[1] = 0UL; #if defined(HAVE_UINT64) if (has_rdtsc && use_rdtsc) *(uint64*)ts = get_rdtsc(); #endif }
/*@ brief thread to read the data */ void *write_data(void *data) { uint8_t *ptr = (uint8_t*) data; uint8_t tid=*ptr; while(global_run) { tsc.t4 = get_rdtsc(); enqueue(tid, (uint8_t *) &(tsc.t), 4); printd("write_data: (%" PRIu8 ")RDTSC wrote %" PRIu64 "\n", tid, tsc.t4); sleep(1); } }
/*@ brief thread to read the data */ void *read_data(void *data) { uint8_t *ptr = (uint8_t*) data; uint8_t tid=*ptr; data = malloc(1); uint64__T tsc1; while(global_run) { tsc1.t4 = get_rdtsc(); dequeue(tid, (uint8_t *) &(tsc.t), 4); printd("read_data: (%" PRIu8 ")RDTSC (%" PRIu64 "-%" PRIu64 ")=%" PRIu64 "\n" , tid, tsc1.t4,tsc.t4,tsc1.t4-tsc.t4); sleep(1); } return data; }
void check_scheduling(void) { uint32_t prio = get_highest_priority(); task_t* curr_task = per_core(current_task); if (prio > curr_task->prio) { reschedule(); #ifdef DYNAMIC_TICKS } else if ((prio > 0) && (prio == curr_task->prio)) { // if a task is ready, check if the current task runs already one tick (one time slice) // => reschedule to realize round robin const uint64_t diff_cycles = get_rdtsc() - curr_task->last_tsc; const uint64_t cpu_freq_hz = 1000000ULL * (uint64_t) get_cpu_frequency(); if (((diff_cycles * (uint64_t) TIMER_FREQ) / cpu_freq_hz) > 0) { LOG_DEBUG("Time slice expired for task %d on core %d. New task has priority %u.\n", curr_task->id, CORE_ID, prio); reschedule(); } #endif } }
int main(int argc, char *argv[]) { std::string rule; srand(get_rdtsc()); while (getline(std::cin, rule)) { unsigned int ruleNum; std::stringstream strStream(rule); strStream >> ruleNum; printf("%u ", ruleNum); while (!strStream.eof()) { char type; unsigned int num; strStream >> type; if (strStream.eof()) { break; } strStream >> num; if (type == 't') { if (okToMutateTerminal()) { printf("t %u ", rand() % 256); } else { printf("t %u ", num); } } else { assert(type == 'n'); printf("n %u ", num); } } if (okToMutateInsertTrailingTerminal()) { printf("t %u ", rand() % 256); } printf("\n"); } return 0; }
int main(int argc, char *argv[]) { uint32_t **key; uint32_t **extendedkey; uint32_t round; unsigned long n; unsigned long i, j; unsigned long ans; uint32_t a, b; unsigned long long t1, t2; double tt, avg, total; printf("Round of feistel permutation:"); scanf("%d", &round); key = (uint32_t **)malloc(round * sizeof(uint32_t **)); extendedkey = (uint32_t **)malloc(round * sizeof(uint32_t **)); for(i = 0; i < round; i ++) { key[i] = (uint32_t *)malloc(4 * sizeof(uint32_t *)); extendedkey[i] = (uint32_t *)malloc(20 * sizeof(uint32_t *)); memset(key[i], 0, 4 * sizeof(uint32_t)); memset(extendedkey[i], 0, 20 * sizeof(uint32_t)); } for(i = 0; i < round; i ++) { printf("Please input key for %dth round(4 uint32):", i + 1); for(j = 0; j < 4; j ++) { scanf("%u", &key[i][j]); } } for(i = 0; i < round; i ++) { ExpandKey_32(key[i], extendedkey[i]); } freopen(argv[2], "w", stdout); n = (unsigned long)atol(argv[1]); discomp_max(n, &a, &b); total = 0; timer_init(); for(i = 0; i < n ; i ++) { t1 = get_rdtsc(); ans = permute(i, n, a, b, extendedkey, round); t2 = get_rdtsc(); tt = ((double)(t2 - t1) / cpu_freq) * TIMESCALE; total += tt; printf("%u -> %u, time cost is %lfus\n", i, ans, tt); fflush(stdout); } printf("Feistel permutation round for each item is %d\n", round); printf("Total cost is %lfus, and average cost is %lfus\n", total, total/n); fflush(stdout); fclose(stdout); for(i = 0; i < round; i ++) { free(key[i]); free(extendedkey[i]); } free(key); free(extendedkey); return 0; }
int fastfood(void) { printf("ICH BIN EIN NATIVE LIBRARY BRO!!\n"); printf("RDTSC: %ld\n",get_rdtsc()); exit(0); }