Ejemplo n.º 1
0
void get_fans_present(am_node_t *cm)
{
	jipmi_msg_t req = { {0} };

	am_node_t *tz = node_lookup(cm, TZONE_NODE);
	tzone_data_t *tz_data = (tzone_data_t *)tz->priv_data;
	cm_data_t *cm_data = (cm_data_t *)cm->priv_data;
	func_tbl_t func = fn_tbl[cm_data->func_idx];

	if (func_not_ready(tz, tz_data->get_fans_present, func.once))
		goto next;

	FILL_INT(req.netfn,		IPMI_CM_NETFN);
	FILL_INT(req.cmd,		FAN_PRESENCE_CMD);
	FILL_STR(req.name,		am_rmcp_username);
	FILL_STR(req.password,	am_rmcp_password);
	FILL_INT(req.data_len,	0);

	tz_data->get_fans_present.expire = get_current_tick() + func.timeout;
	libjipmi_rmcp_cmd(cm_data->ip_address, IPMI_RMCP_PORT, &req, func.callback, tz, JIPMI_NON_SYNC);
	return;

next:
	process_next_func(cm);
	return;
}
Ejemplo n.º 2
0
Stats *
add_new_stats(username_t username, Stats * st, long long tick_id) {
	User_stats *us = (User_stats *) g_hash_table_lookup(users, username);
    struct governor_config data_cfg;
    get_config_data( &data_cfg );
	//pthread_mutex_lock(&mtx_account);
	if (!us) {
		us = add_user_stats(username, accounts, users);
	}

	if(data_cfg.debug_user && !us->account->need_dbg){
		int len = strlen(data_cfg.debug_user);
		if(!strncmp(data_cfg.debug_user, us->account->id, len)){
			us->account->need_dbg = 1;
		}
	}
	/*if(check_if_user_restricted(username, accounts) && data_cfg.use_lve){
		return NULL;
	}*/
	Stats *stt = NULL;
	if(us){
		if (us->tick == tick_id){
			stt = refresh_stats(st, us);
		} else {
			us->tick = get_current_tick();
			stt = push_stats(st, us);
		}
	}
	//pthread_mutex_unlock(&mtx_account);
	return stt;
}
Ejemplo n.º 3
0
void set_tzone_pwm(am_node_t *cm)
{
	jipmi_msg_t req = { {0} };
	am_node_t *tzone = node_lookup(cm, TZONE_NODE);
	tzone_data_t *tzone_data = (tzone_data_t *)tzone->priv_data;
	cm_data_t *cm_data = (cm_data_t *)cm->priv_data;
	func_tbl_t func = fn_tbl[cm_data->func_idx];
	int32 tz_num = 1;

	if (func_not_ready(tzone, tzone_data->set_tzone_pwm, func.once))
		goto next;

	if (update_pwm_ready(tzone_data) == false)
		goto next;

	FILL_INT(req.netfn,		IPMI_CM_NETFN);
	FILL_INT(req.cmd,		SET_DEFAULT_PWM_CMD);
	FILL_STR(req.name,		am_rmcp_username);
	FILL_STR(req.password,	am_rmcp_password);
	FILL_INT(req.data_len,	2);
	req.data[0] = 0xff;
	req.data[1] = tzone_data->pwm[tz_num - 1];

	rmm_log(DBG, "set pwm is %d\n", tzone_data->pwm[0]);

	tzone_data->set_tzone_pwm.expire = get_current_tick() + func.timeout;
	libjipmi_rmcp_cmd(cm_data->ip_address, IPMI_RMCP_PORT, &req, func.callback, tzone, JIPMI_NON_SYNC);
	return;

next:
	process_next_func(cm);
	return;
}
Ejemplo n.º 4
0
void tick_empty_users(gpointer key, User_stats * us, void *data) {
	if (is_new_tick(us->tick)) {
		us->tick = get_current_tick();
		Stats stats_holder;
		reset_stats(&stats_holder);
		push_stats(&stats_holder, us);
	}
}
Ejemplo n.º 5
0
static int32 update_pwm_ready(tzone_data_t *tzone_data)
{
	int64 curr_tick = get_current_tick();

	if (tzone_data->update_tzone_pwm.expire <= curr_tick) {
		tzone_data->update_tzone_pwm.expire = curr_tick + 10000;
		return true;
	}

	return false;
}
Ejemplo n.º 6
0
static void print_uci_info(app_t *app, int depth, int score)
{
	ms_time_t tm;
	u64 i, s;

	get_current_tick(&tm);
	i = get_interval(&app->search.start, &tm);
	s = i / 1000;

	printf("info depth %d score cp %d time %lld nodes %lld nps %lld pv ",
		depth, score,
		i, app->search.nodes,
		/* we are calculating average nps here - to calculate true nps we should
		   only consider the nodes searched and time interval for this depth */
		(s != 0 ? app->search.nodes / s : app->search.nodes));
	print_pv(app, depth);
	printf("\n");
}
Ejemplo n.º 7
0
void add_user_stats_from_counter(gpointer key, Stat_counters * item, gpointer user_data){
	Stats st;
	send_to_glib_info *internal_info = (send_to_glib_info *)user_data;
	double *in_tm = (double *)&internal_info->tm;
	clac_stats_difference_inner_from_counter((long long)item->s.cpu, item->s.read, item->s.write, item->tm, &st, *in_tm);
	if(internal_info->dbg){
		int len = strlen(internal_info->dbg);
		if(!strncmp(internal_info->dbg, (char *)key, len)){
			char output_buffer[_DBGOVERNOR_BUFFER_2048];
			WRITE_LOG(
					NULL,
					1,
					output_buffer,
					_DBGOVERNOR_BUFFER_2048,
					" step 1: counters c %f, r %llu, w %llu, tm %f",
					internal_info->log_mode,
					item->s.cpu, item->s.read, item->s.write, (*in_tm - item->tm));
		}
	}
	add_new_stats((char *)key, &st, get_current_tick());
	reset_counters((char *)key);
}
Ejemplo n.º 8
0
/**
 * The search is controlled by the think() function.  This function initializes
 * all variables needed for search, sets up thread pools, and then performs a
 * search starting at the root node.  A root node search is fundamentally
 * different from searches at other depths because we know for sure that we
 * should not perform a qsearch or a null-move search.
 */
void think(app_t *app)
{
	int i, val;
	node_t root;

	assert(app);
	assert(app->game.board);

	init_node(&root);
	root.flags |= NODE_ROOT;

	/* reset our node count board->ply */
	app->game.board->ply = 0;
	app->search.nodes = 0;
	app->hash.generations++;

	/* clear the stop bit */
	app->search.flags &= ~SEARCH_STOPPED;

	/* clear search heuristics */
	memset(app->search.pv, 0, SEARCH_MAXDEPTH * sizeof(move_t));
	memset(app->game.board->killers, 0, 2 * SEARCH_MAXDEPTH * sizeof(int));
	memset(app->game.board->history, 0, 2 * 6 * 64 * sizeof(int));

	/* set the start time */
	get_current_tick(&app->search.start);

	/* iterative deepening */
	for (i = 1; i < app->search.depth; i++) {
		root.depth = i;

		val = alpha_beta(app, &root, -MATE, MATE, i);

		if (app->mode == IUCI) {
			print_uci_info(app, i, val);
		}
	}
}
Ejemplo n.º 9
0
void get_fans_speed(am_node_t *cm)
{
	jipmi_msg_t req = { {0} };
	am_node_t *fans = node_lookup(cm, FANS_NODE);
	fans_data_t *fans_data = (fans_data_t *)fans->priv_data;
	cm_data_t *cm_data = (cm_data_t *)cm->priv_data;
	func_tbl_t func = fn_tbl[cm_data->func_idx];

	if (func_not_ready(fans, fans_data->get_fans_speed, func.once))
		goto next;

	FILL_INT(req.netfn,		IPMI_CM_NETFN);
	FILL_INT(req.cmd,		FAN_TACH_METER_CMD);
	FILL_STR(req.name,		am_rmcp_username);
	FILL_STR(req.password,	am_rmcp_password);
	FILL_INT(req.data_len,	0);
	fans_data->get_fans_speed.expire = get_current_tick() + func.timeout;
	libjipmi_rmcp_cmd(cm_data->ip_address, IPMI_RMCP_PORT, &req, func.callback, fans, JIPMI_NON_SYNC);
	return;

next:
	process_next_func(cm);
	return;
}
Ejemplo n.º 10
0
unsigned long get_timer_masked(void)
{
	return tick_to_time(get_current_tick());
}