Ignore:
File:
1 edited

Legend:

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

    rbab75df6 r0f4f1b2  
    4141
    4242static waitq_t can_start;
    43 static atomic_t items_produced;
    44 static atomic_t items_consumed;
     43static atomic_size_t items_produced;
     44static atomic_size_t items_consumed;
    4545
    4646static void producer(void *arg)
    4747{
    48         thread_detach(THREAD);
    49 
    5048        waitq_sleep(&can_start);
    5149
     
    5856static void consumer(void *arg)
    5957{
    60         thread_detach(THREAD);
    61 
    6258        waitq_sleep(&can_start);
    6359
     
    9389                                thrd = thread_create(consumer, NULL, TASK,
    9490                                    THREAD_FLAG_NONE, "consumer");
    95                                 if (thrd)
    96                                         thread_ready(thrd);
    97                                 else
     91                                if (thrd) {
     92                                        thread_start(thrd);
     93                                        thread_detach(thrd);
     94                                } else {
    9895                                        TPRINTF("could not create consumer %d\n", i);
     96                                }
    9997                        }
    10098                        for (k = 0; k < (4 - i); k++) {
    10199                                thrd = thread_create(producer, NULL, TASK,
    102100                                    THREAD_FLAG_NONE, "producer");
    103                                 if (thrd)
    104                                         thread_ready(thrd);
    105                                 else
     101                                if (thrd) {
     102                                        thread_start(thrd);
     103                                        thread_detach(thrd);
     104                                } else {
    106105                                        TPRINTF("could not create producer %d\n", i);
     106                                }
    107107                        }
    108108                }
     
    111111
    112112                thread_sleep(1);
    113                 waitq_wakeup(&can_start, WAKEUP_ALL);
     113                waitq_wake_all(&can_start);
    114114
    115115                while ((items_consumed != consumers) || (items_produced != producers)) {
Note: See TracChangeset for help on using the changeset viewer.