コード例 #1
0
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;
}
コード例 #2
0
ファイル: p7r_stack_hint.c プロジェクト: Akvelog/servcraft
struct p7r_stack_hint *p7r_stack_hint_init_by_entrance(struct p7r_stack_hint *hint, void (*entrance)(void *), const struct p7r_stack_hint_config *config) {
    (hint->key.solid_entrance = entrance), (hint->key.name = NULL);
    init_policy(hint);
    config_as_base_of(hint, config);
    return hint;
}
コード例 #3
0
ファイル: p7r_stack_hint.c プロジェクト: Akvelog/servcraft
struct p7r_stack_hint *p7r_stack_hint_init_by_name(struct p7r_stack_hint *hint, const char *name, const struct p7r_stack_hint_config *config) {
    (hint->key.solid_entrance = NULL), (hint->key.name = name);
    init_policy(hint);
    config_as_base_of(hint, config);
    return hint;
}