void *run_read(void *args){ unsigned int k,j; unsigned int *ll; struct reader_slot *rd_slt; unsigned int id; rd_slt= reader_init(reg); id = get_id(rd_slt); printf("[%u]RD: START\n", id); //sleep(1); while(!start); while(!end || (end_read!=0 && count_read[id] >= end_read)){ //read ll=reg_read(rd_slt); //busy loops k = busy_loop(busy_read); count_read[id]++; //if((count_read[id]%(end_read/5)) == 0) printf("[%u]RD: Iteration %10u\n",id,count_read[id]); } printf("[%u]RD: %u read operations performed\n", id,count_read[id]); pthread_exit(NULL); }
void test_monitor(monitor_target who, bool all_verbosities, bool threaded) { monitor *m = monitor_init(who); monitor_start(m); if(threaded){ busy_threads(); } else { busy_loop(); } monitor_end(m); if(all_verbosities){ monitor_print_stats(m, SILENT); SMALL_SEP(); monitor_print_stats(m, QUIET); SMALL_SEP(); } monitor_print_stats(m, VERBOSE); monitor_free(m); }
void *run_write(void *args){ unsigned int arr[size/4]; unsigned int j=0, k, id; struct writer_slot *wr_slt; wr_slt = writer_init(reg); id = get_id(wr_slt); printf("[%u]WR: START\n", id); while(!start); while(!end || (end_write!=0 && count_write >= end_write)){ //write reg_write(wr_slt, arr); //busy loops k = busy_loop(busy_write); count_write++; //if((count_write%(end_write/10)) == 0) printf("WR: Iteration %10u\n",count_write); } //end = true; printf("[0]WR: END\n"); pthread_exit(NULL); }
enum cts_rc test_interrupt_enable(void) { if (busy_loop()) { CPRINTS("Timeout before interrupt"); return CTS_RC_TIMEOUT; } return CTS_RC_SUCCESS; }
enum cts_rc test_interrupt_disable(void) { interrupt_disable(); if (!busy_loop()) { CPRINTS("Expected timeout but didn't"); return CTS_RC_FAILURE; } return CTS_RC_SUCCESS; }
/* * Interrupt handler. */ void cts_irq1(enum gpio_signal signal) { state[state_index++] = 'B'; got_interrupt = in_interrupt_context(); /* Wake up the CTS task */ if (wake_me_up) task_wake(TASK_ID_CTS); busy_loop(); state[state_index++] = 'C'; }
void *start_task(void *data) { struct thread *thr = (struct thread *)data; long id = (long) thr->arg; thread_pids[id] = gettid(); unsigned long long start_time; int ret; int high = 0; cpu_set_t cpumask; cpu_set_t save_cpumask; int cpu = 0; unsigned long l; long pid; ret = sched_getaffinity(0, sizeof(save_cpumask), &save_cpumask); if (ret < 0) debug(DBG_ERR, "sched_getaffinity failed: %s\n", strerror(ret)); pid = gettid(); /* Check if we are the highest prio task */ if (id == nr_tasks-1) high = 1; while (!done) { if (high) { /* rotate around the CPUS */ if (!CPU_ISSET(cpu, &save_cpumask)) cpu = 0; CPU_ZERO(&cpumask); CPU_SET(cpu, &cpumask); cpu++; sched_setaffinity(0, sizeof(cpumask), &cpumask); } pthread_barrier_wait(&start_barrier); start_time = rt_gettime(); ftrace_write("Thread %d: started %lld diff %lld\n", pid, start_time, start_time - now); l = busy_loop(start_time); record_time(id, start_time / NS_PER_US, l); pthread_barrier_wait(&end_barrier); } return (void *)pid; }
int main(int argc, char **argv) { int rsize = 0; int wsize = 0; int factor = atoi(argv[0] + 6); SRAND(factor); FPRINTF(STDERR, "seeded with %d\n", factor); /* copy all data from STDIN to STDOUT */ for(;;) { char buffer[CHUNK_SIZE]; // int plan = RAND() % sizeof buffer + 1; int plan = (rand() * rand()) % sizeof buffer + 1; /* read */ int count = READ(STDIN, buffer, plan); BREAKIF(count < 0, "read error %d\n", count); busy_loop(factor); /* eof */ if(count == 0) break; /* the read log */ rsize += count; FPRINTF(STDERR, "%5d(of %5d) read, ", count, plan); /* write */ count = WRITE(STDOUT, buffer, count); BREAKIF(count < 0, "write error %d\n", count); /* the write log */ FPRINTF(STDERR, "%5d written\n", count); wsize += count; } /* report results */ FPRINTF(STDERR, "\n%d bytes has been read\n", rsize); FPRINTF(STDERR, "%d bytes has been written\n", wsize); return rsize == wsize ? 0 : 1; }
void platform_test_loop_ticks() { /* Initialize the timer */ unsigned long timer_base = PLATFORM_TIMER0_VBASE + SP804_TIMER1_OFFSET; volatile u32 reg = read(timer_base + SP804_CTRL); const int looptotal = 500000; int ticks, loops = looptotal; int inst_per_loop = 2; const int timer_load = 0xFFFFFFFF; int timer_read; int ipm_whole, ipm_decimal, temp; /* Make sure timer is disabled */ write(0, timer_base + SP804_CTRL); /* Load the timer with a full value */ write(timer_load, timer_base + SP804_LOAD); /* One shot, 32 bits, no irqs */ reg = SP804_32BIT | SP804_ONESHOT | SP804_ENABLE; /* Start the timer */ write(reg, timer_base + SP804_CTRL); dmb(); /* Make sure write occurs before looping */ busy_loop(loops); timer_read = read(timer_base + SP804_VALUE); ticks = timer_load - timer_read; temp = (inst_per_loop * looptotal) * 10 / ticks; ipm_whole = temp / 10; ipm_decimal = temp - ipm_whole * 10; printk("Perfmon: %d ticks/%d instructions\n", ticks, inst_per_loop * looptotal); printk("Perfmon: %d%d instr/Mhz.\n", ipm_whole, ipm_decimal); }
void platform_test_loop_cycles() { const int looptotal = 1000000; int cyccnt, loops = looptotal; int inst_per_loop = 2; int ipc_whole, ipc_decimal, temp; /* Test the basic cycle counter */ perfmon_reset_start_cyccnt(); isb(); busy_loop(loops); /* Finish all earlier instructions */ isb(); cyccnt = perfmon_read_cyccnt(); /* Finish reading cyccnt */ isb(); /* * Do some fixed point division * * The idea is to multiply by 10, divide by 10 and * get the remainder. Remainder becomes the decimal * part. The division result is the whole part. */ temp = inst_per_loop * looptotal * 10 / (cyccnt * 64); ipc_whole = temp / 10; ipc_decimal = temp - ipc_whole * 10; printk("Perfmon: %d cycles/%d instructions\n", cyccnt * 64, inst_per_loop * looptotal); printk("Perfmon: %d.%d Inst/cycle\n", ipc_whole, ipc_decimal); }
void *start_task(void *data) { long id = (long)data; unsigned long long start_time; struct sched_param param = { .sched_priority = id + prio_start, }; int ret; int high = 0; cpu_set_t cpumask; cpu_set_t save_cpumask; int cpu = 0; unsigned long l; long pid; ret = sched_getaffinity(0, sizeof(save_cpumask), &save_cpumask); if (ret < 0) perr("getting affinity"); pid = gettid(); /* Check if we are the highest prio task */ if (id == nr_tasks-1) high = 1; ret = sched_setscheduler(0, SCHED_FIFO, ¶m); if (ret < 0 && !id) fprintf(stderr, "Warning, can't set priorities\n"); while (!done) { if (high) { /* rotate around the CPUS */ if (!CPU_ISSET(cpu, &save_cpumask)) cpu = 0; CPU_ZERO(&cpumask); CPU_SET(cpu, &cpumask); cpu++; sched_setaffinity(0, sizeof(cpumask), &cpumask); } pthread_barrier_wait(&start_barrier); start_time = get_time(); lgprint(lfd, "Thread %d: started %lld diff %lld\n", pid, start_time, start_time - now); l = busy_loop(start_time); record_time(id, start_time, l); pthread_barrier_wait(&end_barrier); } return (void*)pid; } static int check_times(int l) { int i; unsigned long long last; unsigned long long last_loops; unsigned long long last_length; for (i=0; i < nr_tasks; i++) { if (i && last < intervals[l][i] && ((intervals[l][i] - last) > max_err)) { /* * May be a false positive. * Make sure that we did more loops * our start is before the end * and the end should be tested. */ if (intervals_loops[l][i] < last_loops || intervals[l][i] > last_length || (intervals_length[l][i] > last_length && intervals_length[l][i] - last_length > max_err)) { check = -1; return 1; } } last = intervals[l][i]; last_loops = intervals_loops[l][i]; last_length = intervals_length[l][i]; } return 0; }
void *busy(void *no_args) { busy_loop(); pthread_exit(NULL); }
void cts_irq2(enum gpio_signal signal) { state[state_index++] = 'A'; busy_loop(); state[state_index++] = 'D'; }