Esempio n. 1
0
static void t1(void* a, void* b)
{
    (void) a;
    (void) b;
	thread1();
	lwt_sig_signal(sig);
}
Esempio n. 2
0
int main(int ac, char* av[])
{
	LOG_MSG << "LogTestApp. -- written by Wilston Oreo.";

#ifdef TEST_THREADS

	srand ( time(NULL) );

	LOG_MSG_(1) << "Startup";  
	boost::thread thread1(threadLog);
	boost::thread thread2(threadLog);
	boost::thread thread3(threadLog);
	boost::thread thread4(threadLog);
	LOG_MSG_(1) << "Waiting for threads...";

	thread1.join();
	thread2.join();
	thread3.join();
	thread4.join();

#endif

	LOG_MSG_(1) << "Done";

	LOG->level(2);

	LOG_MSG_(1) << fmt("Log level: %") % LOG->level();
	LOG_WRN << fmt("Warning %") % 3;
	LOG_MSG_(3);
	LOG_MSG_(4);
	LOG_ERR << "ERROR";

	return 0;
}
Esempio n. 3
0
int testthread(int* arg){
  int i;
  int id[100];

  temp = 0;
  timeout = 2000; /* in millisceonds */

  for(N = 2; N<=50; N*=5){
    printf("\n\n* %ld threads Test...", N);
    fflush(stdout);
    timeout *= 3;
    strt = mytime();
    id[0]=0;

    for(i = 1; i < N; i++){
      id[i]=i;
      minithread_fork(thread1, &id[i]);
    }

    thread1(&id[0]);

    if(temp >= N*3)
      printf(" Preemption working");
    else 
      printf(" Preemption failed");
    fflush(stdout);
    time_wait(4000); /* in milliseconds */
  }

  return 0;
}
Esempio n. 4
0
void main() {
  x = 0;
  y = 0;
  thread1();
  thread2();
  thread3();
}
Esempio n. 5
0
void testThreadInitAndExit()
{
    std::cout<<"******   Running thread start and delete test   ****** "<<std::endl;

    {
        MyThread thread;
        thread.startThread();
    }
    
    // add a sleep to allow the thread start to fall over it its going to.
    OpenThreads::Thread::microSleep(500000);
    
    std::cout<<"pass    thread start and delete test"<<std::endl<<std::endl;


    std::cout<<"******   Running notify thread test   ****** "<<std::endl;

    {
        NotifyThread thread1(osg::INFO,"thread one:");
        NotifyThread thread2(osg::INFO,"thread two:");
        NotifyThread thread3(osg::INFO,"thread three:");
        NotifyThread thread4(osg::INFO,"thread four:");
        thread1.startThread();
        thread2.startThread();
        thread3.startThread();
        thread4.startThread();

        // add a sleep to allow the thread start to fall over it its going to.
        OpenThreads::Thread::microSleep(5000000);
    }

    std::cout<<"pass    noitfy thread test."<<std::endl<<std::endl;
}
Esempio n. 6
0
int main() {
	std::mutex m;
	std::condition_variable cond_var;
    std::thread thread1([&m, &cond_var](){
        for(;;) {
        	std::this_thread::sleep_for(std::chrono::seconds(1));
        	std::unique_lock<std::mutex> lock(m);
        	std::cout << "first" << std::endl;
        	cond_var.notify_one();
        }
    });

    std::thread thread2([&m, &cond_var](){
        for(;;) {
        	std::unique_lock<std::mutex> lock(m);
        	cond_var.wait(lock);
        	std::cout << "second" << std::endl;
        }
    });

    thread1.join();
    thread2.join();

    return 0;
}
Esempio n. 7
0
void launch_and_join() 
{ 
    std::thread thread1( [] {
        do_some_work_and_join();
    });
    thread1.join();
}
Esempio n. 8
0
void main() {
  starting = 1;
  IntrMask = 0;
  patched = 0;
  thread1();
  thread2();
}
Esempio n. 9
0
int main(int argc, char** argv) {
  std::thread thread1(run_master);
  std::thread thread2(run_watcher);
  thread1.join();
  thread2.join();
  return 0;
}
Esempio n. 10
0
main() {
    IntrMask = 0;
    intr_mask = 0;
    handled = 0;
  thread1();
  thread2();
}
Esempio n. 11
0
int main ()
{
  printf ("Results of cancel_thread_test:\n");

  try
  {
    LogFilter filter ("system.threads.*", &print_log);

    Thread thread1 (&thread1_run), thread2 (&thread2_run);

    thread [0] = &thread1;
    thread [1] = &thread2;
    
    int result1 = thread [1]->Join (), result0 = thread [0]->Join ();

    printf ("join thread2: %d\n", result1);
    printf ("join thread1: %d\n", result0);
    fflush (stdout);
  }
  catch (std::exception& exception)
  {
    printf ("exception: %s\n", exception.what ());
  }

  return 0;
}
//-*****************************************************************************
int main( int argc, char* argv[] )
{
    boost::thread thread1( &test );
    boost::thread thread2( &test );
    thread1.join();
    thread2.join();
    return 0;
}
Esempio n. 13
0
int main() {
  __CPROVER_ASYNC_1: thread1();
  __CPROVER_ASYNC_1: thread2();
  __CPROVER_ASYNC_1: thread3();
  __CPROVER_assume(y==3);
  assert(x!=1);
  return 0;
}
Esempio n. 14
0
void PresetTests::parallelAccessTest() {
    const int initIterations = 100;
    const int itemsToGenerate = 5;
    DECLARE_MODELS_AND_GENERATE(itemsToGenerate);

    QString presetName = "preset";
    QStringList keywords;
    keywords << "keyword1" << "another keyword" << "test";

    Helpers::Barrier barrier1(2), barrier2(2);
    bool isAdded1, isAdded2;
    volatile bool removed1;
    volatile bool removed2;
    KeywordsPresets::ID_t id1 = 0;
    KeywordsPresets::ID_t id2 = 0;

    std::thread thread1([&]() {
        int n = initIterations;
        while (n--) {
            isAdded1 = false; id1 = 0;
            presetKeywordsModel.addOrUpdatePreset(presetName, keywords, id1, isAdded1);

            /*-------------*/barrier1.wait();

            Q_ASSERT(isAdded1 != isAdded2);
            Q_ASSERT(id1 == id2);

            removed1 = presetKeywordsModel.removePresetByID(id1);

            /*-------------*/barrier2.wait();

            Q_ASSERT(removed1 != removed2);
        }
    });

    std::thread thread2([&]() {

        int n = initIterations;
        while (n--) {
            isAdded2 = false; id2 = 1;
            presetKeywordsModel.addOrUpdatePreset(presetName, keywords, id2, isAdded2);

            /*-------------*/barrier1.wait();

            Q_ASSERT(isAdded1 != isAdded2);
            Q_ASSERT(id1 == id2);

            removed2 = presetKeywordsModel.removePresetByID(id2);

            /*-------------*/barrier2.wait();

            Q_ASSERT(removed1 != removed2);
        }
    });

    thread1.join();
    thread2.join();
}
Esempio n. 15
0
void testThreads()
{
    Thread thread1(1);
    Thread thread2(2);
    thread1.start();
    thread2.start();
    thread1.wait();
    thread2.wait();
}
Esempio n. 16
0
void main() {
  registered = 0;
  initialised1 = 0;
  initialised2 = 0;
  initialised3 = 0;
  thread1();
  thread2();
  thread3();
}
Esempio n. 17
0
void MiscThreadTestCase::TestThreadRun()
{
    MyJoinableThread thread1(2);
    CPPUNIT_ASSERT_EQUAL( wxTHREAD_NO_ERROR, thread1.Run() );
    thread1.Wait();     // wait until the thread ends

    // verify that running twice the same thread fails
    WX_ASSERT_FAILS_WITH_ASSERT( thread1.Run() );
}
Esempio n. 18
0
File: main.c Progetto: diffblue/2ls
void main()
{
  while(1)
  {
    thread1();
    thread2();
    if(exit==0) break;
  }
}
Esempio n. 19
0
int main()
{
    pthread_t thread;
    pthread_create(&thread, NULL, thread2, NULL);
    thread1(0);
    pthread_join(thread, NULL);

    return 0;
}
Esempio n. 20
0
int main()
{
   std::thread thread1(function_modifying_global_struct, 1);
   std::thread thread2(function_modifying_global_struct, 2);

   thread1.join();
   thread2.join();

   return 0;
}
Esempio n. 21
0
	void doTest() {
//		boost::thread::id a = boost::this_thread::get_id();
		boost::thread thread0(func0);
		boost::thread thread1(func1);

		//boost::recursive_mutex::scoped_lock autolock(mutex);
		thread0.join();
		thread1.join();
		printf("ThreadTest OK..\n");
	}
Esempio n. 22
0
File: main.cpp Progetto: CCJY/coliru
int main ()
{
    std::thread thread1(task1);
    std::thread thread2(task2);

    thread1.join();
    thread2.join();

    return EXIT_SUCCESS;
}
Esempio n. 23
0
void main() {
  napi_poll = 0;
  shutdown = 0;
  stuff1_done = 0;
  updated = 0;
  napi_disabled = 0;
  thread1();
  thread2();
  thread3();
}
Esempio n. 24
0
void main()
{
  for(int i = 0; i < 10; i++)
  {
    boost::thread thread1(boost::bind(&func1));
    boost::thread thread2(boost::bind(&func2));
    thread2.join();
    thread1.join();
  }
}
Esempio n. 25
0
File: lazy01.c Progetto: quytc/TARA
void main()
{
  data = 0;
  mutex = 0;
  
  thread1();
  thread2();
  thread3();
  
}
Esempio n. 26
0
int main()
{
	boost::thread thread1(boost::bind(func, "tom", 160));
	boost::thread thread2(boost::bind(func, "glen", 500));

	sleep(3);
	thread1.join();
	thread2.join();
	return 0;
}
Esempio n. 27
0
int main(int argc, char **argv) 
{
  Aria::init(Aria::SIGHANDLE_THREAD, false);

  ArMutex mutex;
  mutex.setLogName("mutex");

  ArMutex::setLockWarningTime(1);
  ArMutex::setUnlockWarningTime(5);
  TestThread thread1(1, mutex), thread2(2, mutex), thread3(3, mutex),
    thread4(4, mutex);

  thread1.setThreadName("thread1");
  thread2.setThreadName("thread2");
  thread3.setThreadName("thread3");
  thread4.setThreadName("thread4");
  srand(time(0));


  thread1.create();
  thread2.create();
  thread3.create();

  printf("main thread name=\"%s\", OS handle=%lu, OS pointer=0x%x\n", ArThread::getThisThreadName(), ArThread::getThisOSThread(), (unsigned int) ArThread::getThisThread());
  printf("thread1 thread name=\"%s\", OS handle=%lu, OS pointer=0x%x\n", thread1.getThreadName(), thread1.getOSThread(), (unsigned int) thread1.getThread());
  printf("thread2 thread name=\"%s\", OS handle=%lu, OS pointer=0x%x\n", thread2.getThreadName(), thread2.getOSThread(), (unsigned int) thread2.getThread());
  printf("thread3 thread name=\"%s\", OS handle=%lu, OS pointer=0x%x\n", thread3.getThreadName(), thread3.getOSThread(), (unsigned int) thread3.getThread());
  printf("thread4 (not created yet) thread name=\"%s\", OS handle=%lu, OS pointer=0x%x\n", thread4.getThreadName(), thread4.getOSThread(), (unsigned int) thread4.getThread());
  if(ArThread::getThisOSThread() == thread1.getOSThread() ||
     ArThread::getThisOSThread() == thread2.getOSThread() ||
     ArThread::getThisOSThread() == thread3.getOSThread() ||
     ArThread::getThisOSThread() == thread4.getOSThread() ||
     thread1.getOSThread() == thread2.getOSThread() ||
     thread1.getOSThread() == thread3.getOSThread() ||
     thread1.getOSThread() == thread4.getOSThread() ||
     thread2.getOSThread() == thread1.getOSThread() ||
     thread2.getOSThread() == thread3.getOSThread() ||
     thread2.getOSThread() == thread4.getOSThread() ||
     thread3.getOSThread() == thread1.getOSThread() ||
     thread3.getOSThread() == thread2.getOSThread() ||
     thread3.getOSThread() == thread4.getOSThread() ||
     thread4.getOSThread() == thread1.getOSThread() ||
     thread4.getOSThread() == thread2.getOSThread() ||
     thread4.getOSThread() == thread3.getOSThread() )
  {
    puts("error, some thread IDs are the same!");
    return 5;
  }

  thread4.runInThisThread();

  Aria::shutdown();

  return(0);
}
Esempio n. 28
0
void main() {
  x = 0;
  y = 0;
  z = 0;
  a = 0;
  b = 0;
  thread1();
  thread2();
  thread3();
  thread4();
}
Esempio n. 29
0
File: main.cpp Progetto: CCJY/coliru
int main()
{
	mystack<std::function<bool()>> stk; // une version sans pointeurs serait meilleure/plus simple
	int n = 10;
	std::thread thread1(fun1, std::ref(stk), std::ref(n));
	std::thread thread2(fun2, std::ref(stk));
	thread1.join();
	thread2.join();
	std::cout << "Fin." << std::endl;
	return 0;
}
Esempio n. 30
0
bool ServiceLocator::test() {
    bool result = true;
    
    int n = 0;
    
    ServiceLocator* loc = ServiceLocator::getDefaultLocator();
    
    std::thread thread1(testThread, ++n, loc);
    std::thread thread2(testThread, ++n, loc);
    
    thread1.join();
    thread2.join();
    
    return result;
}