EFI_STATUS EFIAPI CpuUpdateDataHub(EFI_BOOT_SERVICES * bs, UINT64 FSBFrequency, UINT64 TSCFrequency, UINT64 CPUFrequency) { EFI_STATUS Status; EFI_DATA_HUB_PROTOCOL *DataHub; MAGIC_HUB_DATA *MagicData; // // Locate DataHub protocol. // Status = bs->LocateProtocol (&gEfiDataHubProtocolGuid, NULL, (VOID**)&DataHub); if (EFI_ERROR (Status)) { return Status; } MagicData = (MAGIC_HUB_DATA*)AllocatePool (0x200); if (MagicData == NULL) { return EFI_OUT_OF_RESOURCES; } // Log data in format some OSes like LogData(DataHub, MagicData, L"FSBFrequency", &FSBFrequency, sizeof(FSBFrequency)); // do that twice, as last variable read not really accounted for LogData(DataHub, MagicData, L"FSBFrequency", &FSBFrequency, sizeof(FSBFrequency)); LogData(DataHub, MagicData, L"TSCFrequency", &TSCFrequency, sizeof(TSCFrequency)); LogData(DataHub, MagicData, L"CPUFrequency", &CPUFrequency, sizeof(CPUFrequency)); FreePool (MagicData); return EFI_SUCCESS; }
void udp_log(SOCKET s, char *p, char *p2, int bytes, struct sockaddr_in *to, unsigned char *pszData, char *pSign) { return; //------------------------------------------------------------------------ struct sockaddr_in sa; char buff[512]; int size; DWORD dwError; USHORT uLocalPort; dwError = GetLastError(); if(bytes<0) bytes = 0; memset(buff, 0, sizeof(buff)); size = sizeof(sa); getsockname(s, (struct sockaddr *)&sa, &size); uLocalPort = ntohs(sa.sin_port); sprintf(buff, "%s %s:%d %s ",pSign, inet_ntoa(sa.sin_addr), uLocalPort, p2); if(bytes<0) bytes = 0; sprintf(&buff[strlen(buff)], "%s:%d %d bytes (%s)", inet_ntoa(to->sin_addr), ntohs(to->sin_port), bytes, p); LogData(buff, uLocalPort, pszData, bytes); SetLastError(dwError); }
EXPORT_C void CImMobilityLogger::LogDataOut(TInt /*aFilePos*/, const TDesC8& /*aText*/) #endif //__IM_MOBILITY_LOGGING { #ifdef __IM_MOBILITY_LOGGING LogData(aFilePos, aText, KTxtFormatDataOut); #endif //__IM_MOBILITY_LOGGING }
//-------------------------------------------------- // main entry //-------------------------------------------------- int main(int argc, char * argv[]) { FILE* fLogFile; int iCount; int status ; int* piStatus; CMD tCmd; //----------------------------------------- // read or create new conf file status = configfile_Read(CONF_FILE, &tAlarmCenter); if (status == -1) { configfile_CreateDefault(&tAlarmCenter); printf("created new conf file\n"); (void)configfile_Read(CONF_FILE, &tAlarmCenter); } //----------------------------------------- //----------------------------------------- // create semaphore sem_init(&mutex_CmdBlock, 0, 1); //----------------------------------------- // -------------------------------------------------------- // run the command thread (TCP/IP) printf(" starting thread cmd ... "); if (pthread_create(&threadCmd, NULL, CommandThread, NULL)) { fprintf(stderr, "pthread: pthread_create() failed.\n"); } // -------------------------------------------------------- //----------------------------------------- // open Logfile fLogFile = fopen(LOG_FILE, "a"); //----------------------------------------- //-------------------------------------- // - configure the GPIOs to use the board // - start display thread dispsw_Start(); //-------------------------------------- dispsw_vSetMenuValue(1, tAlarmCenter.iOnOff); dispsw_vSetMenuValue(2, tAlarmCenter.iAlarmTime); dispsw_vSetMenuValue(3, tAlarmCenter.iAlarmMode); dispsw_vSetMenuValue(4, tAlarmCenter.iAlarmSchwelle2); dispsw_vSetMenuValue(5, tAlarmCenter.iWarningTime); dispsw_vSetMenuValue(6, tAlarmCenter.iWarningMode); dispsw_vSetMenuValue(7, tAlarmCenter.iAlarmSchwelle1); dispsw_vSetMenuValue(8, tAlarmCenter.iOnDelay); dispsw_vSetMenuValue(9, tAlarmCenter.iAlarmDelay); dispsw_vSetMenuValue(10, tAlarmCenter.iWarningDelay); dispsw_vSetMenuValue(20, tAlarmCenter.iStartHour); dispsw_vSetMenuValue(21, tAlarmCenter.iStopHour); tAlarmCenter.iState = 0; pinMode(A1, OUTPUT); pinMode(A2, OUTPUT); pinMode(A3, OUTPUT); digitalWrite(A1, 0); digitalWrite(A2, 0); digitalWrite(A3, 0); // -------------------------------------------------------- // welcome to the machine while(tAlarmCenter.iExit == 0) { //------------------------------ // Commando Verarbeitung sem_wait(&mutex_CmdBlock); if(tAlarmCenter.iCmd == 1) { getcmd(CmdBuffer, &tCmd); LogData(fLogFile, &tCmd); tAlarmCenter.iCmd = 0; if (strcmp(tCmd.acBuf2, "ALARM") == 0) tAlarmCenter.iAlarms++; if (strcmp(tCmd.acBuf2, "EXIT") == 0) tAlarmCenter.iExit = 1; if (tAlarmCenter.iAlarms > 1000) tAlarmCenter.iAlarms = 1000; } sem_post(&mutex_CmdBlock); //------------------------------ iCount++; //------------------------------ // Alarm funktion if (iCount % 20 == 0) // 1.0 second { AlarmFkt(&tAlarmCenter); printf("OnOff=%d A-Time=%d A-Mode=%d A-Schwelle=%d W-Time=%d W-Mode=%d W-Schwelle=%d A3A2A1=%d%d%d #=%d state=%d port=%d\n", tAlarmCenter.iOnOff, tAlarmCenter.iAlarmTime, tAlarmCenter.iAlarmMode, tAlarmCenter.iAlarmSchwelle2, tAlarmCenter.iWarningTime, tAlarmCenter.iWarningMode, tAlarmCenter.iAlarmSchwelle1, digitalRead(A3), digitalRead(A2), digitalRead(A1), tAlarmCenter.iAlarms, tAlarmCenter.iState, tAlarmCenter.iTcpPort); //------------------------------ } //------------------------------ //------------------------------ // flush logfile each 10 second if (iCount % 200 == 0) // 10 second flush logfile { fflush(fLogFile); } //------------------------------ //-------------------------------------- // update display dispsw_vSetMenuValue(11, tAlarmCenter.iAlarms); dispsw_vSetMenuValue(12, tAlarmCenter.iState); dispsw_vSetMenuValue(13, iAlarmCountDown); dispsw_vSetMenuValue(14, iWarningCountDown); dispsw_vSetMenuValue(15, iOnOffCountDown); //-------------------------------------- //-------------------------------------- // process user inputs and update the // menu. dispsw_MenuUpdate(); //-------------------------------------- //-------------------------------------- // process the menu menuProcess(); //-------------------------------------- usleep(MAINCYCLE*1000ul); } // -------------------------------------------------------- //-------------------------------------- // wait for the threads to stop pthread_join(threadCmd, (void*)piStatus); //-------------------------------------- //-------------------------------------- // stop the display from working. // release CPU power. dispsw_Stop(); //-------------------------------------- sem_destroy(&mutex_CmdBlock); return status ; }
std::string LogBinaryLarge(const void *data, int size, int minSize) { return (size >= minSize) ? LogData(data, size, size) : ""; }
std::string LogBinaryShort(const void *data, int size, int maxSize) { if(maxSize == -1) maxSize = size; return LogData(data, size, maxSize, " (...)"); }
std::string LogBinaryAll(const void *data, int size) { return LogData(data, size, size); }
/// <summary> /// External call passing statistical information to hill climbing. Based on these /// statistics, hill climbing will give a recommendation on the number of resources to be used. /// </summary> /// <param name="currentControlSetting"> /// The control setting used in this period of time. /// </param> /// <param name="completionRate"> /// The number of completed units or work in that period of time. /// </param> /// <param name="arrivalRate"> /// The number of incoming units or work in that period of time. /// </param> /// <param name="queueLength"> /// The total length of the work queue. /// </param> /// <returns> /// The recommended number of resources to be used. /// </returns> unsigned int HillClimbing::Update(unsigned int currentControlSetting, unsigned int completionRate, unsigned int arrivalRate, unsigned int queueLength) { HillClimbingStateTransition transition = Undefined; int recommendedSetting = 0; // If there are no resources devoted to this scheduler proxy then there is // no statistical analysis needed. if (currentControlSetting == 0) { return 0; } // // Hill climbing made a recommendation for a number of resources to be used the next time around. However, that // does not mean that this recommendation was accepted by the consumer of that information. Thus, first establish // the control setting passed in by the consumer so that we can accurately track history information. Also, it is // necessary to flush old, stale history information before trying to hill climb. // m_totalSampleCount++; EstablishControlSetting(currentControlSetting); // // If we had some invalid samples, then carefully modify the actual parameters to this function // if (m_invalidCount > 0) { completionRate += m_saveCompleted; arrivalRate += m_saveIncoming; } // // If we have long running tasks that are not yet completed, report completions and arrivals for those // tasks, effectively chunking them up into sample sized tasks. A long running task scenario is defined as: // // a) Number or completed tasks is smaller than number of resources used in the time interval, AND // b) Number of completed tasks is smaller than a length of the queue (resources cannot be invalid) // if (completionRate < currentControlSetting && completionRate < queueLength) { arrivalRate += (currentControlSetting - completionRate); completionRate = currentControlSetting; } // // Check if reported statistics are within the bounds of a valid sample. A sample is invalid iff: // it is not a warmup run AND it is EITHER too short of a measurement OR there were not enough completions. // if (m_sampleCount >= WarmupSampleCount && MinCompletionsPerSample > completionRate && MinCompletionsPerSample > arrivalRate && queueLength == 0) { // // If this is an invalid sample, save the data // m_invalidCount++; m_saveCompleted = completionRate; m_saveIncoming = arrivalRate; unsigned int minimumSetting = m_pSchedulerProxy->MinHWThreads(); unsigned int maximumSetting = m_pSchedulerProxy->DesiredHWThreads(); (maximumSetting); recommendedSetting = (m_invalidCount < MaxInvalidCount) ? m_currentControlSetting : minimumSetting; TRACE(CONCRT_TRACE_HILLCLIMBING, L"********** Invalid sample!\n Process: %u\n Scheduler: %d\n Invalid count: %d\n Completions: %d\n Arrivals: %d\n Queue length: %d\n Minimum: %d\n Maximum: %d\n Current setting: %d\n Last setting: %d\n -----\n Recommended setting: %d\n**********\n", GetCurrentProcessId(), m_id, m_invalidCount, completionRate, arrivalRate, queueLength, minimumSetting, maximumSetting, m_currentControlSetting, m_lastControlSetting, recommendedSetting); return recommendedSetting; } unsigned int numberOfSamples = m_invalidCount + 1; // // Reset the statistics kept for invalid samples and initiate a valid sample // m_sampleCount++; m_saveCompleted = 0; m_saveIncoming = 0; m_invalidCount = 0; // Unless there is a good reason to climb, the current setting (set by EstablishControlSetting) will remain the same. recommendedSetting = m_currentControlSetting; // Calculate the throughput for this given instance double throughput = CalculateThroughput(numberOfSamples, completionRate, arrivalRate, queueLength); if (m_sampleCount <= WarmupSampleCount) { // // We're in the "warmup" phase, where we simply bide our time (and initialize our current control setting). // _CONCRT_ASSERT(m_currentControlSetting != 0); m_lastControlSetting = m_currentControlSetting; transition = Warmup; } else { MeasuredHistory * currentHistory = GetHistory(m_currentControlSetting); MeasuredHistory * lastHistory = GetHistory(m_lastControlSetting); currentHistory->Add(throughput, m_totalSampleCount); if (AlwaysIncrease > 0) { // // We're in the "always increase" diagnostic mode. Just increase the control setting // along the desired slope. // unsigned int newSetting = (unsigned int) ((AlwaysIncrease / 1000.0) * m_sampleCount); if (newSetting > m_currentControlSetting) { recommendedSetting = RecommendControlSetting(newSetting); transition = DoClimbing; } else { transition = ContinueLookingForClimb; } } else if (lastHistory->Count() == 0 || currentHistory == lastHistory) { // // If we have no previous history, then we need to initialize. We wait until // the current history is stable, then make our first move. // if (IsStableHistory(currentHistory)) { // // This is our first move; we have no history to use to predict the correct move. // We'll just make a random move, and see what happens. // recommendedSetting = RecommendControlSetting(m_currentControlSetting + GetRandomMove()); transition = CompletedInitialization; } else { transition = ContinueInitializing; } } else if (!IsStableHistory(currentHistory)) { transition = ContinueLookingForClimb; } else { // // We have two separate stable histories. We can compare them, and make a real climbing move. // double slope = CalculateThroughputSlope(m_lastControlSetting, m_currentControlSetting); double controlSettingAdjustment = slope * m_controlGain; unsigned int newControlSetting = (unsigned int) (m_currentControlSetting + controlSettingAdjustment); if (newControlSetting == m_currentControlSetting) { newControlSetting = (unsigned int) (m_currentControlSetting + sign(controlSettingAdjustment)); } recommendedSetting = RecommendControlSetting(newControlSetting); transition = DoClimbing; } } _CONCRT_ASSERT(transition != Undefined); // Unhandled case for HillClimbing controller #if defined(CONCRT_TRACING) LogData(recommendedSetting, transition, numberOfSamples, completionRate, arrivalRate, queueLength, throughput); #endif return recommendedSetting; }
void LogManager::Log( Severity severity, const char* message, const char * logFile, int logLine, int verbosity) { if(verbosityLevel>=verbosity) logList.push_back(LogData(severity,logFile,logLine,message,verbosity));//timestamp auto added }