Changeset cb01e1e in mainline for kernel/test/synch/rwlock3.c


Ignore:
Timestamp:
2009-04-04T00:26:27Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a85aebd
Parents:
171f9a1
Message:

use global variable and a macro for silencing tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/test/synch/rwlock3.c

    r171f9a1 rcb01e1e  
    3535#include <synch/rwlock.h>
    3636
    37 #define THREADS 4
     37#define THREADS  4
    3838
    3939static atomic_t thread_count;
    4040static rwlock_t rwlock;
    41 static bool sh_quiet;
    4241
    4342static void reader(void *arg)
     
    4544        thread_detach(THREAD);
    4645       
    47         if (!sh_quiet)
    48                 printf("cpu%u, tid %" PRIu64 ": trying to lock rwlock for reading....\n", CPU->id, THREAD->tid);
     46        TPRINTF("cpu%u, tid %" PRIu64 ": trying to lock rwlock for reading....\n", CPU->id, THREAD->tid);
    4947       
    5048        rwlock_read_lock(&rwlock);
    5149        rwlock_read_unlock(&rwlock);
    5250       
    53         if (!sh_quiet) {
    54                 printf("cpu%u, tid %" PRIu64 ": success\n", CPU->id, THREAD->tid);             
    55                 printf("cpu%u, tid %" PRIu64 ": trying to lock rwlock for writing....\n", CPU->id, THREAD->tid);       
    56         }
    57 
     51        TPRINTF("cpu%u, tid %" PRIu64 ": success\n", CPU->id, THREAD->tid);
     52        TPRINTF("cpu%u, tid %" PRIu64 ": trying to lock rwlock for writing....\n", CPU->id, THREAD->tid);
     53       
    5854        rwlock_write_lock(&rwlock);
    5955        rwlock_write_unlock(&rwlock);
    6056       
    61         if (!sh_quiet)
    62                 printf("cpu%u, tid %" PRIu64 ": success\n", CPU->id, THREAD->tid);
     57        TPRINTF("cpu%u, tid %" PRIu64 ": success\n", CPU->id, THREAD->tid);
    6358       
    6459        atomic_dec(&thread_count);
    6560}
    6661
    67 char * test_rwlock3(bool quiet)
     62char *test_rwlock3(void)
    6863{
    6964        int i;
    7065        thread_t *thrd;
    71         sh_quiet = quiet;
    7266       
    7367        atomic_set(&thread_count, THREADS);
     
    8074                if (thrd)
    8175                        thread_ready(thrd);
    82                 else if (!quiet)
    83                         printf("Could not create reader %d\n", i);
     76                else
     77                        TPRINTF("Could not create reader %d\n", i);
    8478        }
    85 
     79       
    8680        thread_sleep(1);
    8781        rwlock_write_unlock(&rwlock);
    8882       
    8983        while (atomic_get(&thread_count) > 0) {
    90                 if (!quiet)
    91                         printf("Threads left: %ld\n", atomic_get(&thread_count));
     84                TPRINTF("Threads left: %ld\n", atomic_get(&thread_count));
    9285                thread_sleep(1);
    9386        }
Note: See TracChangeset for help on using the changeset viewer.