int main() { Echo("start Processeur 1"); Echo(itoa(GetTick())); int moyenne[size],i,j; calcul_moyenne(moyenne); msg1.length=size; for(i=0;i<size;i++) msg1.msg[i]=moyenne[i]; Echo("Valeur de la moyenne :"); Echo(fixetoa(moyenne[0])); Send(&msg1,RMS); Send(&msg1,WRMS); Send(&msg1,GFC); Send(&msg1,XYZ1); Echo(itoa(GetTick())); Echo("Communication Processeur 1 finished."); exit(); }
int main() { Echo("start LAB1"); Echo(itoa(GetTick())); int i; int LAB[3]={0,0,0}; Receive(&msg1,XYZ1); lab(msg1.msg,LAB); for (i=0;i<3;i++) { msg1.msg[i]=LAB[i]; Echo(fixetoa(LAB[i])); } Send(&msg1,DLAB); Echo(itoa(GetTick())); Echo("Communication LAB1 finished."); exit(); }
void AdManager::Update() { list<AdProvider*>::iterator itor = m_providers.begin(); for (;itor != m_providers.end(); itor++) { (*itor)->Update(); } if (m_errorCount > 15) return; //something is seriously wrong, let's not risk hammering the tapjoy service forever if (m_updateTimer >= GetTick(TIMER_SYSTEM)) return; m_updateTimer = GetTick(TIMER_SYSTEM)+ 1000; if (m_bSendTapjoyAdRequestASAP) { CacheTapjoyAd(); } if (m_bSendTapjoyFeaturedAppRequestASAP) { CacheTapjoyFeaturedApp(); } }
int main() { Echo("start GFC"); Echo(itoa(GetTick())); int i; int sum_Es,sum_Me,sum_EM; int gfc; Receive(&msg1,P1); Receive(&msg2,P2); sum_Es=0; sum_Me=0; sum_EM=0; for (i=0;i<size;i++) { sum_Es=add(mult(msg1.msg[i],msg1.msg[i]),sum_Es); sum_Me=add(mult(msg2.msg[i],msg2.msg[i]),sum_Me); sum_EM=add(mult(msg1.msg[i],msg2.msg[i]),sum_EM); } if (sum_EM<0) sum_EM=mult(sum_EM,-10000); gfc=mult(sqrt(sum_Es),sqrt(sum_Me)); gfc=div(sum_EM,gfc); Echo("distance GFC : "); Echo(fixetoa(gfc)); Echo(itoa(GetTick())); Echo("Communication GFC finished."); exit(); }
int Application::Run() { float T_currrent = GetTick(); float T_preRender = T_currrent; float T_prev; g_Profiler.ClearSamples(); while (MainWindow && !MainWindow->IsDestroyed()) { { Profile("Main Loop"); if (!MainWindow->ProcessMessages()) break; T_prev = T_currrent; T_currrent = GetTick(); float T_total = T_currrent - T_prev; //float T_render = T_currrent - T_preRender; SceneCur->FrameStart(); Update(T_total * 0.001f); T_preRender = GetTick(); Render(); if (!MainWindow || MainWindow->IsDestroyed()) return 0; SceneCur->FrameEnd(); } g_Profiler.FrameEnd(); } return 0; }
int main() { int i, j,t; Echo("synthetic task C started."); Echo(itoa(GetTick())); for(i=0;i<SYNTHETIC_ITERATIONS;i++){ msg.length = 30; for(j=0;j<30;j++) msg.msg[j]=i; Receive(&msg,taskA); for(t=0;t<1000;t++){ } Send(&msg,taskD); Receive(&msg,taskB); for(t=0;t<1000;t++){ } Send(&msg,taskE); } Echo(itoa(GetTick())); Echo("synthetic task C finished."); exit(); }
void Profiler :: ProfileBegin (const char* name) { uint iSample = 0; while ( iSample < I_MaxSamples && Samples[iSample].FL_valid ) { if ( strcmp( name, Samples[iSample].Name ) == 0 ) { // Sample is already known ++Samples[iSample].I_OpenProfiles; ++Samples[iSample].I_ProfileInstances; Samples[iSample].T_Start = GetTick(); assert(Samples[iSample].I_OpenProfiles && "Profiler::ProfileBegin : Recurention is not supported"); return; } iSample++; } if ( iSample >= I_MaxSamples ) { assert( !"Profiler::ProfileBegin : Number of samples exceeded I_MaxSamples" ); return; } ProfileSample &sample = Samples[iSample]; sample.Name = name; sample.FL_valid = true; sample.I_OpenProfiles = 1; sample.I_ProfileInstances = 1; sample.T_Samples = 0.f; sample.T_ChildrenSamples = 0.f; sample.T_Start = GetTick(); }
// 接收按键处理 void Process_BetPadKey(unsigned char Id, unsigned char *Data) { unsigned short Key = (Data[0]|(Data[1]<<8)); unsigned short Release; // 已释放掉的键 unsigned char BitIdx; int Tick; Key &= 0x0EFF; if (!RecvTick[Id]) { // 发送ID if (Id < COM_PLAYER_COUNT) { Send_ID(Id); } Set_Odds(Id); Set_LED(Id); Set_Score(Id); } RecvTick[Id] = GetTick() + 3000; // 如果1.5秒内没有信息发过来就当掉线 DownKey[Id] = Key & (Key ^ ConstDownKey[Id]); // 长按开始计数 Release = DownKey[Id]&(~ConstDownKey[Id]); Tick = GetTick(); while (Release & KeyPressFlag) { BitIdx = bsr32(Release); Release &= ~(1<<BitIdx); KeyCount[Id][BitIdx] = Tick + 200; } Release = (Key ^ DownKey[Id] ^ ConstDownKey[Id]); ConstDownKey[Id] = Key & (~Release); }
// 关门 void SetCloseDoor(unsigned char Door, unsigned char Delay) { if (Door & 0x01) { CloseDoorTick[0] = GetTick() + Delay*5000; } if (Door &0x02) { CloseDoorTick[1] = GetTick() + Delay*5000; } }
// Driver program to test above functions void main() { int n = sizeof(arr)/sizeof(arr[0]); Echo("n:"); Echo(itoa(n)); Echo("Begin:");Echo(itoa(GetTick())); selectionSort(arr, n); Echo("End:");Echo(itoa(GetTick())); Echo("Sorted array"); printArray(arr, n); exit(); }
void LoopingSound::Update() { if (m_bDisabled) return; switch (m_state) { case STATE_MOVE_START: if (m_waitTimer < GetTick(TIMER_SYSTEM)) { m_waitTimer = 0; //time to kick into the move loop sound GetAudioManager()->Stop(m_transitionSoundHandle); m_transitionSoundHandle = AUDIO_HANDLE_BLANK; PlayMoveSound(); } break; case STATE_MOVE_END: if (m_waitTimer < GetTick(TIMER_SYSTEM)) { m_waitTimer = 0; //time to kick into the move loop sound GetAudioManager()->Stop(m_transitionSoundHandle); m_transitionSoundHandle = AUDIO_HANDLE_BLANK; PlayIdleSound(); } break; case STATE_IDLE: if (GetEmulatedPlatformID() == PLATFORM_ID_WEBOS) { //special hack to fix crappy SDL audio issues with looping cutting out if (m_loopingSoundHandle > 0 && !GetAudioManager()->IsPlaying(m_loopingSoundHandle)) { //restart it #ifdef _DEBUG //LogMsg("Kickstarting idle loop again"); #endif PlayIdleSound(); } } break; } }
void TApp::Idle(DWORD timeout) { TApp *app = TApp::GetApp(); DWORD start = GetTick(); MSG msg; while (::PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) { if (app->PreProcMsg(&msg)) continue; ::TranslateMessage(&msg); ::DispatchMessageW(&msg); if (GetTick() - start >= timeout) break; } }
void TrailRenderComponent::OnRender(VariantList *pVList) { if (m_insideTrailDrawingNow) return; //currently drawing our trail, get out or we'll cause an inifinite loop m_insideTrailDrawingNow = true; //save current settings TrailFrame tempFrame; SetFrameFromEntity(&tempFrame); //render out all history.. deque<TrailFrame>::iterator itor = m_history.begin(); float frame = 1; while (itor != m_history.end()) { SetEntityFromFrame(&*itor); //tweak the alpha a bit *m_pAlpha = *m_pAlpha * *m_pTrailAlpha * (frame / float(m_history.size())+2); //tweak the scale a bit //*m_pScale2d = *m_pScale2d *(frame / (float(m_history.size())+2)); GetParent()->CallFunctionRecursivelyWithUpdatedVar("OnRender", pVList, string("pos2d"), 0, Entity::RECURSIVE_VAR_OP_ADDITION); itor++; frame++; } //put it back SetEntityFromFrame(&tempFrame); //add current data to our history? if (m_frameRecordTimer < GetTick(m_timingSystem)) { m_history.push_back(tempFrame); while (m_history.size() > *m_pFrames) { m_history.pop_front(); } m_frameRecordTimer = GetTick(m_timingSystem)+*m_pTimeBetweenFramesMS; } m_insideTrailDrawingNow = false; }
int main() { unsigned char decoded_block[1000]; int samples[COMPRESSED_SAMPLES*2]; unsigned int j, time_arrive =0, last_arrive = 0, jitter[2000]; int block_size, blocks; Message msg; int i, k; Echo("Join start..."); Echo("Number of frames"); Echo(itoa(FRAMES)); //RealTime(AUDIO_VIDEO_PERIOD, JOIN_deadline, JOIN_exe_time); j = 0; for(k=0; k<FRAMES; k++ ) { Receive(&msg, FIR); Receive(&msg,idct); Echo(itoa(GetTick())); } //for(i=0; i<j; i++) // Echo(itoa(jitter[i])); Echo("Join finished."); exit(); }
void MoveButtonState::OnPressToggle(bool bDown, boost::signal<void (VariantList*)> *pCustomSignal) { VariantList v; if (bDown) { if (!m_bIsDown) { m_bIsDown = true; v.Get(0).Set(uint32(m_keyType)); v.Get(1).Set(uint32(VIRTUAL_KEY_PRESS)); if (pCustomSignal) { (*pCustomSignal)(&v); } else { GetBaseApp()->m_sig_arcade_input(&v); } } m_releaseTimer = rt_max(GetTick(TIMER_SYSTEM), m_releaseTimer); m_releaseTimer += 1000*60; } else { ReleaseIfNeeded(pCustomSignal); } }
int main() { int i; volatile int p; unsigned int time[PROD_CONS_ITERATIONS]; Echo("Inicio da aplicacao cons"); for(i=0; i<PROD_CONS_ITERATIONS; i++){ Receive(&msg, prod); time[i] = GetTick(); } for(i=0; i<PROD_CONS_ITERATIONS; i++){ Echo(itoa(time[i])); } Echo("Fim da aplicacao cons"); exit(); }
void MoveButtonState::Update(boost::signal<void (VariantList*)> *pCustomSignal) { if (m_bIsDown && m_releaseTimer < GetTick(TIMER_SYSTEM)) { //time to release, since Android doesn't send one ReleaseIfNeeded(pCustomSignal); } }
void LoopingSound::SetMoving( bool bNew ) { if (m_bDisabled) return; if (bNew == m_bMoving) return; //nothing really changed m_bMoving = bNew; KillAudio(); if (m_bMoving) { if (m_moveStart.empty()) { //there is no move start sound, so just play the looping moving sound right now PlayMoveSound(); } else { //play a starting sound first m_transitionSoundHandle = GetAudioManager()->Play(m_moveStart, false, false, m_bAddBasePath); GetAudioManager()->SetVol(m_transitionSoundHandle, m_volume); m_waitTimer = GetTick(TIMER_SYSTEM)+m_moveStartTimeMS; m_state = STATE_MOVE_START; } } else { //stop moving and play the idle sound if (m_moveEnd.empty()) { PlayIdleSound(); } else { //play a stopping sound first m_transitionSoundHandle = GetAudioManager()->Play(m_moveEnd, false, false, m_bAddBasePath); GetAudioManager()->SetVol(m_transitionSoundHandle, m_volume); m_waitTimer = GetTick(TIMER_SYSTEM)+m_moveEndTimeMS; m_state = STATE_MOVE_END; } } }
void AppResume(JNIEnv* env) { g_callAppResumeASAPTimer = GetSystemTimeTick() + C_DELAY_BEFORE_RESTORING_SURFACES_MS; #ifdef _DEBUG LogMsg("Queuing resume: %u (now is %u)", g_callAppResumeASAPTimer, GetTick(TIMER_SYSTEM)); #endif }
int main() { int i, j,t; Echo("synthetic task B started."); Echo(itoa(GetTick())); for(i=0;i<SYNTHETIC_ITERATIONS;i++){ Receive(&msg,taskA); Send(&msg,taskD); } Echo(itoa(GetTick())); Echo("synthetic task B finished."); exit(); }
int main(void) { #ifdef _WIN32 hInstance = GetModuleHandle(NULL); #endif CSynthesizer s; CEditor e(&s); COSToolkit t(0, &e); unsigned int time = GetTick(); e.SetToolkit(&t); time = GetTick() - time; printf("full blitting time: %ums\n", time); CDummyHostInterface h(&s); e.SetHostInterface(&h); t.StartWindowProcesses(); return t.WaitWindowClosed(); }
int main(){ int i, j; //int distances[NUM_PATTERNS]; msg.length = SIZE*SIZE; //SIZE*SIZE nao pode ser maior que 128, senao usar o SendData Echo("Rec ola\n"); Echo(GetTick()); memcpy(msg.msg, test, sizeof(test)); for(i=0; i<TOTAL_TASKS; i++){ Send(&msg,P[i]); } Echo("Test Sendedd to all tasks\n"); //Echo(itoa(PATTERN_PER_TASK)); for(j=0; j<PATTERN_PER_TASK; j++){ for(i=0; i<TOTAL_TASKS; i++){ Receive(&msg, P[i]); //distances[d_count] = msg.msg[0]; //sprintf(d, "DTW entre amostra de teste e o padrão %d = %d TICK = %d", d_count, distances[d_count], GetTick()); } Echo(itoa(GetTick())); } /*j = distances[0]; for(i=1; i<TOTAL_TASKS; i++){ if(j<distances[i]) j = distances[i]; }*/ Echo("FIM DO RECONHECIMENTO DE PADROES, MENOR DISTANCIA:\n"); /*Echo(itoa(j)); Echo("tempo: "); Echo(itoa(GetTick()));*/ exit(); }
int dpMain::Search(double max_time) { if(!start_node) { cerr << "dpMain error: start node not set" << endl; return -1; } dpQueue* q = top_queue; LongInteger start_tick = GetTick(); while(q) { if(q->node->open(-1, -1)) break; remove_node_single(q->node); q = smallest_queue(); LongInteger cur_tick = GetTick(); if(ExpiredTime(start_tick, cur_tick) > max_time) return 1; } return 0; }
int main(int argc, char *argv[]) { int i, j; Message msg; int rank = 4; //RealTime(200000, 200000, 90000, 0); //RealTime(200000, 200000, 90000, 0); - 45% nos primeiros 2s qtdEnvios = 0; msg.length = NUM_NODES*(NUM_NODES-1)/2; Receive(&msg, divider); for (i=0; i<(NUM_NODES*(NUM_NODES-1)/2); i++) nodes_tasks[i][0] = msg.msg[i]; Receive(&msg, divider); for (i=0; i<(NUM_NODES*(NUM_NODES-1)/2); i++) nodes_tasks[i][1] = msg.msg[i]; msg.length = MAXPROCESSORS; Receive(&msg, divider); for (i=0; i<MAXPROCESSORS; i++) { tasks[i][0] = msg.msg[i]; } Receive(&msg, divider); for (i=0; i<MAXPROCESSORS; i++) { tasks[i][1] = msg.msg[i]; } msg.length = NUM_NODES; for (i=0; i<NUM_NODES; i++) { Receive(&msg, divider); for (j=0; j<NUM_NODES; j++) AdjMatrix[j][i] = msg.msg[j]; } /*for(i=0; i<NUM_NODES; i++) { Echo(" D1: "); for(j=0; j<NUM_NODES; j++) { Echo(itoa(AdjMatrix[i][j])); Echo(" "); } Echo("\n"); }*/ dijkstra(rank); Echo(itoa(GetTick())); Echo("Dijkstra_4 finished."); exit(); }
static void ngx_proc_luashm_backup_thread_cycle(void *data) { ngx_proc_luashm_backup_conf_t *pbcf; ngx_cycle_t *cycle; ngx_shm_zone_t *zone; ngx_str_t *name; ngx_uint_t i; ngx_time_t *tp; int64_t now,settimestamp; cycle = data; pbcf = ngx_proc_get_conf(cycle->conf_ctx, ngx_proc_luashm_backup_module); if(pbcf->settimestamp.data == NULL){ pthread_exit((void *)0); return; } while(pbcf->running){ ngx_time_update(); if(ngx_strstr(pbcf->settimestamp.data,":")==NULL){ settimestamp=ngx_atoi(pbcf->settimestamp.data,pbcf->settimestamp.len); }else{ tp = ngx_timeofday(); now = (int64_t) tp->sec * 1000 + tp->msec; settimestamp=GetTick((char*)pbcf->settimestamp.data)*1000; ngx_log_error(NGX_LOG_DEBUG, ngx_cycle->log, 0, "========= now:%lu, settimestamp:%lu =========",now,settimestamp); if(settimestamp<now) settimestamp=(24*60*60*1000)-(now-settimestamp); else settimestamp=settimestamp-now; if(settimestamp==0)settimestamp=1; } ngx_log_error(NGX_LOG_DEBUG, ngx_cycle->log, 0, "========= backup time:%s, sleeptime:%lu =========",pbcf->settimestamp.data,settimestamp); ngx_msleep(settimestamp); if(!pbcf->running)break; i = 0; for (; i < pbcf->shdict_names->nelts;i++) { name = ((ngx_str_t*)pbcf->shdict_names->elts) + i; zone = ngx_http_lua_find_zone(name->data,name->len); dd("shm.name:%s,shm.name_len:%ld,shm.size:%ld ", name->data,name->len,zone->shm.size); ngx_proc_luashm_backup_backup(cycle,zone); } ngx_log_error(NGX_LOG_DEBUG, cycle->log, 0, "luashm_backup %V",&ngx_cached_http_time); ngx_sleep(60); if(!pbcf->running)break; } pthread_exit((void *)0); }
// 保单箱状态检测 void BoxStateCheck (void) { static unsigned char HasPaperBlank = 0; // 不缺纸 static unsigned char HasBoxOpen = 0; // 门没打开 // 是否有按下退纸键 if (!KeyRollBack) { ZhengFan = 0; PRTOpen = 1; } // 缺纸检测 if (IsPaperBlank() && !HasPaperBlank) { SendIC (0x22); HasPaperBlank = 1; } else if (HasPaperBlank && !IsPaperBlank()) { SendIC (0x33); HasPaperBlank = 0; if (!IsOpenPrinter()) {//纸合未打开 RollPaper(1, 600); //进纸 } } // 门开检测 if (IsBoxOpened() && !HasBoxOpen) { SendIC (0x88); HasBoxOpen = 1; } else if (HasBoxOpen && !IsBoxOpened()) { SendIC (0x44); HasBoxOpen = 0; } // 是否要开门和关门 if (OpenDoorTick[0]) if (GetTick() >= OpenDoorTick[0]) { P3 &= 0xFE; OpenDoorTick[0] = 0;} if (OpenDoorTick[1]) if (GetTick() >= OpenDoorTick[1]) { P3 &= 0xFD; OpenDoorTick[1] = 0;} if (CloseDoorTick[0]) if (GetTick() >= CloseDoorTick[0]) { P3 |= 0x01; CloseDoorTick[0] = 0;} if (CloseDoorTick[1]) if (GetTick() >= CloseDoorTick[1]) { P3 |= 0x02; CloseDoorTick[1] = 0;} }
/************************************************************************* Function Name : UartTxPolling Arguments : Null Return : Null Description : send data in polling way. Mainly used for debug. **************************************************************************/ void UartTxPolling(uint8* pData, uint16 len) { if (!len) return; UartLoopUntilTxIdle(); UartSwitchToTx(); while (len--) { loop_until_bit_is_set(UCSR0A, UDRE); UDR0 = *pData++; } UartSwitchToRxAfterTxc(); txCtrl.stat = TX_FNS; txCtrl.lastTxTime = GetTick(); }
bool KSocket::IsTimeout(unsigned int uiStart, unsigned int uiTimeout) { unsigned int uiCurr = GetTick(); unsigned int uiDiff; if (uiTimeout == 0) return false; if (uiCurr >= uiStart) { uiDiff = uiCurr - uiStart; }else{ uiDiff = (0xFFFFFFFF - uiStart) + uiCurr; } if(uiDiff >= uiTimeout){ return true; } return false; }
bool DrSocket::IsTimeout(unsigned int uiStart, unsigned int uiTimeout) { showLog("Jni.DrSocket.IsTimeout", "uiStart:%d uiTimeout:%d", uiStart, uiTimeout); unsigned int uiCurr = GetTick(); unsigned int uiDiff; if (uiTimeout == 0) return false; if (uiCurr >= uiStart) { uiDiff = uiCurr - uiStart; }else{ uiDiff = (0xFFFFFFFF - uiStart) + uiCurr; } if(uiDiff >= uiTimeout){ return true; } return false; }
void Profiler :: ProfileEnd (const char* name) { uint iSample = 0; uint I_CountParents = 0; while ( iSample < I_MaxSamples && Samples[iSample].FL_valid ) { if ( strcmp( name, Samples[iSample].Name ) == 0 ) { // We found sample uint iParent = 0; int ID_parent = -1; // direct parent float T_Stop = GetTick(); assert( Samples[iSample].I_OpenProfiles > 0 && "Profiler::ProfileEnd : Trying to close a sample that hasn't been opened" ); --Samples[iSample].I_OpenProfiles; while ( iParent < I_MaxSamples && Samples[iParent].FL_valid ) { if ( Samples[iParent].I_OpenProfiles > 0 ) { ++I_CountParents; if (ID_parent < 0) ID_parent = iParent; else if (Samples[iParent].T_Start >= Samples[ID_parent].T_Start) ID_parent = iParent; } ++iParent; } Samples[iSample].I_NumParents = I_CountParents; float T_duration = T_Stop - Samples[iSample].T_Start; if (ID_parent >= 0) Samples[ID_parent].T_ChildrenSamples += T_duration; Samples[iSample].T_Samples += T_duration; return; } ++iSample; } assert( !"Profiler::ProfileEnd : Sample with given name has not been found" ); }