|
From: <sv...@va...> - 2009-02-23 03:31:14
|
Author: njn
Date: 2009-02-23 03:31:04 +0000 (Mon, 23 Feb 2009)
New Revision: 9233
Log:
These files should have been removed in an earlier merge.
Removed:
branches/DARWIN/helgrind/tests/pth_barrier.c
branches/DARWIN/helgrind/tests/rwlock_race.c
branches/DARWIN/helgrind/tests/rwlock_test.c
Deleted: branches/DARWIN/helgrind/tests/pth_barrier.c
===================================================================
--- branches/DARWIN/helgrind/tests/pth_barrier.c 2009-02-23 03:30:27 UTC (rev 9232)
+++ branches/DARWIN/helgrind/tests/pth_barrier.c 2009-02-23 03:31:04 UTC (rev 9233)
@@ -1,110 +0,0 @@
-/* Test whether all data races are detected in a multithreaded program with
- * barriers.
- */
-
-
-#define _GNU_SOURCE
-
-/***********************/
-/* Include directives. */
-/***********************/
-
-#include <assert.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-
-/*********************/
-/* Type definitions. */
-/*********************/
-
-struct threadinfo
-{
- pthread_barrier_t* b;
- pthread_t tid;
- int* array;
- int iterations;
-};
-
-
-/********************/
-/* Local variables. */
-/********************/
-
-static int s_silent;
-
-
-/*************************/
-/* Function definitions. */
-/*************************/
-
-/** Single thread, which touches p->iterations elements of array p->array.
- * Each modification of an element of p->array is a data race. */
-static void* threadfunc(struct threadinfo* p)
-{
- int i;
- int* const array = p->array;
- pthread_barrier_t* const b = p->b;
- if (! s_silent)
- printf("thread %lx iteration 0\n", pthread_self());
- pthread_barrier_wait(b);
- for (i = 0; i < p->iterations; i++)
- {
- if (! s_silent)
- printf("thread %lx iteration %d; writing to %p\n",
- pthread_self(), i + 1, &array[i]);
- array[i] = i;
- pthread_barrier_wait(b);
- }
- return 0;
-}
-
-/** Actual test, consisting of nthread threads. */
-static void barriers_and_races(const int nthread, const int iterations)
-{
- int i;
- struct threadinfo* t;
- pthread_barrier_t b;
- int* array;
-
- t = malloc(nthread * sizeof(struct threadinfo));
- array = malloc(iterations * sizeof(array[0]));
-
- if (! s_silent)
- printf("&array[0] = %p\n", array);
-
- pthread_barrier_init(&b, 0, nthread);
-
- for (i = 0; i < nthread; i++)
- {
- t[i].b = &b;
- t[i].array = array;
- t[i].iterations = iterations;
- pthread_create(&t[i].tid, 0, (void*(*)(void*))threadfunc, &t[i]);
- }
-
- for (i = 0; i < nthread; i++)
- {
- pthread_join(t[i].tid, 0);
- }
-
- pthread_barrier_destroy(&b);
-
- free(array);
- free(t);
-}
-
-int main(int argc, char** argv)
-{
- int nthread;
- int iterations;
-
- nthread = (argc > 1) ? atoi(argv[1]) : 2;
- iterations = (argc > 2) ? atoi(argv[2]) : 3;
- s_silent = (argc > 3) ? atoi(argv[3]) : 0;
-
- barriers_and_races(nthread, iterations);
-
- return 0;
-}
Deleted: branches/DARWIN/helgrind/tests/rwlock_race.c
===================================================================
--- branches/DARWIN/helgrind/tests/rwlock_race.c 2009-02-23 03:30:27 UTC (rev 9232)
+++ branches/DARWIN/helgrind/tests/rwlock_race.c 2009-02-23 03:31:04 UTC (rev 9233)
@@ -1,56 +0,0 @@
-/** Cause a race inside code protected by a reader lock.
- */
-
-
-/* Needed for older glibc's (2.3 and older, at least) who don't
- otherwise "know" about pthread_rwlock_anything or about
- PTHREAD_MUTEX_RECURSIVE (amongst things). */
-
-#define _GNU_SOURCE 1
-
-#include <pthread.h>
-#include <stdio.h>
-#include <unistd.h>
-
-
-
-static pthread_rwlock_t s_rwlock;
-static int s_racy;
-
-static void sleep_ms(const int ms)
-{
- struct timespec delay = { ms / 1000, (ms % 1000) * 1000 * 1000 };
- nanosleep(&delay, 0);
-}
-
-static void* thread_func(void* arg)
-{
- pthread_rwlock_rdlock(&s_rwlock);
- s_racy++;
- pthread_rwlock_unlock(&s_rwlock);
- sleep_ms(100);
- return 0;
-}
-
-int main(int argc, char** argv)
-{
- pthread_t thread1;
- pthread_t thread2;
-
-#if 0
- int res;
- VALGRIND_DO_CLIENT_REQUEST(res, 0, VG_USERREQ__DRD_TRACE_ADDR,
- &s_racy, 0, 0, 0, 0);
-#endif
-
- pthread_rwlock_init(&s_rwlock, 0);
- pthread_create(&thread1, 0, thread_func, 0);
- pthread_create(&thread2, 0, thread_func, 0);
- pthread_join(thread1, 0);
- pthread_join(thread2, 0);
- pthread_rwlock_destroy(&s_rwlock);
-
- fprintf(stderr, "Result: %d\n", s_racy);
-
- return 0;
-}
Deleted: branches/DARWIN/helgrind/tests/rwlock_test.c
===================================================================
--- branches/DARWIN/helgrind/tests/rwlock_test.c 2009-02-23 03:30:27 UTC (rev 9232)
+++ branches/DARWIN/helgrind/tests/rwlock_test.c 2009-02-23 03:31:04 UTC (rev 9233)
@@ -1,52 +0,0 @@
-/** Multithreaded test program that triggers various access patterns without
- * triggering any race conditions.
- */
-
-
-#define _GNU_SOURCE 1
-
-#include <pthread.h>
-#include <stdio.h>
-
-
-static pthread_rwlock_t s_rwlock;
-static int s_counter;
-
-static void* thread_func(void* arg)
-{
- int i;
- int sum = 0;
-
- for (i = 0; i < 1000; i++)
- {
- pthread_rwlock_rdlock(&s_rwlock);
- sum += s_counter;
- pthread_rwlock_unlock(&s_rwlock);
- pthread_rwlock_wrlock(&s_rwlock);
- s_counter++;
- pthread_rwlock_unlock(&s_rwlock);
- }
-
- return 0;
-}
-
-int main(int argc, char** argv)
-{
- const int thread_count = 10;
- pthread_t tid[thread_count];
- int i;
-
- for (i = 0; i < thread_count; i++)
- {
- pthread_create(&tid[i], 0, thread_func, 0);
- }
-
- for (i = 0; i < thread_count; i++)
- {
- pthread_join(tid[i], 0);
- }
-
- fprintf(stderr, "Finished.\n");
-
- return 0;
-}
|