예제 #1
0
/*
 *  SW-C2用性能評価関数
 */
void
measure_swc2(void)
{
	volatile uint32 i;
	IDT_TimeCount	cnt;

	WrapperCancelAlarm2();

	WrapperSuspendAllInterruptsWithoutOS();

	syslog(LOG_NOTICE, "== measure overhead ==");
	init_hist(2U, MAX_TIME, histarea);
	for (i = 0U; i < LOOP_COUNT; i++) {
		begin_measure(2U);
		end_measure(2U);
	}
	print_hist(2U);

	syslog(LOG_NOTICE, "== Rte_Read_SWC2_RPort_time  ==");
	init_hist(2U, MAX_TIME, histarea);
	for (i = 0U; i < LOOP_COUNT; i++) {
		begin_measure(2U);
		Rte_Read_SWC2_RPort_time(&cnt);
		end_measure(2U);
	}
	print_hist(2U);

	WrapperResumeAllInterruptsWithoutOS();

	WrapperShutdownOS();
}
예제 #2
0
/*
 *  メインタスク(中優先度)
 */
void main_task(intptr_t exinf)
{
	uint_t	i;

	syslog_0(LOG_NOTICE, "Performance evaluation program (4)");
	init_hist(1, MAX_TIME, histarea1);
	init_hist(2, MAX_TIME, histarea2);
	init_hist(3, MAX_TIME, histarea3);
	logtask_flush(0U);

	sus_tsk(LOGTASK);		/* システムログタスクの動作を止める */

	/*
	 *  タスク切換えを起こさないact_tskの処理時間の測定
	 */
	for (i = 0; i < NO_MEASURE; i++) {
		begin_measure(1);
		act_tsk(TASK3);
		end_measure(1);
		slp_tsk();
	}

	/*
	 *  タスク切換えを起こすact_tskの処理時間の測定
	 */
	for (i = 0; i < NO_MEASURE; i++) {
		begin_measure(2);
		act_tsk(TASK1);
	}

	/*
	 *  タスク切換えを起こすiact_tskの処理時間の測定(測定回数は10分の1)
	 */
	task2_count = 0;
	sta_cyc(CYC1);
	while (task2_count < NO_MEASURE / 10) ;
	stp_cyc(CYC1);

	rsm_tsk(LOGTASK);		/* システムログタスクの動作を再開する */

	syslog_0(LOG_NOTICE, "Execution times of act_tsk without task switch");
	print_hist(1);
	syslog_0(LOG_NOTICE, "Execution times of act_tsk with task switch");
	print_hist(2);
	syslog_0(LOG_NOTICE, "Execution times of iact_tsk with task switch");
	print_hist(3);
	ext_ker();
}
예제 #3
0
/*
 *  メインタスク(低優先度)
 */
void main_task(intptr_t exinf)
{
	syslog_0(LOG_NOTICE, "Performance evaluation program (1)");
	init_hist(1);
	init_hist(2);

	act_tsk(TASK1);
	act_tsk(TASK2);

	syslog_0(LOG_NOTICE, "Execution times of wup_tsk -> slp_tsk");
	print_hist(1);

	syslog_0(LOG_NOTICE, "Execution times of slp_tsk -> wup_tsk");
	print_hist(2);
	check_finish(0);
}
예제 #4
0
/*
 *  performance evaluation routine
 */
void
perf_eval(uint_t n)
{
	uint_t		i;
	intptr_t	data;
	PRI			pri;

	ini_pdq(PDQ1);
	init_hist(1, MAX_TIME, histarea1);

	for (i = 0; i < n; i++) {
		data = i;
		snd_pdq(PDQ1, data, 1);
	}

	for (i = 0; i < NO_MEASURE; i++) {
		data = i;
		begin_measure(1);
		snd_pdq(PDQ1, data, 2);
		end_measure(1);
		rcv_pdq(PDQ1, &data, &pri);
	}

	syslog_1(LOG_NOTICE, "Execution times of snd_pdq"
								" when %d data are queued.", n);
	print_hist(1);
	syslog_flush();
}
예제 #5
0
/*
 *  計測ルーチン
 */
void
perf_eval(uint_t n)
{
	uint_t		i, j;

	init_hist(1, MAX_TIME, histarea1);

	sus_tsk(LOGTASK);		/* システムログタスクの動作を止める */
	for (i = 0; i < NO_MEASURE; i++) {
		ini_flg(FLG1);
		for (j = 0; j < n; j++) {
			act_tsk(task_list[j]);
		}
		chg_pri(TSK_SELF, MAIN_PRIORITY_LOW);
		/* タスクが待ち状態に入るのを待つ */
		chg_pri(TSK_SELF, TPRI_INI);

		begin_measure(1);
		set_flg(FLG1, 0x01U);
		end_measure(1);

		chg_pri(TSK_SELF, MAIN_PRIORITY_LOW);
		/* タスクが終了するのを待つ */
		chg_pri(TSK_SELF, TPRI_INI);
	}
	rsm_tsk(LOGTASK);		/* システムログタスクの動作を再開する */

	syslog_1(LOG_NOTICE, "Execution times of set_flg"
							" when %d tasks are released from waiting.", n);
	print_hist(1);
	logtask_flush(0U);
}
예제 #6
0
/*
 *  main task (low priority)
 */
void main_task(intptr_t exinf)
{
	syslog_0(LOG_NOTICE, "Performance evaluation program (1)");
	init_hist(1, MAX_TIME, histarea1);
	init_hist(2, MAX_TIME, histarea2);
	syslog_flush();

	act_tsk(TASK1);
	act_tsk(TASK2);

	syslog_0(LOG_NOTICE, "Execution times of wup_tsk -> slp_tsk");
	print_hist(1);
	syslog_0(LOG_NOTICE, "Execution times of slp_tsk -> wup_tsk");
	print_hist(2);
	test_finish();
}
예제 #7
0
/*
 *  performance evaluation routine
 */
void
perf_eval(uint_t n)
{
	uint_t		i, j;

	init_hist(1, MAX_TIME, histarea1);

	for (i = 0; i < NO_MEASURE; i++) {
		ini_flg(FLG1);
		for (j = 0; j < n; j++) {
			act_tsk(task_list[j]);
		}
		chg_pri(TSK_SELF, MAIN_PRIORITY_LOW);
		/* let the task in the waiting queue of the event flag */
		chg_pri(TSK_SELF, TPRI_INI);

		begin_measure(1);
		set_flg(FLG1, 0x01U);
		end_measure(1);

		chg_pri(TSK_SELF, MAIN_PRIORITY_LOW);
		/* wait the task exits */
		chg_pri(TSK_SELF, TPRI_INI);
	}

	syslog_1(LOG_NOTICE, "Execution times of set_flg"
							" when %d tasks are released from waiting.", n);
	print_hist(1);
	syslog_flush();
}
예제 #8
0
/*
 *  メインタスク(低優先度)
 */
void main_task(intptr_t exinf)
{
	syslog_0(LOG_NOTICE, "Performance evaluation program (1)");
	init_hist(1, MAX_TIME, histarea1);
	init_hist(2, MAX_TIME, histarea2);
	logtask_flush(0U);

	sus_tsk(LOGTASK);		/* システムログタスクの動作を止める */
	act_tsk(TASK1);
	act_tsk(TASK2);
	rsm_tsk(LOGTASK);		/* システムログタスクの動作を再開する */

	syslog_0(LOG_NOTICE, "Execution times of wup_tsk -> slp_tsk");
	print_hist(1);
	syslog_0(LOG_NOTICE, "Execution times of slp_tsk -> wup_tsk");
	print_hist(2);
	ext_ker();
}
예제 #9
0
파일: test_13.c 프로젝트: slava77/emulibSVN
/*----------------------------- get_next_scan -------------------------------*/
int get_next_scan( int nscan)
  {

  if ( nscan != 1)
    {              // we don't need to fit and save at the begining 
    fit_thresh(nscan-1);
    save_hist(nscan-1);
    print_scan_result(nscan-1);
    HDELET(0);
    }
  init_hist (nscan);
  return 0;
  }
예제 #10
0
/*
 *  main task
 */
void main_task(intptr_t exinf)
{
	uint_t	i;

	syslog_0(LOG_NOTICE, "Performance evaluation program (0)");
	init_hist(1, MAX_TIME, histarea1);
	syslog_flush();

	for (i = 0; i < NO_MEASURE; i++) {
		begin_measure(1);
		end_measure(1);
	}

	syslog_0(LOG_NOTICE, "Measurement overhead");
	print_hist(1);
	test_finish();
}
예제 #11
0
/* initialize */
int event_init(){
	int i, k;
	hb_init(ofile,SHMSIZE);
  init_hist();
	evt_time();

	/* clear scalers */
	k = nscalers*nmodes;
	scaler = (int*)malloc(sizeof(int)*k);
	for(i=0; i<k; i++)
		scaler[i] = 0;

	/* clear analyzed blocks */
	ablk = 0;
	cblk = 0;
    return 0;
}
예제 #12
0
int main()
{
	ComList * ret_pointer = init_hist();

	

	ret_pointer = historico(ret_pointer,"circulo");
	ret_pointer = historico(ret_pointer,"bola");
	ret_pointer = historico(ret_pointer,"merda");
	
	printf("%s\n",ret_pointer->teclado);
	printf("%s\n",ret_pointer->next->teclado);
	
	savecomlist("ola",ret_pointer);
	
	return 0;
}
예제 #13
0
int CV_BaseHistTest::prepare_test_case( int test_case_idx )
{
    int i;
    float** r;

    clear();

    CvTest::prepare_test_case( test_case_idx );
    get_hist_params( test_case_idx );
    r = get_hist_ranges( test_case_idx );

    for( i = 0; i < hist_count; i++ )
    {
        hist[i] = cvCreateHist( cdims, dims, hist_type, r, uniform );
        init_hist( test_case_idx, i );
    }
    test_cpp = (cvTsRandInt(ts->get_rng()) % 2) != 0;

    return 1;
}
예제 #14
0
파일: gtcm_init.c 프로젝트: mihawk/fis-gtm
/* On OSF/1 (Digital Unix), pointers are 64 bits wide; the only exception to this is C programs for which one may
 * specify compiler and link editor options in order to use (and allocate) 32-bit pointers.  However, since C is
 * the only exception and, in particular because the operating system does not support such an exception, the argv
 * array passed to the main program is an array of 64-bit pointers.  Thus the C program needs to declare argv[]
 * as an array of 64-bit pointers and needs to do the same for any pointer it sets to an element of argv[].
 */
void gtcm_init(int argc, char_ptr_t argv[])
{
	char			*ptr;
	struct sigaction 	ignore, act;
	void			get_page_size();
	int		  	pid;
	char			msg[256];
	int			save_errno, maxfds;

	/*  Disassociate from the rest of the universe */
	get_page_size();
	gtm_wcswidth_fnptr = gtm_wcswidth;
#	ifndef GTCM_DEBUG_NOBACKGROUND
	FORK(pid);
	if (0 > pid)
	{
		save_errno = errno;
		SPRINTF(msg, "Unable to detach %s from controlling tty", SRVR_NAME);
		gtcm_rep_err(msg, save_errno);
		EXIT(-1);
	}
	else if (0 < pid)
		EXIT(0);
	(void) setpgrp();
#	endif
	/* Initialize logging */
	omi_pid = getpid();
	/*  Initialize signals */
	sigemptyset(&act.sa_mask);
	act.sa_flags = 0;
	ignore = act;
	ignore.sa_handler = SIG_IGN;
	act.sa_handler = (void (*)()) gtcm_term;
	(void) sigaction(SIGTERM, &act, 0);
	act.sa_handler = (void (*)()) gtcm_dmpstat;
	(void) sigaction(SIGUSR1, &act, 0);

	(void) sigaction(SIGUSR2, &ignore, 0);
	(void) sigaction(SIGALRM, &ignore, 0);
	(void) sigaction(SIGPIPE, &ignore, 0);
	(void) sigaction(SIGINT, &ignore, 0);
#	ifdef GTCM_RC
	act.sa_handler = gtcm_fail;
	act.sa_flags = SA_RESETHAND;
	/* restore signal handler to default action upon receipt
	   of signal */
	(void) sigaction(SIGSEGV, &act, 0);
	(void) sigaction(SIGBUS, &act, 0);
	(void) sigaction(SIGILL, &act, 0);
	(void) sigaction(SIGTRAP, &act, 0);
	(void) sigaction(SIGABRT, &act, 0);
#	ifndef __linux__
	(void) sigaction(SIGEMT, &act, 0);
	(void) sigaction(SIGSYS, &act, 0);
#	endif
#	endif
	/*  Initialize the process flags */
	if (0 != gtcm_prsopt(argc, argv))
		EXIT(-1);
	/* Write down pid into log file */
	 OMI_DBG((omi_debug, "GTCM_SERVER pid : %d\n", omi_pid));
	/* Initialize history mechanism */
	if (history)
	{
		init_hist();
		act.sa_handler = (void (*)())dump_rc_hist;
		act.sa_flags = 0;
		(void) sigaction(SIGUSR2, &act, 0);
	}
	/*  Initialize the DBMS */
	licensed = TRUE;
	getjobnum();
	getzdir();
	if ((maxfds = getmaxfds()) < 0)
	{
		gtcm_rep_err("Unable to get system resource limits", errno);
		EXIT(errno);
	}
	assert(SIZEOF(gtcm_ast_avail) == 2);	/* check that short is size 2 bytes as following code relies on that */
	gtcm_ast_avail = (maxfds > MAXINT2) ? MAXINT2 : maxfds;
	stp_init(STP_INITSIZE);
	rts_stringpool = stringpool;
	curr_pattern = pattern_list = &mumps_pattern;
	pattern_typemask = mumps_pattern.typemask;
	INVOKE_INIT_SECSHR_ADDRS;
	initialize_pattern_table();
	/* Preallocate some timer blocks. */
	prealloc_gt_timers();
	gt_timers_add_safe_hndlrs();
	/* Moved to omi_gvextnam, omi_lkextnam */
	/*    gvinit(); */
	return;
}
예제 #15
0
/* 
 * Input a line with some basic editing.
 */
char * read_line() {

	// save terminal settings
	struct termios orig_attr;
	tcgetattr(0, &orig_attr);

	// Set terminal in raw mode
	tty_raw_mode();

	line_length = 0;
	line_pos = 0;

	// reset the line buffer
	int t = 0;
	for (t = 0; t < MAX_BUFFER_LINE; t++) {
		line_buffer[t] = '\0';
	}

	// Read one line until enter is typed
	while (1) {

		// init history if necessary
		if (history == NULL) {
			init_hist();
		}

		// Read one character in raw mode.
		char ch;
		read(0, &ch, 1);

		if (ch>=32 && ch < 127) {
			// It is a printable character. 

			if (line_pos == line_length) {
				// we're at the end of the line
				// Do echo
				write(1,&ch,1);

				// If max number of character reached return.
				if (line_length==MAX_BUFFER_LINE-2) break; 

				// add char to buffer.
				line_buffer[line_pos]=ch;
				line_length++;
				line_pos++;
			} else {
				// in the middle of the line somewhere
				char * temp = (char*)malloc(MAX_BUFFER_LINE * sizeof(char));
				int i;
				// copy all the characters after where we're at
				for ( i = 0; i < MAX_BUFFER_LINE; i++) {

					if (line_buffer[line_pos + i] == '\0' ) {
						// if we see the null char, we've gotten it all
						break;
					}
					temp[i] = line_buffer[line_pos + i];
				}

				// write the character we want to add
				write (1, &ch, 1);

				// If max number of character reached return.
				if (line_length==MAX_BUFFER_LINE-2) break; 
				
				// add char to buffer.
				line_buffer[line_pos]=ch;
				line_length++;
				line_pos++;

				// print all the rest of the characters afterwards
				int chars_added = 0;
				for (i = 0; i < MAX_BUFFER_LINE; i++) {
					chars_added+=1;
					write(1, &temp[i], 1);
					if (line_buffer[line_pos + i] == '\0' ) {
						// if we see the null char, we've gotten it all
						break;
					}
				}
				// go back to where we were
				backspace(chars_added);
			}
		}
		else if (ch==10) {
			// <Enter> was typed. Return line

			// add line to history linked list if it's not empty
			if ( strlen(line_buffer) != 0 ) {
				add_hist_line(line_buffer);
			}

			// Print newline
			write(1,&ch,1);

			break;
		}
		else if (ch == 31) {
			// ctrl-?
			read_line_print_usage();
			line_buffer[0]=0;
			break;
		}
		else if (ch == 127) {
			// <backspace> was typed. Remove previous character read.

			// don't do anything if we're already at the beginning 
			if (line_pos <= 0) {
				continue;
			}

			// Go back one character
			backspace(1);

			// Write a space to erase the last character read
			ch = ' ';
			write(1,&ch,1);

			// Go back one character
			backspace(1);

			// Remove one character from buffer
			line_buffer[ line_pos ] = '\0';
			line_length--;
			line_pos--;
		}
		else if (ch==27) {
			// Escape sequence. Read two chars more
			//
			// HINT: Use the program "keyboard-example" to
			// see the ascii code for the different chars typed.
			//
			char ch1; 
			char ch2;
			read(0, &ch1, 1);
			read(0, &ch2, 1);
			if (ch1==91 && ch2==65) {
				// Up arrow. Print next line in history.

				// Erase old line
				// Print backspaces
				int i = 0;
				for (i =0; i < line_length; i++) {
					ch = 8;
					write(1,&ch,1);
				}

				// Print spaces on top
				for (i =0; i < line_length; i++) {
					ch = ' ';
					write(1,&ch,1);
				}

				// Print backspaces
				for (i =0; i < line_length; i++) {
					ch = 8;
					write(1,&ch,1);
				}

				// if history is uninitialized, do nothing
				// Copy line from history
				history_index -= 1;
				if (history_index <= 0) {
					// loop back to the most recent command
					history_index = history_length - 1;
				}

				if (history[history_index] == NULL) {
					const char * empty = "";
					strcpy(line_buffer, empty);
				} else {
					strcpy(line_buffer, history[history_index]);
				}
				line_length = strlen(line_buffer);

				// echo line
				write(1, line_buffer, line_length);
			}
			else if (ch1 == 91 && ch2 == 66) {
				// down arrow. print previous line in history

				// Erase old line
				// Print backspaces
				backspace( line_length );

				// Print spaces on top
				int i = 0;
				for (i =0; i < line_length; i++) {
					ch = ' ';
					write(1,&ch,1);
				}

				// Print backspaces
				backspace( line_length );

				// increment index accordingly
				if (history_index <= 0) {
					// stay at 0
					history_index = 0;
				} else {
					history_index += 1;
					if (history_index >= history_length ) {
						history_index = 0;
					} 
				}

				// Copy line from history
				if (history[history_index] == NULL) {
					const char * empty = "";
					strcpy(line_buffer, empty);
				} else {
					strcpy(line_buffer, history[history_index]);
				}
				line_length = strlen(line_buffer);

				// echo line
				write(1, line_buffer, line_length);
			}
			else if (ch1 == 91 && ch2 == 68) {
				// left arrow
				if (line_pos > 0) {
					line_pos--;
					backspace(1);
				}
			}
			else if (ch1 == 91 && ch2 == 67) {
				// right arrow
				if (line_pos < line_length) {

					// grab current char
					char c = line_buffer[line_pos];

					// print grabbed char
					write( 1, &c, 1);

					line_pos++;
				}
			}
		}
	}

	// Add eol and null char at the end of string
	line_buffer[line_length]=10;
	line_length++;
	line_buffer[line_length]=0;

	// set the terminal back to orig settings
	tcsetattr(0, TCSANOW, &orig_attr);

	return line_buffer;
}
예제 #16
0
/*
 *  メインタスク
 */
void main_task(intptr_t exinf)
{
	uint_t	i, j;

	syslog_0(LOG_NOTICE, "Performance evaluation program (5)");
	init_hist(1);
	init_hist(2);
	init_hist(3);
	init_hist(4);
	init_hist(5);
	init_hist(6);

	/*
	 *  繰り返し計測
	 */
	for (j = 0; j < NO_MEASURE / 10; j++) {
		/*
		 *  アラームハンドラ0短い時間で動作開始
		 *
		 *  性能評価中に高分解能タイマが再設定されるのを避けるため.
		 */
		sta_alm(ALM0, ALM_RELTIM0);

		/*
		 *  30個のアラームハンドラを長い時間で動作開始
		 */
		begin_measure(1);
		for (i = 0; i < 30; i++) {
			sta_alm(alarm1_list[i], ALM_RELTIM1);
		}
		end_measure(1);

		/*
		 *  30個のアラームハンドラを中間の時間で動作開始
		 */
		begin_measure(2);
		for (i = 0; i < 30; i++) {
			sta_alm(alarm2_list[i], ALM_RELTIM2);
		}
		end_measure(2);

		/*
		 *  30個のアラームハンドラを短い時間で動作開始
		 */
		begin_measure(3);
		for (i = 0; i < 30; i++) {
			sta_alm(alarm3_list[i], ALM_RELTIM3);
		}
		end_measure(3);

		/*
		 *  短い時間で動作開始した30個のアラームハンドラを動作停止
		 */
		begin_measure(6);
		for (i = 0; i < 30; i++) {
			stp_alm(alarm3_list[i]);
		}
		end_measure(6);

		/*
		 *  中間の時間で動作開始した30個のアラームハンドラを動作停止
		 */
		begin_measure(5);
		for (i = 0; i < 30; i++) {
			stp_alm(alarm2_list[29 - i]);		/* 逆順で動作停止 */
		}
		end_measure(5);

		/*
		 *  長い時間で動作開始した30個のアラームハンドラを動作停止
		 */
		begin_measure(4);
		for (i = 0; i < 30; i++) {
			stp_alm(alarm1_list[29 - i]);		/* 逆順で動作停止 */
		}
		end_measure(4);
	}

	/*
	 *  測定結果の出力
	 */
	syslog_0(LOG_NOTICE, "Execution times of 30 short sta_alm");
	print_hist(1);

	syslog_0(LOG_NOTICE, "Execution times of 30 medium sta_alm");
	print_hist(2);

	syslog_0(LOG_NOTICE, "Execution times of 30 long sta_alm");
	print_hist(3);

	syslog_0(LOG_NOTICE, "Execution times of 30 short stp_alm");
	print_hist(4);

	syslog_0(LOG_NOTICE, "Execution times of 30 medium stp_alm");
	print_hist(5);

	syslog_0(LOG_NOTICE, "Execution times of 30 long stp_alm");
	print_hist(6);
	check_finish(0);
}