Example #1
0
void cos_init(void)
{

	printc("\n****** TOP: thread %d in spd %ld ******\n",cos_get_thd_id(), cos_spd_id());

	periodic_wake_create(cos_spd_id(), PERIODIC);

	int k = 0;
	int th;
	int i = 0;
	
	/* do{ */
	/* 	periodic_wake_wait(cos_spd_id()); */
	/* }while (i++ < waiting); */
	i = 0;

	/* printc("thd %d start testing...!\n", cos_get_thd_id()); */

	while(1){
		k++;
		/* printc("kkkkkk %d\n",k); */
		th = cos_get_thd_id();

		/* if ( (th == 16 || th == 17) && k >= 2)  */
		/* 	break; */

		cbuf_call('a');
		/* if(cos_get_thd_id() == 15) while(1); */
		periodic_wake_wait(cos_spd_id());
	}

	return;

}
void 
cos_init(void *arg)
{
	printc("thd %d Tmem policy running.....\n", cos_get_thd_id());
	INIT_LIST(&threads, next, prev);

	init_spds();

#ifdef THD_POOL
	printc("<<<Thd Pool with total %d tmems, component size %d>>>\n", MAX_NUM_MEM, THD_POOL);
	if (THD_POOL != 1)
		thdpool_max_policy();
	else
		thdpool_1_policy();
#else
	printc("<<<Now using Algorithm %d, total number of tmems:%d >>>\n", ALGORITHM, MAX_NUM_MEM);
	DOUT("Tmem policy: %d in spd %ld\n", cos_get_thd_id(), cos_spd_id());
	init_policy();
#endif

	periodic_wake_create(cos_spd_id(), POLICY_PERIODICITY);

	/* Wait for all other threads to initialize */
	int i = 0, waiting = 100 / POLICY_PERIODICITY, counter = 0, report_period = 100 / POLICY_PERIODICITY;
	do {
		periodic_wake_wait(cos_spd_id());
	} while (i++ < waiting);

	init_thds();

	//unsigned long long s,e;
	while (1) {
		if (counter++ % report_period == 0) {
			/* report tmems usage */
			cbufmgr_buf_report();
			stkmgr_stack_report();
		}
		gather_data(counter % report_period);
#ifdef THD_POOL
		if (THD_POOL == 1)
			thdpool_1_policy();
		else
			thdpool_max_policy();
#else
		//rdtscll(s);
		DOUT("POLICY starts!\n");
		policy();
		DOUT("POLICY ends!\n");
		//rdtscll(e);
		//printc("SP:%llu cycles\n",e-s);
#endif
		periodic_wake_wait(cos_spd_id());
	}
	return;
}
Example #3
0
void cos_init(void *arg)
{
	static volatile int first = 0;
	union sched_param sp;
	int tcp_thd = 0;

	if (cos_get_thd_id() == event_thd) cos_net_evt_loop();

#ifdef DEBUG_PERIOD
	if (cos_get_thd_id() == debug_thd) {
		if (periodic_wake_create(cos_spd_id(), 100)) BUG();
		while(1) {
			periodic_wake_wait(cos_spd_id());
			printc("tcp evt trigger: tcp_accept_cnt %ld tcp_recv_cnt %ld net_accetp_cnt %ld\n", 
			       tcp_accept_cnt, tcp_recv_cnt, net_accetp_cnt);
			printc("tcp_tread_cnt %ld tcp_twrite_cnt %ld\n", 
			       tcp_tread_cnt, tcp_twrite_cnt);

			tcp_accept_cnt = 0;
			tcp_recv_cnt = 0;
			net_accetp_cnt = 0;

			tcp_tread_cnt = 0;
			tcp_twrite_cnt = 0;
		}
	}
#endif

	if (first == 0) {
		first = 1;

		sp.c.type = SCHEDP_PRIO;
		sp.c.value = 28;
		tcp_thd = sched_create_thd(cos_spd_id(), sp.v, 0, 0);
		printc("tcp creates a thread %d\n", tcp_thd);

#ifdef DEBUG_PERIOD
		sp.c.type = SCHEDP_PRIO;
		sp.c.value = 10;
		debug_thd = sched_create_thd(cos_spd_id(), sp.v, 0, 0);
#endif

		return;
	} else {
		printc("tcp: thread %d\n", cos_get_thd_id());
		init();
		BUG();
		prints("net: not expecting more than one bootstrap.");
	}

		
}
Example #4
0
void cos_init(void *arg)
{
	torlib_init();
	lock_static_init(&h_lock);

	if (periodic_wake_create(cos_spd_id(), HTTP_REPORT_FREQ)) BUG();
	while (1) {
		periodic_wake_wait(cos_spd_id());
		printc("HTTP conns %ld, reqs %ld\n", http_conn_cnt, http_req_cnt);
		http_conn_cnt = http_req_cnt = 0;
	}
	
	return;
}
void cos_init(void)
{
	static int first = 0;
	union sched_param sp;

	if(first == 0){
		first = 1;
		sp.c.type = SCHEDP_PRIO;
		sp.c.value = 4;
		high = sched_create_thd(cos_spd_id(), sp.v, 0, 0);
	} else {
		if (cos_get_thd_id() == high) {
			periodic_wake_create(cos_spd_id(), INJECTION_PERIOD);
			timed_event_block(cos_spd_id(), 1);
#ifdef SWIFI_ON
			// this is for each service fault coverage test
			while(1) {
				test++;
				while (test == 3) timed_event_block(cos_spd_id(), 100);
				recovery_upcall(cos_spd_id(), COS_UPCALL_SWIFI_BEFORE,
						SWIFI_SPD, 0);
				// in 1 tick, hope some thread is spinning in the target spd
				/* printc("swifi....call timed_event_block\n"); */
				timed_event_block(cos_spd_id(), 1);
				/* printc("swifi....return from timed_event_block\n"); */
				
				fault_inject(SWIFI_SPD);

				recovery_upcall(cos_spd_id(), COS_UPCALL_SWIFI_AFTER,
						SWIFI_SPD, 0);
				/* printc("swifi....call periodic_wake_wait\n"); */
				periodic_wake_wait(cos_spd_id());
				/* printc("swifi....return from periodic_wake_wait\n"); */
			}
#endif
#ifdef SWIFI_WEB
			// this is for web server fault injection only
			while(1) {
				fault_inject(target_spd[TARGET_SPD]);
				periodic_wake_wait(cos_spd_id());
			}
#endif
		}
	}
}
Example #6
0
File: netif.c Project: songjiguo/C3
void cos_init(void *arg)
{
	static volatile int first = 1;
	
	union sched_param sp;
	pnums = avg = 0;
	inc1 = inc2 = 0;

#ifdef DEBUG_PERIOD	
	unsigned long cos_immediate_process_cnt_prev = 0;

	if (cos_get_thd_id() == debug_thd) {
		if (periodic_wake_create(cos_spd_id(), 100)) BUG();
		while(1) {
			periodic_wake_wait(cos_spd_id());
			printc("num interrupt_wait %ld interrupt_process %ld\n", 
			       interrupt_wait_cnt, interrupt_process_cnt);
			interrupt_wait_cnt = 0;
			interrupt_process_cnt = 0;
			if (cos_immediate_process_cnt > 0) {
				printc("num immediate interrupt_process %ld\n", 
				       cos_immediate_process_cnt - cos_immediate_process_cnt_prev);
				cos_immediate_process_cnt_prev = cos_immediate_process_cnt;
			}

		}
	}
#endif
	
	if (first) {
		first = 0;

#ifdef DEBUG_PERIOD		
		sp.c.type = SCHEDP_PRIO;
		sp.c.value = 10;
		debug_thd = sched_create_thd(cos_spd_id(), sp.v, 0, 0);
#endif

		init();
	} else {
		prints("net: not expecting more than one bootstrap.");
	}
}
Example #7
0
void cos_init(void)
{
	static int first = 0;
	union sched_param sp;
	int i;
	
	if(first == 0){
		first = 1;

		sp.c.type = SCHEDP_PRIO;
		sp.c.value = 11;
		high = sched_create_thd(cos_spd_id(), sp.v, 0, 0);

		sp.c.type = SCHEDP_PRIO;
		sp.c.value = 12;
		low = sched_create_thd(cos_spd_id(), sp.v, 0, 0);
	} else {
		if (cos_get_thd_id() == high) {
#ifdef TEST_TE
			while(1) {
				rdtscll(start);
				timed_event_block(cos_spd_id(), 100);
				rdtscll(end);
				printc("(thd %d)time even blocked for %llu ticks\n", cos_get_thd_id(), (end-start));
			}
#endif
#ifdef TEST_PERIOD
			periodic_wake_create(cos_spd_id(), 100);
			while(1) {
				rdtscll(start);
				periodic_wake_wait(cos_spd_id());
				rdtscll(end);
				printc("time even blocked for %llu ticks\n", (end-start));
			}
#endif
		}
	}
	return;
}
Example #8
0
void 
cos_init(void)
{
	static int first = 0;
	union sched_param sp;
	int i;
	

	if(first == 0){
		first = 1;

		for (i=0; i<PAGE_NUM; i++) s_addr[i] = 0;
		for (i=0; i<PAGE_NUM; i++) d_addr[i] = 0;

		sp.c.type = SCHEDP_PRIO;
		sp.c.value = THREAD1;
		sched_create_thd(cos_spd_id(), sp.v, 0, 0);

	} else {
		timed_event_block(cos_spd_id(), 50);
		periodic_wake_create(cos_spd_id(), 1);
		i = 0;
		while(i++ < 80) { /* 80 x 10 x 4k  < 4M */
			printc("<<< MM RECOVERY TEST START (thd %d) >>>\n", cos_get_thd_id());
			get_test();
#ifdef BEST_TEST
			alias_test();
			revoke_test();
#endif

			/* all_in_one(); */

			printc("<<< MM RECOVERY TEST DONE!! >>> {%d}\n\n\n", i);
			periodic_wake_wait(cos_spd_id());
		}
	}
	
	return;
}
Example #9
0
/* periodic PID controller : read sensor data and send control data*/
static void
pid_process()
{
	ap_data in_data;
	ap_data out_data;

	if (periodic_wake_create(cos_spd_id(), PID_PERIOD)) BUG();
	while(1) {
		periodic_wake_wait(cos_spd_id());
		/* printc("PERIODIC: pid....(thd %d in spd %ld)\n",  */
		/*        cos_get_thd_id(), cos_spd_id()); */

		/* simulator ==> pid */
		if (from_data_new(&in_data)) {
			/* If there is data to process, we process and
			 * send back to simulator */
			/* pid */
			ap_control(&in_data, &out_data);			
			/* pid ==> simulator */
			to_data_new(&out_data);
		}
	}
}
Example #10
0
void cos_init(void)
{
	static int first = 0, flag = 0;
	union sched_param sp;

	if(first == 0){
		first = 1;
		sp.c.type = SCHEDP_PRIO;
		sp.c.value = 8;
		high = sched_create_thd(cos_spd_id(), sp.v, 0, 0);
	} else {
		if (cos_get_thd_id() == high) {
			periodic_wake_create(cos_spd_id(), NOISE_PERIOD);
			while(1){
				periodic_wake_wait(cos_spd_id());
				/* printc("PERIODIC: noise....(thd %d in spd %ld)\n", */
				/*        cos_get_thd_id(), cos_spd_id()); */
				sinusoid_spike();
			}
		}
	}
	
	return;
}
Example #11
0
void cos_init(void *arg)
{
	td_t t1, serv;
	long evt;
	char *params1 = "foo", *params2 = "", *d;
	int period, num, ret, sz, i, j;
	u64_t start = 0, end = 0, re_cbuf;
	cbuf_t cb1;

	union sched_param sp;
	static int first = 1;

	if (first) {
		first = 0;
		sp.c.type = SCHEDP_PRIO;
		sp.c.value = 9;
		if (sched_create_thd(cos_spd_id(), sp.v, 0, 0) == 0) BUG();
		return ;
	}
	evt = evt_split(cos_spd_id(), 0, 0);
	assert(evt > 0);
	serv = tsplit(cos_spd_id(), td_root, params1, strlen(params1), TOR_RW, evt);
	if (serv < 1) {
		printc("UNIT TEST FAILED: split1 failed %d\n", serv); 
	}
	evt_wait(cos_spd_id(), evt);
	printc("client split successfully\n");
	sz = 4096;
	j = 1000*ITER;
	rdtscll(start);
	for (i=1; i<=j; i++) {
		if (i == j)    rdtscll(end);
		d = cbuf_alloc(sz, &cb1);
		if (!d) goto done;
		cbuf_send(cb1);
		rdtscll(end);
		((u64_t *)d)[0] = end;
		ret = twritep(cos_spd_id(), serv, cb1, sz);
		cbuf_free(cb1); 
	}
	printc("Client snd %d times %llu\n", j-1, (end-start)/(j-1));
	/* 
	 * insert evt_grp_wait(...) into the code below where it makes
	 * sense to.  Simulate if the code were executing in separate
	 * threads.
	 */
	parse_args(&period, &num);
	periodic_wake_create(cos_spd_id(), period);
	re_cbuf = 0;
	for (i=1; i<=ITER; i++) {
		for (j=0; j<num; j++) {
			rdtscll(start);
			d = cbuf_alloc(i*sz, &cb1);
			if (!d) goto done;
			cbuf_send_free(cb1);
			rdtscll(end);
			re_cbuf = re_cbuf+(end-start);
			rdtscll(end);
			((u64_t *)d)[0] = end;
			ret = twritep(cos_spd_id(), serv, cb1, i*sz);
		}
		periodic_wake_wait(cos_spd_id());
	}
	printc("Client: Period %d Num %d Cbuf %llu\n", period, num, re_cbuf/(num*ITER));
done:
	trelease(cos_spd_id(), serv);
	printc("client UNIT TEST PASSED: split->release\n");

	printc("client UNIT TEST ALL PASSED\n");
	return;
}
void cos_init(void *arg)
{

	int start_time_in_ticks = 0;
	int duration_time_in_ticks = 0;

	int local_period = 0;

	static int first = 1;

//	static int pre_run = 0;

	if (first) {
		union sched_param sp;
		int i;
		first = 0;
		parse_initstr();
		assert(priority);
		sp.c.type = SCHEDP_PRIO;
		sp.c.value = priority;

		if (sched_create_thd(cos_spd_id(), sp.v, 0, 0) == 0) BUG();
		if (priority == 30) { //best effort thds
			printc("thd num %d\n",thd_num);
				for (i=0; i<(thd_num-1); i++)
				sched_create_thd(cos_spd_id(), sp.v, 0, 0);
		}
		return;
	}

	local_period = period;

	unsigned long cyc_per_tick;
	cyc_per_tick = sched_cyc_per_tick();

	unsigned long exe_cycle;
	exe_cycle = cyc_per_tick/US_PER_TICK;
	exe_cycle = exe_cycle*exe_t;

	start_time_in_ticks = start_time*100;
	duration_time_in_ticks = duration_time*100;

	printc("In spd %ld Thd %d, period %d ticks, execution time %d us in %lu cycles\n", cos_spd_id(),cos_get_thd_id(), local_period, exe_t, exe_cycle);

	/* int event_thd = 0; */
	/* unsigned long pre_t_0 = 0; */
	if (local_period <= 0){/* Create all non-periodic tasks */

#ifdef BEST_EFF   // for best effort sys now
		int i;
		if (first == 0){
//			for (i= 0;i<5;i++) create_thd("r0");
			pre_t_0 = sched_timestamp();
			first = 1;
		}

		printc("<<<<1 thd %d in spd %ld\n",cos_get_thd_id(), cos_spd_id());
		event_thd = cos_get_thd_id();

		for (i = 0 ; i < 100; i++){
			left(200000,200000,0,0);
		}

		unsigned long pre_run_remained = 0;
		unsigned long numm = 10000*cyc_per_tick/US_PER_TICK;;
		while(1) {
			for (i = 0 ; i < 10; i++){
				pre_run_remained = numm;  /* refill */
				pre_run_remained = left(20000,20000,0,0);
				/* printc(" thd %d pre_t_0 %u pre_t %lu\n", cos_get_thd_id(), pre_t_0, pre_t); */
			}
			unsigned long pre_t = sched_timestamp();
			if ( pre_t > pre_t_0 + 1*100) break;
		}
		printc("BF thd %d finish pre_run\n", cos_get_thd_id());

#endif
		/* pub_duration_time_in_ticks = duration_time_in_ticks; */
		timed_event_block(cos_spd_id(), start_time_in_ticks);
		printc("<<<<2 thd %d in spd %ld\n",cos_get_thd_id(), cos_spd_id());
	}
	else {/* Create all periodic tasks */
		if (local_period == 0 || (exe_t > local_period*US_PER_TICK)) BUG();
		/* if (cos_get_thd_id() == 20) { */
		/* 	printc("pre allocating ...\n"); */
		/* 	int mm; */
		/* 	for (mm = 0 ; mm < 3000; mm++) */
		/* 		left(70000, 70000, 0, 0); */
		/* 	printc("done.\n"); */
		/* } */
		periodic_wake_create(cos_spd_id(), local_period);

		int i = 0;
		int waiting = 0;

		if(start_time_in_ticks <= 0)
			/* waiting = (50+100*10) / local_period;   /\* use 50 before. Now change to let BF threads run first 10 seconds before 0 second *\/ */
			waiting = (50) / local_period;   /* use 50 before. Now change to let BF threads run first 10 seconds before 0 second */
		else
			waiting = start_time_in_ticks / local_period;
		do {
			periodic_wake_wait(cos_spd_id());
		} while (i++ < waiting); /* wait 50 ticks */
	}

/* Let all tasks run */
	unsigned long exe_cyc_remained = 0;
//	unsigned long long t;
//	unsigned long val;
	int refill_number = 0;

	unsigned long exe_cyc_event_remained = 0;
//	printc("start...!!\n");
	while (1) {
		if(local_period <= 0){			/* used for transient non-periodic tasks only */
			exe_cyc_event_remained = exe_cycle;  /* refill */
			while(1) {
				exe_cyc_event_remained = exe_cycle;  /* refill */
				/* rdtscll(t); */
				/* val = (int)(t & (TOTAL_AMNT-1)); */
				/* if (val >= 64){ */
					exe_cyc_event_remained = left(exe_cyc_event_remained,exe_cycle,0,0);
				/* } */
				/* else{ */
				/* 	exe_cyc_event_remained = right(exe_cyc_event_remained,exe_cycle,0,0); */
				/* } */
				unsigned long t = sched_timestamp();
				/* if ( t > (unsigned long)(7*100 + start_time_in_ticks + duration_time_in_ticks)) { */
				/* 	printc("thd %d left!!!\n",cos_get_thd_id()); */
				if ( t > (unsigned long)( start_time_in_ticks + duration_time_in_ticks)) {
					/* printc("thd %d left>>>\n",cos_get_thd_id()); */

					timed_event_block(cos_spd_id(), 10000);
				}
			}
		}
		else{
			/* rdtscll(start); */
			/* used for transient periodic tasks only */
			if (start_time_in_ticks > 0 && (local_period*refill_number > duration_time_in_ticks)){
				for(;;) periodic_wake_wait(cos_spd_id());
			}
			exe_cyc_remained = exe_cycle;  /* refill */
			/* printc("thd %d in home comp, going to call\n",cos_get_thd_id()); */
			while(exe_cyc_remained) {
				exe_cyc_remained = left(exe_cyc_remained,exe_cycle,0,0);	  
			}
			
			/* rdtscll(end); */
			/* printc("%d, times : %d\n", cos_get_thd_id(), times); */
			/* printc("\n @@thd %ld is sleeping in spd %d\n", cos_get_thd_id(), cos_spd_id()); */
			/* printc("thd %d back in home comp, going to block\n",cos_get_thd_id()); */
			periodic_wake_wait(cos_spd_id());
			/* printc("thd %d woke up.\n",cos_get_thd_id()); */
			refill_number++;	  
			/* printc("\n @@thd %ld is waking in spd %d\n", cos_get_thd_id(), cos_spd_id()); */
			/* printc("\n thd %d refilled...%d\n", cos_get_thd_id(), refill_number); */
		}
	}
	return;
}
Example #13
0
void 
cos_init(void)
{
	static int first = 0;
	union sched_param sp;
	int i, j, k;
	
	if(first == 0){
		first = 1;

		sp.c.type = SCHEDP_PRIO;
		sp.c.value = 10;
		warm = sched_create_thd(cos_spd_id(), sp.v, 0, 0);

		sp.c.type = SCHEDP_PRIO;
		sp.c.value = 11;
		high = sched_create_thd(cos_spd_id(), sp.v, 0, 0);
		printc("<<<high thd %d>>>\n", high);

		sp.c.type = SCHEDP_PRIO;
		sp.c.value = 15;
		med = sched_create_thd(cos_spd_id(), sp.v, 0, 0);
		printc("<<<med thd %d>>>\n", med);

		sp.c.type = SCHEDP_PRIO;
		sp.c.value = 20;
		low = sched_create_thd(cos_spd_id(), sp.v, 0, 0);
		printc("<<<low thd %d>>>\n", low);

	} else {
/**************************************/
/**************************************/
/**************************************/
/********  PI Overrun Fault*********/
#if defined MON_PI_OVERRUN 
		if (cos_get_thd_id() == high) {
			printc("<<<high thd %d>>>\n", cos_get_thd_id());
			periodic_wake_create(cos_spd_id(), 5);
			timed_event_block(cos_spd_id(), 3);
			try_cs_hp();
		}
		/* if (cos_get_thd_id() == med) { */
		/* 	printc("<<<med thd %d>>>\n", cos_get_thd_id()); */
		/* 	periodic_wake_create(cos_spd_id(), 8); */
		/* 	timed_event_block(cos_spd_id(), 6); */
		/* 	try_cs_mp(); */
		/* } */

		if (cos_get_thd_id() == low) {
			printc("<<<low thd %d>>>\n", cos_get_thd_id());
			periodic_wake_create(cos_spd_id(), 13);
			try_cs_lp();
		}
/********  PI Scheduling Fault *********/
#elif defined MON_PI_SCHEDULING
		/* if (cos_get_thd_id() == warm) { */
		/* 	printc("<<<worm thd %d (highest prio)>>>\n", cos_get_thd_id()); */
		/* 	sched_block(cos_spd_id(), 0); */
		/* 	printc("<<<worm thd %d is back...>>>\n", cos_get_thd_id()); */
		/* 	while(1); */
		/* } */
		if (cos_get_thd_id() == high) {
			printc("<<<high thd %d>>>\n", cos_get_thd_id());
			periodic_wake_create(cos_spd_id(), 5);
			timed_event_block(cos_spd_id(), 10);
			try_cs_hp();
		}
		if (cos_get_thd_id() == med) {
			printc("<<<med thd %d>>>\n", cos_get_thd_id());
			periodic_wake_create(cos_spd_id(), 8);
			timed_event_block(cos_spd_id(), 6);
			try_cs_mp();
		}

		if (cos_get_thd_id() == low) {
			printc("<<<low thd %d>>>\n", cos_get_thd_id());
			periodic_wake_create(cos_spd_id(), 13);
			try_cs_lp();
		}
/********  Deadlock Fault*********/
#elif defined MON_DEADLOCK
		if (cos_get_thd_id() == high) {
			printc("<<<high thd %d>>>\n", cos_get_thd_id());
			printc("\n[[[[ MON_DEADLOCK Test....]]]]\n");
			periodic_wake_create(cos_spd_id(), 5);
			timed_event_block(cos_spd_id(), 3);
			try_cs_hp();
		}
		if (cos_get_thd_id() == med) {
			printc("<<<med thd %d>>>\n", cos_get_thd_id());
			periodic_wake_create(cos_spd_id(), 8);
			timed_event_block(cos_spd_id(), 1);
			try_cs_mp();
		}
		if (cos_get_thd_id() == low) {
			printc("<<<low thd %d>>>\n", cos_get_thd_id());
			periodic_wake_create(cos_spd_id(), 13);
			try_cs_lp();
		}
/********  Overrun in Scheduler *********/
#elif defined MON_SCHED  // 2 threads, bloc/wakeup N time, random delay in sched
		printc("thread %d is in MON_SCHED_DELAY\n", cos_get_thd_id());
		if (cos_get_thd_id() == high) {
			printc("<<<high thd %d>>>\n", cos_get_thd_id());
			periodic_wake_create(cos_spd_id(), 5);
			try_cs_hp();
		}
		if (cos_get_thd_id() == low) {
			printc("<<<low thd %d>>>\n", cos_get_thd_id());
			periodic_wake_create(cos_spd_id(), 13);
			try_cs_lp();
		}
/********  Overrun in MM *********/
#elif defined MON_MM  // 1 threads, do alloc/alias/revoke
		if (cos_get_thd_id() == high) {
			periodic_wake_create(cos_spd_id(), 5);
			printc("thread %d is in MON_MM\n", cos_get_thd_id());
			try_cs_hp();
		}
#elif defined MON_CAS_TEST
		printc("thread %d is in MON_CAS_TEST\n", cos_get_thd_id());
		if (cos_get_thd_id() == high) {
			timed_event_block(cos_spd_id(), 6);
			printc("<<<high thd %d>>>\n", cos_get_thd_id());
			test_iploop();
			return;
		}
#elif defined MON_PPONG
		if (cos_get_thd_id() == high) {
			printc("<<<high thd %d --- PPONG>>>\n", cos_get_thd_id());
			int i = 0;
			unsigned long long start_pp, end_pp;
			
			while(i++ < RUNITER) {
				rdtscll(start_pp);
				try_cs_hp();
				rdtscll(end_pp);
				printc("one invocation in cmon is %llu\n", end_pp-start_pp);
			}
		}
#elif defined MON_FPU
		if (cos_get_thd_id() == high) {
			printc("\n\n<<<high thd %d --- FPU>>>\n\n", cos_get_thd_id());
			try_cs_hp();
		}
#endif		
	}

	return;
}