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


Ignore:
Timestamp:
2009-04-04T00:26:27Z (16 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/rwlock5.c

    r171f9a1 rcb01e1e  
    3636#include <synch/rwlock.h>
    3737
    38 #define READERS         50
    39 #define WRITERS         50
     38#define READERS  50
     39#define WRITERS  50
    4040
    4141static rwlock_t rwlock;
     
    4848{
    4949        thread_detach(THREAD);
    50 
     50       
    5151        waitq_sleep(&can_start);
    52 
     52       
    5353        rwlock_write_lock(&rwlock);
    5454        atomic_inc(&items_written);
     
    5959{
    6060        thread_detach(THREAD);
    61 
     61       
    6262        waitq_sleep(&can_start);
    6363       
     
    6767}
    6868
    69 char * test_rwlock5(bool quiet)
     69char *test_rwlock5(void)
    7070{
    7171        int i, j, k;
     
    7777        for (i = 1; i <= 3; i++) {
    7878                thread_t *thrd;
    79 
     79               
    8080                atomic_set(&items_read, 0);
    8181                atomic_set(&items_written, 0);
    82 
     82               
    8383                readers = i * READERS;
    8484                writers = (4 - i) * WRITERS;
    85 
    86                 printf("Creating %ld readers and %ld writers...", readers, writers);
     85               
     86                TPRINTF("Creating %ld readers and %ld writers...", readers, writers);
    8787               
    8888                for (j = 0; j < (READERS + WRITERS) / 2; j++) {
     
    9292                                        thread_ready(thrd);
    9393                                else
    94                                         printf("Could not create reader %d\n", k);
     94                                        TPRINTF("Could not create reader %d\n", k);
    9595                        }
    9696                        for (k = 0; k < (4 - i); k++) {
     
    9999                                        thread_ready(thrd);
    100100                                else
    101                                         printf("Could not create writer %d\n", k);
     101                                        TPRINTF("Could not create writer %d\n", k);
    102102                        }
    103103                }
    104 
    105                 printf("ok\n");
    106 
     104               
     105                TPRINTF("ok\n");
     106               
    107107                thread_sleep(1);
    108108                waitq_wakeup(&can_start, WAKEUP_ALL);
    109        
     109               
    110110                while ((items_read.count != readers) || (items_written.count != writers)) {
    111                         printf("%d readers remaining, %d writers remaining, readers_in=%d\n", readers - items_read.count, writers - items_written.count, rwlock.readers_in);
     111                        TPRINTF("%d readers remaining, %d writers remaining, readers_in=%d\n", readers - items_read.count, writers - items_written.count, rwlock.readers_in);
    112112                        thread_usleep(100000);
    113113                }
Note: See TracChangeset for help on using the changeset viewer.