Ignore:
File:
1 edited

Legend:

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

    r0f4f1b2 rbab75df6  
    4141
    4242static waitq_t can_start;
    43 static atomic_size_t items_produced;
    44 static atomic_size_t items_consumed;
     43static atomic_t items_produced;
     44static atomic_t items_consumed;
    4545
    4646static void producer(void *arg)
    4747{
     48        thread_detach(THREAD);
     49
    4850        waitq_sleep(&can_start);
    4951
     
    5658static void consumer(void *arg)
    5759{
     60        thread_detach(THREAD);
     61
    5862        waitq_sleep(&can_start);
    5963
     
    8993                                thrd = thread_create(consumer, NULL, TASK,
    9094                                    THREAD_FLAG_NONE, "consumer");
    91                                 if (thrd) {
    92                                         thread_start(thrd);
    93                                         thread_detach(thrd);
    94                                 } else {
     95                                if (thrd)
     96                                        thread_ready(thrd);
     97                                else
    9598                                        TPRINTF("could not create consumer %d\n", i);
    96                                 }
    9799                        }
    98100                        for (k = 0; k < (4 - i); k++) {
    99101                                thrd = thread_create(producer, NULL, TASK,
    100102                                    THREAD_FLAG_NONE, "producer");
    101                                 if (thrd) {
    102                                         thread_start(thrd);
    103                                         thread_detach(thrd);
    104                                 } else {
     103                                if (thrd)
     104                                        thread_ready(thrd);
     105                                else
    105106                                        TPRINTF("could not create producer %d\n", i);
    106                                 }
    107107                        }
    108108                }
     
    111111
    112112                thread_sleep(1);
    113                 waitq_wake_all(&can_start);
     113                waitq_wakeup(&can_start, WAKEUP_ALL);
    114114
    115115                while ((items_consumed != consumers) || (items_produced != producers)) {
Note: See TracChangeset for help on using the changeset viewer.