Add -c option for read-side C.S. length to tests
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Fri, 12 Jun 2009 17:31:02 +0000 (13:31 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Fri, 12 Jun 2009 17:31:02 +0000 (13:31 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
test_mutex.c
test_perthreadlock.c
test_qsbr.c
test_rwlock.c
test_urcu.c

index 57f584252f73ba692b98b23942d92afba2985dbf..29c840b284a3a8277edf4786d22d7c4ea4b584b7 100644 (file)
@@ -71,6 +71,9 @@ static volatile struct test_array test_array = { 8 };
 
 static unsigned long duration;
 
+/* read-side C.S. duration, in us */
+static unsigned long rduration;
+
 /*
  * returns 0 if test should end.
  */
@@ -130,6 +133,8 @@ void *thr_reader(void *data)
        for (;;) {
                pthread_mutex_lock(&lock);
                assert(test_array.a == 8);
+               if (unlikely(rduration))
+                       usleep(rduration);
                pthread_mutex_unlock(&lock);
                nr_reads++;
                if (unlikely(!test_duration_read()))
@@ -180,6 +185,7 @@ void show_usage(int argc, char **argv)
        printf(" [-r] [-w] (yield reader and/or writer)");
 #endif
        printf(" [-d delay] (writer period (us))");
+       printf(" [-c duration] (reader C.S. duration (us))");
        printf(" [-a cpu#] [-a cpu#]... (affinity)");
        printf("\n");
 }
@@ -244,6 +250,13 @@ int main(int argc, char **argv)
                        use_affinity = 1;
                        printf("Adding CPU %d affinity\n", a);
                        break;
+               case 'c':
+                       if (argc < i + 2) {
+                               show_usage(argc, argv);
+                               return -1;
+                       }
+                       rduration = atoi(argv[++i]);
+                       break;
                case 'd':
                        if (argc < i + 2) {
                                show_usage(argc, argv);
index 4f46d23c9da84fca94a8c7fe40ca2c44a585b119..a2abb8df714c2e825aa31657032d46523135f6bf 100644 (file)
@@ -75,6 +75,9 @@ static volatile struct test_array test_array = { 8 };
 
 static unsigned long duration;
 
+/* read-side C.S. duration, in us */
+static unsigned long rduration;
+
 /*
  * returns 0 if test should end.
  */
@@ -134,6 +137,8 @@ void *thr_reader(void *data)
        for (;;) {
                pthread_mutex_lock(&per_thread_lock[tidx].lock);
                assert(test_array.a == 8);
+               if (unlikely(rduration))
+                       usleep(rduration);
                pthread_mutex_unlock(&per_thread_lock[tidx].lock);
                nr_reads++;
                if (unlikely(!test_duration_read()))
@@ -189,6 +194,7 @@ void show_usage(int argc, char **argv)
        printf(" [-r] [-w] (yield reader and/or writer)");
 #endif
        printf(" [-d delay] (writer period (us))");
+       printf(" [-c duration] (reader C.S. duration (us))");
        printf(" [-a cpu#] [-a cpu#]... (affinity)");
        printf("\n");
 }
@@ -253,6 +259,13 @@ int main(int argc, char **argv)
                        use_affinity = 1;
                        printf("Adding CPU %d affinity\n", a);
                        break;
+               case 'c':
+                       if (argc < i + 2) {
+                               show_usage(argc, argv);
+                               return -1;
+                       }
+                       rduration = atoi(argv[++i]);
+                       break;
                case 'd':
                        if (argc < i + 2) {
                                show_usage(argc, argv);
index f56234b564c8bac4a6d01ff1b2eede53beba3e0f..7ff1aca9c7600994f5b2ad30d79d0ca7fd3a0e60 100644 (file)
@@ -65,6 +65,9 @@ static struct test_array *test_rcu_pointer;
 
 static unsigned long duration;
 
+/* read-side C.S. duration, in us */
+static unsigned long rduration;
+
 /*
  * returns 0 if test should end.
  */
@@ -164,6 +167,8 @@ void *thr_reader(void *_count)
                debug_yield_read();
                if (local_ptr)
                        assert(local_ptr->a == 8);
+               if (unlikely(rduration))
+                       usleep(rduration);
                _rcu_read_unlock();
                nr_reads++;
                /* QS each 1024 reads */
@@ -228,6 +233,7 @@ void show_usage(int argc, char **argv)
        printf(" [-r] [-w] (yield reader and/or writer)");
 #endif
        printf(" [-d delay] (writer period (us))");
+       printf(" [-c duration] (reader C.S. duration (us))");
        printf(" [-a cpu#] [-a cpu#]... (affinity)");
        printf("\n");
 }
@@ -291,6 +297,13 @@ int main(int argc, char **argv)
                        use_affinity = 1;
                        printf("Adding CPU %d affinity\n", a);
                        break;
+               case 'c':
+                       if (argc < i + 2) {
+                               show_usage(argc, argv);
+                               return -1;
+                       }
+                       rduration = atoi(argv[++i]);
+                       break;
                case 'd':
                        if (argc < i + 2) {
                                show_usage(argc, argv);
index 0fdaad60b9871641d30b7e1eca3007f3ff07ad06..4ec427b8be469e14f3f46b511b7d5744cc114d49 100644 (file)
@@ -71,6 +71,9 @@ static volatile struct test_array test_array = { 8 };
 
 static unsigned long duration;
 
+/* read-side C.S. duration, in us */
+static unsigned long rduration;
+
 /*
  * returns 0 if test should end.
  */
@@ -127,6 +130,8 @@ void *thr_reader(void *_count)
        for (;;) {
                pthread_rwlock_rdlock(&lock);
                assert(test_array.a == 8);
+               if (unlikely(rduration))
+                       usleep(rduration);
                pthread_rwlock_unlock(&lock);
                nr_reads++;
                if (unlikely(!test_duration_read()))
@@ -177,6 +182,7 @@ void show_usage(int argc, char **argv)
        printf(" [-r] [-w] (yield reader and/or writer)");
 #endif
        printf(" [-d delay] (writer period (us))");
+       printf(" [-c duration] (reader C.S. duration (us))");
        printf(" [-a cpu#] [-a cpu#]... (affinity)");
        printf("\n");
 }
@@ -241,6 +247,13 @@ int main(int argc, char **argv)
                        use_affinity = 1;
                        printf("Adding CPU %d affinity\n", a);
                        break;
+               case 'c':
+                       if (argc < i + 2) {
+                               show_usage(argc, argv);
+                               return -1;
+                       }
+                       rduration = atoi(argv[++i]);
+                       break;
                case 'd':
                        if (argc < i + 2) {
                                show_usage(argc, argv);
index 016fa3f6c70ac2f7aa7c6c74cef1225493d6b1fa..85f4a36ce8e1eb3a35a62854b916ff9b284ced50 100644 (file)
@@ -69,6 +69,9 @@ static struct test_array *test_rcu_pointer;
 
 static unsigned long duration;
 
+/* read-side C.S. duration, in us */
+static unsigned long rduration;
+
 /*
  * returns 0 if test should end.
  */
@@ -168,6 +171,8 @@ void *thr_reader(void *_count)
                debug_yield_read();
                if (local_ptr)
                        assert(local_ptr->a == 8);
+               if (unlikely(rduration))
+                       usleep(rduration);
                rcu_read_unlock();
                nr_reads++;
                if (unlikely(!test_duration_read()))
@@ -229,6 +234,7 @@ void show_usage(int argc, char **argv)
        printf(" [-r] [-w] (yield reader and/or writer)");
 #endif
        printf(" [-d delay] (writer period (us))");
+       printf(" [-c duration] (reader C.S. duration (us))");
        printf(" [-a cpu#] [-a cpu#]... (affinity)");
        printf("\n");
 }
@@ -292,6 +298,13 @@ int main(int argc, char **argv)
                        use_affinity = 1;
                        printf("Adding CPU %d affinity\n", a);
                        break;
+               case 'c':
+                       if (argc < i + 2) {
+                               show_usage(argc, argv);
+                               return -1;
+                       }
+                       rduration = atoi(argv[++i]);
+                       break;
                case 'd':
                        if (argc < i + 2) {
                                show_usage(argc, argv);
This page took 0.029316 seconds and 4 git commands to generate.