Changeset 96348adc in mainline for kernel/test/synch/rwlock5.c


Ignore:
Timestamp:
2006-12-12T17:24:58Z (17 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7e13972
Parents:
34db7fa
Message:

cleanup tests

File:
1 edited

Legend:

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

    r34db7fa r96348adc  
    4545static atomic_t items_written;
    4646
    47 static void writer(void *arg);
    48 static void reader(void *arg);
    49 static void failed(void);
    50 
    51 void writer(void *arg)
     47static void writer(void *arg)
    5248{
    5349        thread_detach(THREAD);
     
    6056}
    6157
    62 void reader(void *arg)
     58static void reader(void *arg)
    6359{
    6460        thread_detach(THREAD);
     
    7167}
    7268
    73 void failed(void)
    74 {
    75         printf("Test failed prematurely.\n");
    76         thread_exit();
    77 }
    78 
    79 void test_rwlock5(void)
     69char * test_rwlock5(void)
    8070{
    8171        int i, j, k;
    8272        count_t readers, writers;
    8373       
    84         printf("Read/write locks test #5\n");
    85    
    8674        waitq_initialize(&can_start);
    8775        rwlock_initialize(&rwlock);
    8876       
    89         for (i=1; i<=3; i++) {
     77        for (i = 1; i <= 3; i++) {
    9078                thread_t *thrd;
    9179
     
    9381                atomic_set(&items_written, 0);
    9482
    95                 readers = i*READERS;
    96                 writers = (4-i)*WRITERS;
     83                readers = i * READERS;
     84                writers = (4 - i) * WRITERS;
    9785
    9886                printf("Creating %ld readers and %ld writers...", readers, writers);
    9987               
    100                 for (j=0; j<(READERS+WRITERS)/2; j++) {
    101                         for (k=0; k<i; k++) {
     88                for (j = 0; j < (READERS + WRITERS) / 2; j++) {
     89                        for (k = 0; k < i; k++) {
    10290                                thrd = thread_create(reader, NULL, TASK, 0, "reader");
    10391                                if (thrd)
    10492                                        thread_ready(thrd);
    10593                                else
    106                                         failed();
     94                                        printf("Could not create reader %d\n", k);
    10795                        }
    108                         for (k=0; k<(4-i); k++) {
     96                        for (k = 0; k < (4 - i); k++) {
    10997                                thrd = thread_create(writer, NULL, TASK, 0, "writer");
    11098                                if (thrd)
    11199                                        thread_ready(thrd);
    112100                                else
    113                                         failed();
     101                                        printf("Could not create writer %d\n", k);
    114102                        }
    115103                }
     
    120108                waitq_wakeup(&can_start, WAKEUP_ALL);
    121109       
    122                 while (items_read.count != readers || items_written.count != writers) {
     110                while ((items_read.count != readers) || (items_written.count != writers)) {
    123111                        printf("%zd readers remaining, %zd writers remaining, readers_in=%zd\n", readers - items_read.count, writers - items_written.count, rwlock.readers_in);
    124112                        thread_usleep(100000);
    125113                }
    126114        }
    127         printf("Test passed.\n");
     115       
     116        return NULL;
    128117}
Note: See TracChangeset for help on using the changeset viewer.