pthread_barrier_test: Reduce sleep times and increase cycles.
This test now reliably reproduces the deadlock reported in #15736.
This commit is contained in:
@@ -2,9 +2,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <OS.h>
|
||||||
|
|
||||||
#define THREAD_COUNT 10
|
#define THREAD_COUNT 10
|
||||||
#define CYCLES 2
|
#define CYCLES 20
|
||||||
|
|
||||||
pthread_barrier_t mybarrier;
|
pthread_barrier_t mybarrier;
|
||||||
|
|
||||||
@@ -14,14 +15,14 @@ void* threadFn(void* id_ptr)
|
|||||||
|
|
||||||
for (int i = 0; i < CYCLES; ++i) {
|
for (int i = 0; i < CYCLES; ++i) {
|
||||||
int wait_sec = 1 + rand() % 10;
|
int wait_sec = 1 + rand() % 10;
|
||||||
printf("thread %d: Wait %d seconds.\n", thread_id, wait_sec);
|
fprintf(stderr, "thread %d: Wait %d microseconds.\n", thread_id, wait_sec * 100);
|
||||||
sleep(wait_sec);
|
snooze(wait_sec * 100);
|
||||||
printf("thread %d: Waiting on barrier...\n", thread_id);
|
|
||||||
|
|
||||||
|
fprintf(stderr, "thread %d: Waiting on barrier...\n", thread_id);
|
||||||
int status = pthread_barrier_wait(&mybarrier);
|
int status = pthread_barrier_wait(&mybarrier);
|
||||||
if (status == PTHREAD_BARRIER_SERIAL_THREAD)
|
if (status == PTHREAD_BARRIER_SERIAL_THREAD)
|
||||||
printf("thread %d: serial thread.\n", thread_id);
|
fprintf(stderr, "thread %d: serial thread.\n", thread_id);
|
||||||
printf("thread %d: Finished!\n", thread_id);
|
fprintf(stderr, "thread %d: Finished!\n", thread_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user