예제 #1
0
파일: timer.c 프로젝트: CSU-GH/okl4_3.0
void *ChildTimer(void *vtest)
#endif
{
#ifndef WINDOWS
    test_ll_t *test = (test_ll_t *)vtest;
#endif
    extern time_t global_end_time;		/* overall end time of test */
    time_t local_end_time = 0;
    int i;

    child_args_t *args = test->args;
    test_env_t *env = test->env;

    if((args->flags & CLD_FLG_TMD)) {
        local_end_time = global_end_time;
    } else { /* force the longest time */
        for(i=0; i<(sizeof(time_t)*8)-1; i++) {
            local_end_time |= 0x1ULL<<i;
        }
    }

    PDBG4(DEBUG, test->args, "In timer %lu < %lu, %d\n", time(NULL), local_end_time, env->bContinue);
    do {
        Sleep(1000);
        PDBG4(DEBUG, test->args, "Continue timing %lu < %lu, %d\n", time(NULL), local_end_time, env->bContinue);
        if(args->flags & CLD_FLG_W) {
            if((args->flags & CLD_FLG_LINEAR) && !(args->flags & CLD_FLG_NTRLVD)) {
                if(TST_OPER(args->test_state) == WRITER) {
                    env->cycle_stats.wtime++;
                }
            } else {
                env->cycle_stats.wtime++;
            }
        }
        if(args->flags & CLD_FLG_R) {
            if((args->flags & CLD_FLG_LINEAR) && !(args->flags & CLD_FLG_NTRLVD)) {
                if(TST_OPER(args->test_state) == READER) {
                    env->cycle_stats.rtime++;
                }
            } else {
                env->cycle_stats.rtime++;
            }
        }
        if((args->hbeat > 0) && ((env->cycle_stats.wtime % args->hbeat) || (env->cycle_stats.rtime % args->hbeat)) == 0) {
            print_stats(args, env, CYCLE);
        }
        /* If test failed don't continue to report stats */
        if(!(TST_STS(args->test_state))) {
            break;
        }
    } while((time(NULL) < local_end_time) && (env->bContinue));
    PDBG4(DEBUG, test->args, "Out of timer %lu < %lu, %d\n", time(NULL), local_end_time, env->bContinue);
    env->bContinue = FALSE;
    TEXIT(GETLASTERROR());
}
예제 #2
0
파일: timer.c 프로젝트: 1587/ltp
void *ChildTimer(void *vtest)
#endif
{
#ifndef WINDOWS
	test_ll_t *test = (test_ll_t *) vtest;
#endif
	time_t ioTimeoutCount = 0;
	time_t total_time = 0;
	OFF_T cur_total_io_count = 0;
	OFF_T last_total_io_count = 0;

	OFF_T tmp_io_count = 0;
	time_t run_time = 0;

	lvl_t msg_level = WARN;

	child_args_t *args = test->args;
	test_env_t *env = test->env;

	extern int signal_action;
	extern unsigned short glb_run;

#ifdef _DEBUG
	PDBG3(DBUG, args, "In timer %lu, %d\n", time(NULL), env->bContinue);
#endif
	do {
		Sleep(1000);
		run_time++;
#ifdef _DEBUG
		PDBG3(DBUG, args, "Continue timing %lu, %lu, %d\n", time(NULL),
		      run_time, env->bContinue);
#endif
		if (args->flags & CLD_FLG_W) {
			if ((args->flags & CLD_FLG_LINEAR)
			    && !(args->flags & CLD_FLG_NTRLVD)) {
				if (TST_OPER(args->test_state) == WRITER) {
					env->hbeat_stats.wtime++;
				}
			} else {
				env->hbeat_stats.wtime++;
			}
		}
		if (args->flags & CLD_FLG_R) {
			if ((args->flags & CLD_FLG_LINEAR)
			    && !(args->flags & CLD_FLG_NTRLVD)) {
				if (TST_OPER(args->test_state) == READER) {
					env->hbeat_stats.rtime++;
				}
			} else {
				env->hbeat_stats.rtime++;
			}
		}

		/*
		 * Check to see if we have made any IO progress in the last interval,
		 * if not incremment the ioTimeout timer, otherwise, clear it
		 */
		cur_total_io_count = env->global_stats.wcount
		    + env->cycle_stats.wcount
		    + env->hbeat_stats.wcount
		    + env->global_stats.rcount
		    + env->cycle_stats.rcount + env->hbeat_stats.rcount;

		if (cur_total_io_count == 0) {
			tmp_io_count = 1;
		} else {
			tmp_io_count = cur_total_io_count;
		}

		total_time = env->global_stats.rtime
		    + env->cycle_stats.rtime
		    + env->hbeat_stats.rtime
		    + env->global_stats.wtime
		    + env->cycle_stats.wtime + env->hbeat_stats.wtime;

#ifdef _DEBUG
		PDBG3(DBUG, args, "average number of seconds per IO: %0.8lf\n",
		      ((double)(total_time) / (double)(tmp_io_count)));
#endif

		if (cur_total_io_count == last_total_io_count) {	/* no IOs completed in interval */
			if (0 == (++ioTimeoutCount % args->ioTimeout)) {	/* no progress after modulo ioTimeout interval */
				if (args->flags & CLD_FLG_TMO_ERROR) {
					args->test_state =
					    SET_STS_FAIL(args->test_state);
					env->bContinue = FALSE;
					msg_level = ERR;
				}
				pMsg(msg_level, args,
				     "Possible IO hang condition, IO timeout reached, %lu seconds\n",
				     args->ioTimeout);
			}
#ifdef _DEBUG
			PDBG3(DBUG, args, "io timeout count: %lu\n",
			      ioTimeoutCount);
#endif
		} else {
			ioTimeoutCount = 0;
			last_total_io_count = cur_total_io_count;
#ifdef _DEBUG
			PDBG3(DBUG, args, "io timeout reset\n");
#endif
		}

		if (((args->hbeat > 0) && ((run_time % args->hbeat) == 0))
		    || (signal_action & SIGNAL_STAT)) {
			print_stats(args, env, HBEAT);
			update_cyc_stats(env);
			clear_stat_signal();
		}

		if (glb_run == 0) {
			break;
		}		/* global run flag cleared */
		if (signal_action & SIGNAL_STOP) {
			break;
		}
		/* user request to stop */
		if (args->flags & CLD_FLG_TMD) {	/* if timing */
			if (run_time >= args->run_time) {	/* and run time exceeded */
				break;
			}
		} else {	/* if not timing */
			if (env->kids <= 1) {	/* and the timer is the only child */
				break;
			}
		}
	} while (TRUE);
#ifdef _DEBUG
	PDBG3(DBUG, args, "Out of timer %lu, %lu, %d, %d\n", time(NULL),
	      run_time, env->bContinue, env->kids);
#endif

	if (args->flags & CLD_FLG_TMD) {	/* timed test, timer exit needs to stop io threads */
#ifdef _DEBUG
		PDBG3(DBUG, args,
		      "Setting bContinue to FALSE, timed test & timer exit\n");
#endif
		env->bContinue = FALSE;
	}

	TEXIT((uintptr_t) GETLASTERROR());
}