/***************************************************************************** * SOURCE: This is a translation of a Pthread program from the Lawrence Livermore * Computing Center POSIX Threads Programming Exercise at: * https://computing.llnl.gov/tutorials/pthreads/exercise.html * SUPERSOURCE: Adapted from example code in "Pthreads Programming", B. Nichols * et al. O'Reilly and Associates. * FILE: bug3.cvl * DESCRIPTION: * This "hello world" Pthreads program demonstrates an unsafe (incorrect) * way to pass thread arguments by address at thread creation resulting in * a non-unique value for each thread's argument. * Command line execution: * civl verify -inputNUM_THREADS=8 bug3.cvl ******************************************************************************/ #include "pthread.cvh" #include #include #include $input int NUM_THREADS; void *PrintHello(void *threadid){ long taskid = (long)*threadid; // Dereference rather than direct conv //sleep(1); printf("Hello from thread %d\n", taskid); pthread_exit(NULL, false, NULL, 0); //Different parameters } int main(void){ pthread_t threads[NUM_THREADS]; int rc; long t; for(t=0;t