void * thread_function (void *arg) { int i, j; long thread_number = (long) arg; thread_started (); /* Don't start incrementing X until wp-replication.exp is ready. */ while (!test_ready) usleep (1); pthread_mutex_lock (&data_mutex); for (i = 0; i < NR_TRIGGERS_PER_THREAD; i++) { for (j = 0; j < hw_watch_count; j++) { /* For debugging. */ printf ("Thread %ld changing watch_thread[%d] data" " from %d -> %d\n", thread_number, j, watched_data[j], watched_data[j] + 1); /* Increment the watched data field. */ watched_data[j]++; } } pthread_mutex_unlock (&data_mutex); /* Hold the threads here to work around a problem GDB has evaluating watchpoints right when a DSO event shows up (PR breakpoints/10116). Sleep a little longer (than, say, 1, 5 or 10) to avoid consuming lots of cycles while the other threads are trying to execute the loop. */ while (!can_terminate) usleep (100); pthread_exit (NULL); }
void * thread_function (void *arg) { int i; thread_started (); /* Don't start incrementing X until watchthreads2.exp is ready. */ while (! test_ready) usleep (1); for (i = 0; i < X_INCR_COUNT; ++i) { pthread_mutex_lock (&x_mutex); /* For debugging. */ printf ("Thread %ld changing x %d -> %d\n", (long) arg, x, x + 1); /* The call to usleep is so that when the watchpoint triggers, the pc is still on the same line. */ ++x; usleep (1); /* X increment. */ pthread_mutex_unlock (&x_mutex); } pthread_exit (NULL); }