예제 #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
파일: main.c 프로젝트: 1587/ltp
void linear_read_write_test(test_ll_t * test)
{
	OFF_T *pVal1 = (OFF_T *) test->env->shared_mem;
	int i;

	if (test->args->flags & CLD_FLG_W) {
		test->env->bContinue = TRUE;
		*(pVal1 + OFF_WLBA) = test->args->start_lba;
		test->args->test_state = DIRCT_INC(test->args->test_state);
		test->env->lastAction.oper = WRITER;
		test->args->test_state = SET_OPER_W(test->args->test_state);
		test->args->test_state = SET_wFST_TIME(test->args->test_state);
//              srand(test->args->seed);        /* reseed so we can re create the same random transfers */
		memset(test->env->action_list, 0,
		       sizeof(action_t) * test->args->t_kids);
		test->env->action_list_entry = 0;
		test->env->wcount = 0;
		test->env->rcount = 0;
		if (test->args->flags & CLD_FLG_CYC)
			if (test->args->cycles == 0) {
				pMsg(INFO, test->args,
				     "Starting write pass, cycle %lu\n",
				     (unsigned long)test->env->pass_count);
			} else {
				pMsg(INFO, test->args,
				     "Starting write pass, cycle %lu of %lu\n",
				     (unsigned long)test->env->pass_count,
				     test->args->cycles);
		} else {
			pMsg(INFO, test->args, "Starting write pass\n");
		}
		CreateTestChild(ChildTimer, test);
		for (i = 0; i < test->args->t_kids; i++) {
			CreateTestChild(ChildMain, test);
		}
		/* Wait for the writers to finish */
		cleanUpTestChildren(test);
	}

	/* If the write test failed don't start the read test */
	if (!(TST_STS(test->args->test_state))) {
		return;
	}

	if (test->args->flags & CLD_FLG_R) {
		test->env->bContinue = TRUE;
		*(pVal1 + OFF_RLBA) = test->args->start_lba;
		test->args->test_state = DIRCT_INC(test->args->test_state);
		test->env->lastAction.oper = READER;
		test->args->test_state = SET_OPER_R(test->args->test_state);
		test->args->test_state = SET_rFST_TIME(test->args->test_state);
//              srand(test->args->seed);        /* reseed so we can re create the same random transfers */
		memset(test->env->action_list, 0,
		       sizeof(action_t) * test->args->t_kids);
		test->env->action_list_entry = 0;
		test->env->wcount = 0;
		test->env->rcount = 0;
		if (test->args->flags & CLD_FLG_CYC)
			if (test->args->cycles == 0) {
				pMsg(INFO, test->args,
				     "Starting read pass, cycle %lu\n",
				     (unsigned long)test->env->pass_count);
			} else {
				pMsg(INFO, test->args,
				     "Starting read pass, cycle %lu of %lu\n",
				     (unsigned long)test->env->pass_count,
				     test->args->cycles);
		} else {
			pMsg(INFO, test->args, "Starting read pass\n");
		}
		CreateTestChild(ChildTimer, test);
		for (i = 0; i < test->args->t_kids; i++) {
			CreateTestChild(ChildMain, test);
		}
		/* Wait for the readers to finish */
		cleanUpTestChildren(test);
	}
}
예제 #3
0
파일: main.c 프로젝트: 1587/ltp
void *threadedMain(void *vtest)
#endif
{
#ifndef WINDOWS
	test_ll_t *test = (test_ll_t *) vtest;
#endif

	OFF_T *pVal1;
	unsigned char *data_buffer_unaligned = NULL;
	unsigned long ulRV;
	int i;
	unsigned char *sharedMem;

	extern unsigned short glb_run;
	extern int signal_action;

	test->args->pid = GETPID();

	init_gbl_data(test->env);

	if (make_assumptions(test->args) < 0) {
		TEXIT((uintptr_t) GETLASTERROR());
	}
	if (check_conclusions(test->args) < 0) {
		TEXIT((uintptr_t) GETLASTERROR());
	}
	if (test->args->flags & CLD_FLG_DUMP) {
		/*
		 * All we are doing is dumping filespec data to STDOUT, so
		 * we will do this here and be done.
		 */
		do_dump(test->args);
		TEXIT((uintptr_t) GETLASTERROR());
	} else {
		ulRV = init_data(test, &data_buffer_unaligned);
		if (ulRV != 0) {
			TEXIT(ulRV);
		}
		pVal1 = (OFF_T *) test->env->shared_mem;
	}

	pMsg(START, test->args, "Start args: %s\n", test->args->argstr);

	/*
	 * This loop takes care of passes
	 */
	do {
		test->env->pass_count++;
		test->env->start_time = time(NULL);
		if (test->args->flags & CLD_FLG_RPTYPE) {	/* force random data to be different each cycle */
			fill_buffer(test->env->data_buffer,
				    ((test->args->htrsiz * BLK_SIZE) * 2), NULL,
				    0, CLD_FLG_RPTYPE);
		}
		sharedMem = test->env->shared_mem;
		memset(sharedMem + BMP_OFFSET, 0, test->env->bmp_siz);
		if ((test->args->flags & CLD_FLG_LINEAR)
		    && !(test->args->flags & CLD_FLG_NTRLVD)) {
			linear_read_write_test(test);
		} else {
			/* we only reset the end time if not running a linear read / write test */
			test->env->end_time =
			    test->env->start_time + test->args->run_time;
			test->env->bContinue = TRUE;
			*(pVal1 + OFF_WLBA) = test->args->start_lba;
			test->args->test_state =
			    DIRCT_INC(test->args->test_state);
			test->args->test_state =
			    SET_wFST_TIME(test->args->test_state);
			test->args->test_state =
			    SET_rFST_TIME(test->args->test_state);
			if (test->args->flags & CLD_FLG_W) {
				test->env->lastAction.oper = WRITER;
				test->args->test_state =
				    SET_OPER_W(test->args->test_state);
			} else {
				test->env->lastAction.oper = READER;
				test->args->test_state =
				    SET_OPER_R(test->args->test_state);
			}
			memset(test->env->action_list, 0,
			       sizeof(action_t) * test->args->t_kids);
			test->env->action_list_entry = 0;
			test->env->wcount = 0;
			test->env->rcount = 0;

			if (test->args->flags & CLD_FLG_CYC)
				if (test->args->cycles == 0) {
					pMsg(INFO, test->args,
					     "Starting pass %lu\n",
					     (unsigned long)test->env->
					     pass_count);
				} else {
					pMsg(INFO, test->args,
					     "Starting pass %lu of %lu\n",
					     (unsigned long)test->env->
					     pass_count, test->args->cycles);
			} else {
				pMsg(INFO, test->args, "Starting pass\n");
			}

			CreateTestChild(ChildTimer, test);
			for (i = 0; i < test->args->t_kids; i++) {
				CreateTestChild(ChildMain, test);
			}
			/* Wait for the children to finish */
			cleanUpTestChildren(test);
		}

		update_cyc_stats(test->env);
		if ((test->args->flags & CLD_FLG_CYC)
		    && (test->args->flags & CLD_FLG_PCYC)) {
			print_stats(test->args, test->env, CYCLE);
		}
		update_gbl_stats(test->env);

		if (signal_action & SIGNAL_STOP) {
			break;
		}		/* user request to stop */
		if ((glb_run == 0)) {
			break;
		}
		/* global request to stop */
		if (!(test->args->flags & CLD_FLG_CYC)) {
			break;	/* leave, unless cycle testing */
		} else {
			if ((test->args->cycles > 0)
			    && (test->env->pass_count >= test->args->cycles)) {
				break;	/* leave, cycle testing complete */
			}
		}
	} while (TST_STS(test->args->test_state));
	print_stats(test->args, test->env, TOTAL);

	FREE(data_buffer_unaligned);
	FREE(test->env->shared_mem);
#ifdef WINDOWS
	CloseHandle(OpenMutex(SYNCHRONIZE, TRUE, "gbl"));
	CloseHandle(OpenMutex(SYNCHRONIZE, TRUE, "data"));
#endif

	if (TST_STS(test->args->test_state)) {
		if (signal_action & SIGNAL_STOP) {
			pMsg(END, test->args,
			     "User Interrupt: Test Done (Passed)\n");
		} else {
			pMsg(END, test->args, "Test Done (Passed)\n");
		}
	} else {
		if (signal_action & SIGNAL_STOP) {
			pMsg(END, test->args,
			     "User Interrupt: Test Done (Failed)\n");
		} else {
			pMsg(END, test->args, "Test Done (Failed)\n");
		}
	}
	TEXIT((uintptr_t) GETLASTERROR());
}