Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/regress/lib/libpthread/sem Tweak this test to make it a bit ...



details:   https://anonhg.NetBSD.org/src/rev/f2134027ccba
branches:  trunk
changeset: 542162:f2134027ccba
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Wed Jan 22 22:12:56 2003 +0000

description:
Tweak this test to make it a bit easier to observe behavior.

diffstat:

 regress/lib/libpthread/sem/sem.c |  22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)

diffs (65 lines):

diff -r b9840507348f -r f2134027ccba regress/lib/libpthread/sem/sem.c
--- a/regress/lib/libpthread/sem/sem.c  Wed Jan 22 22:05:45 2003 +0000
+++ b/regress/lib/libpthread/sem/sem.c  Wed Jan 22 22:12:56 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sem.c,v 1.1 2003/01/20 20:12:18 christos Exp $ */
+/* $NetBSD: sem.c,v 1.2 2003/01/22 22:12:56 thorpej Exp $ */
 
 /****************************************************************************
  *
@@ -51,11 +51,15 @@
 static void *
 entry(void * a_arg)
 {
+       pthread_t self = pthread_self();
        sem_t * sem = (sem_t *) a_arg;
 
-;      sem_wait(sem);
 #ifdef DEBUG
-       fprintf(stderr, "Got semaphore\n");
+       printf("Thread %p waiting for semaphore...\n", self);
+#endif
+       sem_wait(sem);
+#ifdef DEBUG
+       printf("Thread %p got semaphore\n");
 #endif
   
        return NULL;
@@ -68,13 +72,13 @@
 main()
 {
 #ifdef DEBUG
-       fprintf(stderr, "Test begin\n");
+       printf("Test begin\n");
 #endif
        usem();
        ksem();
 
 #ifdef DEBUG
-       fprintf(stderr, "Test end\n");
+       printf("Test end\n");
 #endif
        return 0;
 }
@@ -115,6 +119,10 @@
        }
 
        for (i = 0; i < NTHREADS; i++) {
+               sleep(1);
+#ifdef DEBUG
+               printf("main loop 1: posting...\n");
+#endif
                assert(0 == sem_post(&sem_a));
        }
   
@@ -127,6 +135,10 @@
        }
 
        for (i = 0; i < NTHREADS; i++) {
+               sleep(1);
+#ifdef DEBUG
+               printf("main loop 2: posting...\n");
+#endif
                assert(0 == sem_post(&sem_a));
        }
   



Home | Main Index | Thread Index | Old Index