/* The main thread runs this function as a respons to the call of * interrupt_emulation(). */ int mainloop_interrupt( int dummy_rvec ) { mregs->interrupt = 0; if( async_io_is_pending() ) { shield_fpu( mregs ); do_async_io(); } recalc_mol_timer(); if (mregs->hostirq_update) { mregs->hostirq_update = 0; hostirq_update_irqs(&(mregs->active_irqs)); } /* the following is a race free solution... */ if( __cpu_irq_raise ) { __cpu_irq_raise = 0; set_cpu_irq_private( 1 ); } if( __cpu_irq_lower ) { __cpu_irq_lower = 0; set_cpu_irq_private( 0 ); } /* debugging stuff */ if( mregs->kernel_dbg_stop ) { printm("kernel_dbg_stop: %08lX\n", mregs->kernel_dbg_stop ); mregs->kernel_dbg_stop = 0; __stop = kStop; } return __stop; }
void * thread_handler(void *arg) { th_arg_t *th_arg = (th_arg_t *) arg; mb_affinity_t *aff; int i; int fd; int *fd_list; tid = syscall(SYS_gettid); th_arg->tid = tid; if (option.affinities != NULL){ aff = option.affinities[th_arg->id]; if (aff != NULL){ sched_setaffinity(tid, sizeof(cpu_set_t), &aff->cpumask); } } fd_list = malloc(sizeof(int) * option.nr_files); for (i = 0; i < option.nr_files; i++) { if ((fd = open(option.file_path_list[i], option.open_flags)) == -1){ perror("main:open(2)"); exit(EXIT_FAILURE); } fd_list[i] = fd; } if (option.aio == true) { if (option.verbose) fprintf(stderr, "do_async_io\n"); do_async_io(th_arg, fd_list); } else { if (option.verbose) fprintf(stderr, "do_sync_io\n"); do_sync_io(th_arg, fd_list); } for (i = 0; i < option.nr_files; i++) { if (close(fd_list[i]) == -1){ perror("main:close(2)"); exit(EXIT_FAILURE); } } return NULL; }