int main(int argc, char **argv) { int i=0; setsignals(); #ifdef RCU_SIGNAL rcu_init(); #endif setup_test(argc, argv); printf("nbthreads %lu nbupdaters %lu nbbuckets %lu perbucket-pbnodes %lu nbtest %d nbreaders %d nbcores %d" #ifdef POPULATE " POPULATE" #endif "\n", nbthreads, nbupdaters, nbbuckets, pbnodes, NB_TEST, nbreaders, get_nbcores()); for(; i < ITERATION; i++) test(i); double rops = get_avg(&trd_ops[0],ITERATION); double wops = get_avg(&twr_ops[0],ITERATION); printf("read ops per micsec = %g\n", rops); printf("write ops per micsec = %g\n", wops); printf("write/read = %g\n", wops/rops); printf("nbmallocs = %g\n", get_avg(&run_mallocs[0],ITERATION)); printf("nbretry = %g\n", get_avg(&run_retry[0],ITERATION)); printf("nbrelink = %g\n", get_avg(&run_relink[0],ITERATION)); printf("nbreprev = %g\n", get_avg(&run_reprev[0],ITERATION)); printf("nbblockeds = %g\n", get_avg(&run_blockeds[0],ITERATION)); printf("sucess_search = %g on %g\n", get_avg(&run_sea[0],ITERATION), get_avg(&thd_ops[nbupdaters], nbreaders) ); printf("sucess_insert = %g on %g\n", get_avg(&run_ins[0],ITERATION), get_avg(&thd_ops[0], nbupdaters)/2); printf("sucess_delete = %g on %g\n", get_avg(&run_del[0],ITERATION), get_avg(&thd_ops[0], nbupdaters)/2); printf("\n"); printf("avg_max_read = %gus\n", get_max(&run_avg_rd[0],ITERATION)); printf("avg_avg_read = %gus\n", get_avg(&run_avg_rd[0],ITERATION)); printf("avg_min_read = %gus\n", get_min(&run_avg_rd[0],ITERATION)); printf("\n"); printf("avg_max_write = %gus\n", get_max(&run_avg_wr[0],ITERATION)); printf("avg_avg_write = %gus\n", get_avg(&run_avg_wr[0],ITERATION)); printf("avg_min_write = %gus\n", get_min(&run_avg_wr[0],ITERATION)); printf("\n"); printf("max_read = %gus\n", get_max(&run_max_rd[0],ITERATION)); printf("min_read = %gus\n", get_min(&run_min_rd[0],ITERATION)); printf("\n"); printf("max_write = %gus\n", get_max(&run_max_wr[0],ITERATION)); printf("min_write = %gus\n", get_min(&run_min_wr[0],ITERATION)); //printf("cpu time = %gus\n", get_avg(&run_cput[0],ITERATION));//FIXME return 0; }
static int setup(int argc, char** argv) { setargs(argc, argv); if(setstdfds()) retwarn(-1, "cannot set initial fds 0, 1, 2"); if(setinitctl()) /* Not having telinit is bad, but aborting system startup for this mere reason is likely even worse. */ warn("can't initialize initctl, init will be uncontrollable"); if(setsignals()) retwarn(-1, "failed to set signal handlers"); if(!configure(NONSTRICT)) setnewconf(); else if(!cfg) retwarn(-1, "initial configuration error"); return 0; }
void* run(void* arg) { unsigned long i; char iamreader; int key; long t = (long) arg; long nbn;//same cache line for the best rand! double start, end; node_t **hd; lock_t *lck; set_affinity(t); /************ init *****************/ thd_ins = 0; thd_del = 0; thd_sea = 0; nbmallocs = 0; nbretry = 0; nbrelink = 0; nbreprev = 0; nbfl = 0; thread=t; thd_nbupdaters=nbupdaters; setsignals(); iamreader = t >= nbupdaters ? 1 : 0; if(!iamreader) prealloc(); mysrand(t^time(NULL)); /************** init done **************/ /************** barrier ****************/ atomic_xadd4(&ready, 1); while(!go) memory_barrier(); /******************* START ****************/ start = d_gettimeofday(); #ifdef RCU rcu_register_thread(); #endif i=0; do{ key = myrand()%nbkeys; //key = rand_r(&thd_seed)%nbthreads; //key = (t+key)%nbkeys; //key = random() % nbkeys; //if(i%100000) printf("%d %d\n", thread, key); get_buckets(key, &hd, &lck); if(iamreader) { thd_sea += search(key, hd, lck); if(i>= NB_TEST) break; } else { if(i%2) thd_ins += insert(key, hd, lck); else thd_del += delete(key, hd, lck); if(done) { //printf("writer stopped\n"); break; } } //if(!(i%10000)) //printf("%d loop %d\n", t, i); #ifdef RCU_QSBR #if ((defined RCU_QSBR_ACCELERATE) || (defined RCU_Q10)) #ifdef RCU_Q10 if(!(i%10)) #else if(!(i%100)) #endif #endif rcu_quiescent_state(); #endif }while(++i); #ifdef RCU //if(!iamreader) rcu_barrier(); //printf("iamreader %d, ops %d\n", iamreader, i); rcu_unregister_thread(); #endif end = d_gettimeofday(); /******************* END ****************/ //number of ops done thd_ops[t] = i; //printf("nbmallocs %g\n", nbmallocs); thd_mallocs[t] = nbmallocs; thd_retry[t] = nbretry; thd_relink[t] = nbrelink; thd_reprev[t] = nbreprev; //if(t==0) printf("%lu | nbblocked %g\n", t, nbblockeds); #ifdef RCU thd_blockeds[t] = atomic_read_ptr(&rcublockeds); #else thd_blockeds[t] = nbblockeds; #endif //average time per ops avg_time[t] = (((end - start))/i); //total time thd_time[t] = (end - start); suc_ins[t] = thd_ins; suc_sea[t] = thd_sea; suc_del[t] = thd_del; return NULL; }
int warn_send(char *receipient, char *msg) { register struct utmpx *ubuf; static char rterminal[] = "/dev/\0 2345678901"; extern FILE *fp; time_t tod; char time_buf[40]; register int bad = 0; char *rcp1, *rcp2, *rcp3; (void) setlocale(LC_ALL, ""); #if !defined(TEXT_DOMAIN) #define TEXT_DOMAIN "SYS_TEST" #endif (void) textdomain(TEXT_DOMAIN); /* Set "rterm" to location where receipient's terminal will go. */ rterm = &rterminal[sizeof ("/dev/") - 1]; /* * strip any realm or instance from principal so we can match against unix * userid. */ rcp1 = strdup(receipient); rcp2 = strtok(rcp1, "@"); rcp3 = strtok(rcp2, "/"); /* * Scan through the "utmpx" file for the * entry for the person we want to send to. */ setutxent(); while ((ubuf = getutxent()) != NULL) { if (ubuf->ut_type == USER_PROCESS) { if (strncmp(rcp3, ubuf->ut_user, sizeof (ubuf->ut_user)) == 0) { strncpy(rterm, &ubuf->ut_line[0], sizeof (ubuf->ut_line)+1); /* Try to open up the line to the receipient's terminal. */ signal(SIGALRM, openfail); alarm(5); fp = fopen(&rterminal[0], "w"); alarm(0); /* Catch signals SIGHUP, SIGINT, SIGQUIT, and SIGTERM, and send */ /* <EOT> message to receipient. */ setsignals(eof); /* Get the time of day, convert it to a string and throw away the */ /* year information at the end of the string. */ time(&tod); cftime(time_buf, "%c", &tod); (void) fprintf(fp, gettext( "\r\n\007\007\007\tMessage from %s@%s [ %s ] ...\r\n"), progname, myhostname, time_buf); sleep(1); fprintf(fp, gettext("\r\nMessage to %s"), msg); fflush(fp); /* Since "end of file" received, send <EOT> message to receipient. */ eof(); fclose(fp); } } } free(rcp1); /* Did we find a place to talk to? If we were looking for a */ /* specific spot and didn't find it, complain and log it. */ if (*rterm == '\0') if (bad > 0) { (void) syslog(LOG_ERR, gettext("no place to send.\n")); return (1); } endutxent(); return (0); }
// starts the client static void start() { setsignals(); start_client(); }