Changeset 0f4f1b2 in mainline for kernel/test/synch/semaphore1.c


Ignore:
Timestamp:
2024-01-15T17:10:27Z (14 months ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master
Children:
e82879c
Parents:
a064d4f
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2024-01-15 16:37:22)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2024-01-15 17:10:27)
Message:

Add (and use) functions thread_start() and thread_detach()

Mostly cosmetic, with thread_start() replacing calls to thread_ready(),
but not consuming the passed reference, and thread_detach() being
synonym for thread_put(). Makes the code's function more obvious.

Also modify some threaded tests to use thread_join() for waiting,
instead of counting threads with atomics or semaphores.

File:
1 edited

Legend:

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

    ra064d4f r0f4f1b2  
    8989                                thrd = thread_create(consumer, NULL, TASK,
    9090                                    THREAD_FLAG_NONE, "consumer");
    91                                 if (thrd)
    92                                         thread_ready(thrd);
    93                                 else
     91                                if (thrd) {
     92                                        thread_start(thrd);
     93                                        thread_detach(thrd);
     94                                } else {
    9495                                        TPRINTF("could not create consumer %d\n", i);
     96                                }
    9597                        }
    9698                        for (k = 0; k < (4 - i); k++) {
    9799                                thrd = thread_create(producer, NULL, TASK,
    98100                                    THREAD_FLAG_NONE, "producer");
    99                                 if (thrd)
    100                                         thread_ready(thrd);
    101                                 else
     101                                if (thrd) {
     102                                        thread_start(thrd);
     103                                        thread_detach(thrd);
     104                                } else {
    102105                                        TPRINTF("could not create producer %d\n", i);
     106                                }
    103107                        }
    104108                }
Note: See TracChangeset for help on using the changeset viewer.