Changeset 96348adc in mainline for kernel/test/synch/semaphore2.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/semaphore2.c

    r34db7fa r96348adc  
    4848static uint32_t seed = 0xdeadbeef;
    4949
    50 static uint32_t random(uint32_t max);
    51 
    52 static void consumer(void *arg);
    53 static void failed(void);
    54 
    5550static uint32_t random(uint32_t max)
    5651{
     
    6358        return rc;
    6459}
    65 
    6660
    6761static void consumer(void *arg)
     
    8882}
    8983
    90 static void failed(void)
    91 {
    92         printf("Test failed prematurely.\n");
    93         thread_exit();
    94 }
    95 
    96 void test_semaphore2(void)
     84char * test_semaphore2(void)
    9785{
    9886        uint32_t i, k;
    9987       
    100         printf("Semaphore test #2\n");
    101    
    10288        waitq_initialize(&can_start);
    10389        semaphore_initialize(&sem, 5);
    10490       
    105 
     91        thread_t *thrd;
    10692       
    107         for (; ;) {
    108                 thread_t *thrd;
    109                
    110                 k = random(7) + 1;
    111                 printf("Creating %d consumers\n", k);
    112                 for (i=0; i<k; i++) {
    113                         thrd = thread_create(consumer, NULL, TASK, 0, "consumer");
    114                         if (thrd)
    115                                 thread_ready(thrd);
    116                         else
    117                                 failed();
    118                 }
    119                
    120                 thread_usleep(20000);
    121                 waitq_wakeup(&can_start, WAKEUP_ALL);
    122         }               
    123 
     93        k = random(7) + 1;
     94        printf("Creating %d consumers\n", k);
     95        for (i = 0; i < k; i++) {
     96                thrd = thread_create(consumer, NULL, TASK, 0, "consumer");
     97                if (thrd)
     98                        thread_ready(thrd);
     99                else
     100                        printf("Error creating thread\n");
     101        }
     102       
     103        thread_usleep(20000);
     104        waitq_wakeup(&can_start, WAKEUP_ALL);
     105       
     106        return NULL;
    124107}
Note: See TracChangeset for help on using the changeset viewer.