int main(int argc, char**argv) { scene = new Scene(); int renderingMode = 5; RES_X = scene->getWidth(); RES_Y = scene->getHeight(); std::cout << "Please choose your scene from (enter the number):" << std::endl; std::cout << "1 - Balls_low" << std::endl; std::cout << "2 - Balls_high" << std::endl; std::cout << "3 - Mount_Low" << std::endl; std::cout << "4 - Mount_high" << std::endl; std::cout << "5 - Solo dragon" << std::endl; std::cout << "6 - Custom scene" << std::endl; std::string s; getline(std::cin, s); sceneNum = atoi(s.c_str()); std::cout << "Please choose your rendering mode from (enter the number):" << std::endl; std::cout << "1 - Aliasing with DOF" << std::endl; std::cout << "2 - Monte Carlo with DOF" << std::endl; std::cout << "3 - Aliasing only" << std::endl; std::cout << "4 - Monte Carlo only" << std::endl; std::cout << "5 - No DOF or Aliasing" << std::endl; std::cout << "6 - DOF only" << std::endl; getline(std::cin, s); renderingMode = atoi(s.c_str()); std::cout << "Please choose the number of Shadow Rays:" << std::endl; getline(std::cin, s); numSF = atoi(s.c_str()); std::cout << "Please choose the number of Depth Rays:" << std::endl; getline(std::cin, s); numDepth = atoi(s.c_str()); std::thread thr(glutInitv, std::ref(argc), std::ref(argv)); std::thread thr1(loadScene, std::ref(scene ), renderingMode, sceneNum); //threads[2] = std::thread(loadScene, std::ref(scene), 3); //threads[3] = std::thread(loadScene, std::ref(scene), 4); //threads[4] = std::thread(loadScene, std::ref(scene), 5); //threads[5] = std::thread(loadScene, std::ref(scene), 6); //aux[0] = std::thread(loadScene, std::ref(scene), 1); //aux[1] = std::thread(loadScene, std::ref(scene), 2); //aux[2] = std::thread(loadScene, std::ref(scene), 3); //aux[3] = std::thread(loadScene, std::ref(scene), 4); //aux[4] = std::thread(loadScene, std::ref(scene), 5); //aux[5] = std::thread(loadScene, std::ref(scene), 6); thr.join(); thr1.join(); }
int main() { while(1) { __CPROVER_ASYNC_1: thr1(); } }
void test_try_sharable_mutex() { SM mtx; data<SM> s1(1); data<SM> e1(2); data<SM> e2(3); // We start with some specialized tests for "try" behavior shared_val = 0; // Writer one launches, holds the lock for 3*BaseSeconds seconds. boost::thread tw1(thread_adapter<SM>(try_exclusive,&e1,mtx)); // Reader one launches, "clearly" after writer #1 holds the lock // and before it releases the lock. boost::thread::sleep(xsecs(1*BaseSeconds)); boost::thread thr1(thread_adapter<SM>(try_shared,&s1,mtx)); // Writer two launches in the same timeframe. boost::thread tw2(thread_adapter<SM>(try_exclusive,&e2,mtx)); tw2.join(); thr1.join(); tw1.join(); BOOST_INTERPROCES_CHECK(e1.m_value == 10); BOOST_INTERPROCES_CHECK(s1.m_value == -1); // Try would return w/o waiting BOOST_INTERPROCES_CHECK(e2.m_value == -1); // Try would return w/o waiting }
int main() { __CPROVER_ASYNC_1: thr1(0); __CPROVER_ASYNC_2: thr2(0); __CPROVER_ASYNC_3: thr3(0); return 0; }
int main( ) { boost::thread thr1(sendSomething); boost::thread thr2(recvSomething); thr1.join( ); thr2.join( ); }
int main() { __CPROVER_assume(w==0); __CPROVER_assume(r==0); __CPROVER_ASYNC_1: thr1(); thr2(); }
int main() { pthread_t t2; pthread_create(&t2,NULL,thr2,NULL); thr1(NULL); pthread_join(t2,NULL); return 0; }
int main() { __CPROVER_ASYNC_0: thr1(0); __CPROVER_ASYNC_1: thr2(0); __CPROVER_ASYNC_2: thr3(0); __CPROVER_ASYNC_3: thr4(0); //thr2(0); }
int main(){ // pthread_t t1, t2; // pthread_create(&t1, NULL, thr1, NULL); // pthread_create(&t2, NULL, thr2, NULL); __CPROVER_ASYNC_1: thr1(0); __CPROVER_ASYNC_2: thr2(0); assert(r1 != 1 || r2 != 1); return 0; }
int main( ) { boost::thread thr1(boss); boost::thread thr2(worker); boost::thread thr3(worker); thr1.join( ); thr2.join( ); thr3.join( ); }
int main() { __CPROVER_ASYNC_0: thr0(0); __CPROVER_ASYNC_1: thr1(0); __CPROVER_ASYNC_2: thr2(0); //thr2(0); return 0; }
int main() { pthread_t t; /* reachable */ while(/* reachable */ __VERIFIER_nondet_int()) pthread_create(&t, 0, thr1, 0); thr1(0); return 0; }
int main() { barrier barr(3); std::thread thr1(f, std::ref(barr)); std::thread thr2(f, std::ref(barr)); std::thread thr3(f, std::ref(barr)); thr1.join(); thr2.join(); thr3.join(); return 0; }
int main() { std::string s1 = "This is the first thread!"; std::string s2 = "This is the second thread!"; boost::thread thr1(Adapter<WorkerFunPtr, std::string>(worker, s1)); boost::thread thr2(Adapter<WorkerFunPtr, std::string>(worker, s2)); thr1.join(); thr2.join(); }
int main() { __CPROVER_ASYNC_0: thr0(0); __CPROVER_ASYNC_1: thr1(0); __CPROVER_ASYNC_2: thr2(0); __CPROVER_ASYNC_3: thr3(0); __CPROVER_ASYNC_4: thr4(0); __CPROVER_ASYNC_5: thr5(0); //thr2(0); return 0; }
void test_timed_sharable_mutex() { SM m1, m2, m3, m4; SM *pm1, *pm2, *pm3, *pm4; if(SameObject){ pm1 = pm2 = pm3 = pm4 = &m1; } else{ pm1 = &m1; pm2 = &m2; pm3 = &m3; pm4 = &m4; } data<SM> s1(1,1*BaseSeconds); data<SM> s2(2,3*BaseSeconds); data<SM> e1(3,3*BaseSeconds); data<SM> e2(4,1*BaseSeconds); // We begin with some specialized tests for "timed" behavior shared_val = 0; // Writer one will hold the lock for 3*BaseSeconds seconds. boost::thread tw1(thread_adapter<SM>(timed_exclusive,&e1,*pm1)); boost::thread::sleep(xsecs(1*BaseSeconds)); // Writer two will "clearly" try for the lock after the readers // have tried for it. Writer will wait up 1*BaseSeconds seconds for the lock. // This write will fail. boost::thread tw2(thread_adapter<SM>(timed_exclusive,&e2,*pm2)); // Readers one and two will "clearly" try for the lock after writer // one already holds it. 1st reader will wait 1*BaseSeconds seconds, and will fail // to get the lock. 2nd reader will wait 3*BaseSeconds seconds, and will get // the lock. boost::thread thr1(thread_adapter<SM>(timed_shared,&s1,*pm3)); boost::thread thr2(thread_adapter<SM>(timed_shared,&s2,*pm4)); tw1.join(); thr1.join(); thr2.join(); tw2.join(); assert(e1.m_value == 10); assert(s1.m_value == -1); assert(s2.m_value == 10); assert(e2.m_value == -1); }
static void test(void) { atomic_long_test at; mythread thr1(at), thr2(at), thr3(at); thr1.set_detachable(false); thr2.set_detachable(false); thr3.set_detachable(false); thr1.start(); thr2.start(); thr3.start(); thr1.wait(); thr2.wait(); thr3.wait(); }
int main(int, char **) { State s; gcore::Thread thr1(&s, &State::run1, &State::done1); gcore::Thread thr2(&s, &State::run2, &State::done2); thr1.join(); thr1.join(); s.print(stderr, "\nThat's all folks !!\n"); return 0; }
int main() { __CPROVER_ASYNC_0: thr1(0); __CPROVER_ASYNC_1: thr2(0); __CPROVER_ASYNC_2: thr3(0); __CPROVER_ASYNC_3: thr4(0); __CPROVER_ASYNC_4: thr5(0); __CPROVER_ASYNC_5: thr6(0); __CPROVER_ASYNC_6: thr7(0); __CPROVER_ASYNC_7: thr8(0); __CPROVER_ASYNC_8: thr9(0); __CPROVER_ASYNC_9: thr10(0); //thr2(0); }
int main() { pthread_t t2, t3, t4, t5; pthread_create(&t2,NULL,thr2,NULL); pthread_create(&t3,NULL,thr3,NULL); pthread_create(&t4,NULL,thr4,NULL); pthread_create(&t5,NULL,thr5,NULL); thr1(NULL); pthread_join(t2,NULL); pthread_join(t3,NULL); pthread_join(t4,NULL); pthread_join(t5,NULL); return 0; }
void test_try_sharable_mutex() { SM m1, m2, m3; SM *pm1, *pm2, *pm3; if(SameObject){ pm1 = pm2 = pm3 = &m1; } else{ pm1 = &m1; pm2 = &m2; pm3 = &m3; } data<SM> s1(1); data<SM> e1(2); data<SM> e2(3); // We start with some specialized tests for "try" behavior shared_val = 0; // Writer one launches, holds the lock for 3*BaseSeconds seconds. boost::thread tw1(thread_adapter<SM>(try_exclusive,&e1,*pm1)); // Reader one launches, "clearly" after writer #1 holds the lock // and before it releases the lock. boost::thread::sleep(xsecs(1*BaseSeconds)); boost::thread thr1(thread_adapter<SM>(try_shared,&s1,*pm2)); // Writer two launches in the same timeframe. boost::thread tw2(thread_adapter<SM>(try_exclusive,&e2,*pm3)); tw2.join(); thr1.join(); tw1.join(); assert(e1.m_value == 10); assert(s1.m_value == -1); // Try would return w/o waiting assert(e2.m_value == -1); // Try would return w/o waiting }
void test_timed_sharable_mutex() { SM mtx; data<SM> s1(1,1*BaseSeconds); data<SM> s2(2,3*BaseSeconds); data<SM> e1(3,3*BaseSeconds); data<SM> e2(4,1*BaseSeconds); // We begin with some specialized tests for "timed" behavior shared_val = 0; // Writer one will hold the lock for 3*BaseSeconds seconds. boost::thread tw1(thread_adapter<SM>(timed_exclusive,&e1,mtx)); boost::thread::sleep(xsecs(1*BaseSeconds)); // Writer two will "clearly" try for the lock after the readers // have tried for it. Writer will wait up 1*BaseSeconds seconds for the lock. // This write will fail. boost::thread tw2(thread_adapter<SM>(timed_exclusive,&e2,mtx)); // Readers one and two will "clearly" try for the lock after writer // one already holds it. 1st reader will wait 1*BaseSeconds seconds, and will fail // to get the lock. 2nd reader will wait 3*BaseSeconds seconds, and will get // the lock. boost::thread thr1(thread_adapter<SM>(timed_shared,&s1,mtx)); boost::thread thr2(thread_adapter<SM>(timed_shared,&s2,mtx)); tw1.join(); thr1.join(); thr2.join(); tw2.join(); BOOST_INTERPROCES_CHECK(e1.m_value == 10); BOOST_INTERPROCES_CHECK(s1.m_value == -1); BOOST_INTERPROCES_CHECK(s2.m_value == 10); BOOST_INTERPROCES_CHECK(e2.m_value == -1); }
int main (void) { CDUMMY thr1 (1), thr2 (2), thr3 (3); thr1.Start (); thr2.Start (); thr3.Start (); while (42) { #ifdef _WIN32 Sleep (1000); #else struct timeval tv = {2, 0}; ::select (0, 0x0, 0x0, 0x0, &tv); #endif printf ("%08x %08x %08x\n", thr1._cnt, thr2._cnt, thr3._cnt); } return 0; }
void keyboard(unsigned char key, int x, int y) { std::cout << key << std::endl; if (key == 'q') { std::thread thr1(loadScene, std::ref(scene), 1, sceneNum); thr1.detach(); } if (key == 'w') { std::thread thr1(loadScene, std::ref(scene), 2, sceneNum); thr1.detach(); } if (key == 'e') { std::thread thr1(loadScene, std::ref(scene), 3, sceneNum); thr1.detach(); } if (key == 'r') { std::thread thr1(loadScene, std::ref(scene), 4, sceneNum); thr1.detach(); } if (key == 't') { std::thread thr1(loadScene, std::ref(scene), 5, sceneNum); thr1.detach(); } if (key == 'y') { std::thread thr1(loadScene, std::ref(scene), 6, sceneNum); thr1.detach(); } }
void test() { std::string *s1=new std::string("thread1"); boost::thread thr1(adapter<workfunc,std::string>(worker,*s1)); }
int main() { __CPROVER_ASYNC_1: thr1(); thr2(); }
void test_plain_sharable_mutex() { { shared_val = 0; SM m1, m2, m3, m4; SM *pm1, *pm2, *pm3, *pm4; if(SameObject){ pm1 = pm2 = pm3 = pm4 = &m1; } else{ pm1 = &m1; pm2 = &m2; pm3 = &m3; pm4 = &m4; } data<SM> s1(1); data<SM> s2(2); data<SM> e1(1); data<SM> e2(2); // Writer one launches, holds the lock for 3*BaseSeconds seconds. boost::thread tw1(thread_adapter<SM>(plain_exclusive, &e1, *pm1)); // Writer two launches, tries to grab the lock, "clearly" // after Writer one will already be holding it. boost::thread::sleep(xsecs(1*BaseSeconds)); boost::thread tw2(thread_adapter<SM>(plain_exclusive, &e2, *pm2)); // Reader one launches, "clearly" after writer two, and "clearly" // while writer 1 still holds the lock boost::thread::sleep(xsecs(1*BaseSeconds)); boost::thread thr1(thread_adapter<SM>(plain_shared,&s1, *pm3)); boost::thread thr2(thread_adapter<SM>(plain_shared,&s2, *pm4)); thr2.join(); thr1.join(); tw2.join(); tw1.join(); //We can only assure that the writer will be first assert(e1.m_value == 10); //A that we will execute all assert(s1.m_value == 20 || s2.m_value == 20 || e2.m_value == 20); } { shared_val = 0; SM m1, m2, m3, m4; SM *pm1, *pm2, *pm3, *pm4; if(SameObject){ pm1 = pm2 = pm3 = pm4 = &m1; } else{ pm1 = &m1; pm2 = &m2; pm3 = &m3; pm4 = &m4; } data<SM> s1(1, 3); data<SM> s2(2, 3); data<SM> e1(1); data<SM> e2(2); //We launch 2 readers, that will block for 3*BaseTime seconds boost::thread thr1(thread_adapter<SM>(plain_shared,&s1,*pm1)); boost::thread thr2(thread_adapter<SM>(plain_shared,&s2,*pm2)); //Make sure they try to hold the sharable lock boost::thread::sleep(xsecs(1*BaseSeconds)); // We launch two writers, that should block until the readers end boost::thread tw1(thread_adapter<SM>(plain_exclusive,&e1,*pm3)); boost::thread tw2(thread_adapter<SM>(plain_exclusive,&e2,*pm4)); thr2.join(); thr1.join(); tw2.join(); tw1.join(); //We can only assure that the shared will finish first... assert(s1.m_value == 0 || s2.m_value == 0); //...and writers will be mutually excluded after readers assert((e1.m_value == 10 && e2.m_value == 20) || (e1.m_value == 20 && e2.m_value == 10) ); } }
void test_plain_sharable_mutex() { { shared_val = 0; SM mtx; data<SM> s1(1); data<SM> s2(2); data<SM> e1(1); data<SM> e2(2); // Writer one launches, holds the lock for 3*BaseSeconds seconds. boost::thread tw1(thread_adapter<SM>(plain_exclusive, &e1, mtx)); // Writer two launches, tries to grab the lock, "clearly" // after Writer one will already be holding it. boost::thread::sleep(xsecs(1*BaseSeconds)); boost::thread tw2(thread_adapter<SM>(plain_exclusive, &e2, mtx)); // Reader one launches, "clearly" after writer two, and "clearly" // while writer 1 still holds the lock boost::thread::sleep(xsecs(1*BaseSeconds)); boost::thread thr1(thread_adapter<SM>(plain_shared,&s1, mtx)); boost::thread thr2(thread_adapter<SM>(plain_shared,&s2, mtx)); thr2.join(); thr1.join(); tw2.join(); tw1.join(); //We can only assure that the writer will be first BOOST_INTERPROCES_CHECK(e1.m_value == 10); //A that we will execute all BOOST_INTERPROCES_CHECK(s1.m_value == 20 || s2.m_value == 20 || e2.m_value == 20); } { shared_val = 0; SM mtx; data<SM> s1(1, 3); data<SM> s2(2, 3); data<SM> e1(1); data<SM> e2(2); //We launch 2 readers, that will block for 3*BaseTime seconds boost::thread thr1(thread_adapter<SM>(plain_shared,&s1, mtx)); boost::thread thr2(thread_adapter<SM>(plain_shared,&s2, mtx)); //Make sure they try to hold the sharable lock boost::thread::sleep(xsecs(1*BaseSeconds)); // We launch two writers, that should block until the readers end boost::thread tw1(thread_adapter<SM>(plain_exclusive,&e1, mtx)); boost::thread tw2(thread_adapter<SM>(plain_exclusive,&e2, mtx)); thr2.join(); thr1.join(); tw2.join(); tw1.join(); //We can only assure that the shared will finish first... BOOST_INTERPROCES_CHECK(s1.m_value == 0 || s2.m_value == 0); //...and writers will be mutually excluded after readers BOOST_INTERPROCES_CHECK((e1.m_value == 10 && e2.m_value == 20) || (e1.m_value == 20 && e2.m_value == 10) ); } }