Пример #1
0
// Event Worker Thread
// Processes ESIF Events
void *esif_event_worker_thread(void *ptr)
{
	int rc = 0;
	fd_set rfds = {0};
	struct timeval tv = {0};

	UNREFERENCED_PARAMETER(ptr);
	ESIF_TRACE_ENTRY_INFO();
	CMD_OUT("Start ESIF Event Thread\n");

	// Connect To Kernel IPC with infinite timeout
	ipc_autoconnect(0);

	// Run Until Told To Quit
	while (!g_quit) {
#ifdef ESIF_FEAT_OPT_ACTION_SYSFS
		esif_ccb_sleep_msec(250);
#else
		if (g_ipc_handle == ESIF_INVALID_HANDLE) {
			break;
		}
		if (rc > 0) {
			EsifEvent_GetAndSignalIpcEvent();
		}
		FD_ZERO(&rfds);
		FD_SET((esif_ccb_socket_t)g_ipc_handle, &rfds);
		tv.tv_sec  = 0;
		tv.tv_usec = 50000;	/* 50 msec */

#ifdef ESIF_ATTR_OS_LINUX
		rc = select(g_ipc_handle + 1, &rfds, NULL, NULL, &tv);
#endif
		
#ifdef ESIF_ATTR_OS_WINDOWS
		// Windows does not support select/poll so we simulate here
		esif_ccb_sleep_msec(50);
		rc = 1;
#endif
		
#endif
	}

	if (g_ipc_handle != ESIF_INVALID_HANDLE) {
		ipc_disconnect();
	}

	ESIF_TRACE_EXIT_INFO();
	return 0;
}
Пример #2
0
static void EsifDataLogSchedule(const void *ctx)
{
	eEsifError rc = ESIF_OK;

	UNREFERENCED_PARAMETER(ctx);

	if (dataLogContextPtr == NULL) {
		ESIF_TRACE_DEBUG("Data logging schedule fired had no context.\n");
		goto exit;
	}

	if (dataLogContextPtr->dataLogScheduleTimer == NULL) {
		ESIF_TRACE_DEBUG("Data logging schedule fired but had no reference to the members.\n");
		goto exit;
	}

	/*
	* Serialize access to the datalog state.
	*/
	while (atomic_set(&g_dataLogLock, ESIF_TRUE)) {
		esif_ccb_sleep_msec(ESIF_DATALOG_LOCK_SLEEP_MS);
	}

	if (EsifDataIsLogStarted()){
		ESIF_TRACE_DEBUG("Data logging schedule fired but was already started.\n");
		goto exit;
	}

	rc = EsifDataLogValidateParticipantList(dataLogContextPtr->dataLogParticipantList);
	if (rc != ESIF_OK) {
		ESIF_TRACE_ERROR("There was a problem with your participant list. You may have selected invalid participants, or too many participants. \n");
		goto exit;
	}
	rc = EsifDataLogOpenLogFile();
	if (rc != ESIF_OK) {
		ESIF_TRACE_ERROR("Error opening scheduled log file... \n");
		goto exit;
	}
	ESIF_TRACE_DEBUG("Data logging starting... \n");
	g_dataLogInterval = dataLogContextPtr->dataLogInterval;
	EsifDataLogStart();

exit:
	EsifDataLogCleanup();
	atomic_set(&g_dataLogLock, ESIF_FALSE);
}
Пример #3
0
//
// PUBLIC INTERFACE---------------------------------------------------------------------
//
char *EsifShellCmdDataLog(EsifShellCmdPtr shell)
{
	eEsifError rc = ESIF_OK;
	int argc = shell->argc;
	char **argv = shell->argv;
	char *output = shell->outbuf;
	char participantList[MAX_LOG_LINE] = { 0 };

	/*
	 * Serialize access to the datalog state.
	 */
	while (atomic_set(&g_dataLogLock, ESIF_TRUE)) {
		esif_ccb_sleep_msec(ESIF_DATALOG_LOCK_SLEEP_MS);
	}

	if (argc < 2) {
		esif_ccb_sprintf(OUT_BUF_LEN, output, "Data logging is: %s\n", (EsifDataIsLogStarted() ? "started" : "stopped"));
	}
	else if (esif_ccb_stricmp(argv[1], "start") == 0) {

		if (EsifDataIsLogStarted()){
			esif_ccb_sprintf(OUT_BUF_LEN, output, "Data logging is already started.\n");
			goto exit;
		}

		g_dataLogInterval = DEFAULT_STATUS_LOG_INTERVAL;
		if (argc > 2) {
			if ((int)esif_atoi(argv[2]) >= MIN_STATUS_LOG_INTERVAL) {
				g_dataLogInterval = (esif_ccb_time_t)esif_atoi(argv[2]);
			}
			else {
				esif_ccb_sprintf(OUT_BUF_LEN, output, "Invalid sampling period specified (minimum is %d ms).\n", MIN_STATUS_LOG_INTERVAL);
				goto exit;
			}
		}
		if (argc > 3) {
			esif_ccb_sprintf(sizeof(participantList), participantList, "%s", argv[3]);
		}

		rc = EsifDataLogValidateParticipantList(participantList);
		if (rc != ESIF_OK) {
			esif_ccb_sprintf(OUT_BUF_LEN, output, "There was a problem with your participant list. You may have selected invalid participants, or too many participants. \n");
			goto exit;
		}
		rc = EsifDataLogOpenLogFile();
		if (rc != ESIF_OK) {
			esif_ccb_sprintf(OUT_BUF_LEN, output, "Error opening log file... \n");
			goto exit;
		}
		esif_ccb_sprintf(OUT_BUF_LEN, output, "Data logging starting... \n");

		EsifDataLogStart();
	}
	else if (esif_ccb_stricmp(argv[1], "schedule") == 0) {
		UInt32 startTime = 1000;

		/* initialize */
		if (dataLogContextPtr == NULL) {
			dataLogContextPtr = (struct dataLogContext *)esif_ccb_malloc(sizeof(struct dataLogContext));
			if (dataLogContextPtr == NULL) {
				rc = ESIF_E_NO_MEMORY;
				goto exit;
			}
			dataLogContextPtr->dataLogScheduleTimer = (esif_ccb_timer_t *) esif_ccb_malloc(sizeof(esif_ccb_timer_t));
			if (dataLogContextPtr->dataLogScheduleTimer == NULL) {
				rc = ESIF_E_NO_MEMORY;
				goto exit;
			}
			dataLogContextPtr->dataLogParticipantList = NULL;
		}

		dataLogContextPtr->dataLogInterval = DEFAULT_STATUS_LOG_INTERVAL;
		/* start time (in ms from now) */
		if (argc > 2) {
			if ((int) esif_atoi(argv[2]) >= MIN_STATUS_LOG_SCHEDULE) {
				startTime = (esif_ccb_time_t) esif_atoi(argv[2]);
			}
			else {
				esif_ccb_sprintf(OUT_BUF_LEN, output, "Invalid schedule time specified (minimum is %d ms).\n", MIN_STATUS_LOG_INTERVAL);
				goto exit;
			}
		}
		/* log interval */
		if (argc > 3) {
			if ((int) esif_atoi(argv[3]) >= MIN_STATUS_LOG_INTERVAL) {
				dataLogContextPtr->dataLogInterval = (esif_ccb_time_t) esif_atoi(argv[3]);
			}
			else {
				esif_ccb_sprintf(OUT_BUF_LEN, output, "Invalid sampling period specified (minimum is %d ms).\n", MIN_STATUS_LOG_INTERVAL);
				goto exit;
			}
		}
		if (argc > 4) {
			dataLogContextPtr->dataLogParticipantList = esif_ccb_strdup(argv[4]);
			if (dataLogContextPtr->dataLogParticipantList == NULL) {
				rc = ESIF_E_NO_MEMORY;
				goto exit;
			}
		}

		rc = esif_ccb_timer_init(dataLogContextPtr->dataLogScheduleTimer, (esif_ccb_timer_cb) EsifDataLogSchedule, NULL);
		if (ESIF_OK != rc) {
			esif_ccb_sprintf(OUT_BUF_LEN, output, "Error starting timer... \n");
			goto exit;
		}
		rc = esif_ccb_timer_set_msec(dataLogContextPtr->dataLogScheduleTimer, startTime);
		esif_ccb_sprintf(OUT_BUF_LEN, output, "Data logging scheduled for start in %d ms at an interval of %d... \n", startTime, dataLogContextPtr->dataLogInterval);
		
	}
	else if (esif_ccb_stricmp(argv[1], "stop") == 0) {
		EsifDataLogStop();
		esif_ccb_sprintf(OUT_BUF_LEN, output, "Data logging stopped...\n");
		g_dataLogActive = ESIF_FALSE;
	}
	else {
		esif_ccb_sprintf(OUT_BUF_LEN, output, "Invalid parameter specified\n");
	}
exit:
	atomic_set(&g_dataLogLock, ESIF_FALSE);
	return output;
}
Пример #4
0
PowerStatus DomainPowerStatus_001::getPowerStatus(UIntN participantIndex, UIntN domainIndex)
{
    getPower(domainIndex);
    esif_ccb_sleep_msec(250);
    return PowerStatus(getPower(domainIndex));
}