diff options
author | Richard Braun <rbraun@sceen.net> | 2018-05-14 21:47:27 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2018-05-14 21:47:27 +0200 |
commit | 16cb249e8ca911ebca4c7b57751f9e95581ca0e9 (patch) | |
tree | 1a305ff4e46112fad3e7058f8e0c485e0e76723b | |
parent | a06a044cb86860b84dc142b7c88eb87f81f6ff29 (diff) |
kern/thread: make thread_create slightly more convenient
Don't require the caller to pass a pointer to the newly created thread.
-rw-r--r-- | kern/thread.c | 4 | ||||
-rw-r--r-- | kern/thread.h | 3 |
2 files changed, 6 insertions, 1 deletions
diff --git a/kern/thread.c b/kern/thread.c index 85e557d3..e79ef311 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -2367,7 +2367,9 @@ thread_create(struct thread **threadp, const struct thread_attr *attr, * The new thread address must be written before the thread is started * in case it's passed to it. */ - *threadp = thread; + if (threadp) { + *threadp = thread; + } thread_wakeup(thread); diff --git a/kern/thread.h b/kern/thread.h index 4bead755..6e696fc7 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -182,6 +182,9 @@ void thread_ap_setup(void); * Creation attributes must be passed, but some of them may be NULL, in which * case the value is inherited from the caller. The name attribute must not be * NULL. + * + * If successful, and if the caller passed a non-NULL thread pointer, it is + * filled with the address of the newly created thread. */ int thread_create(struct thread **threadp, const struct thread_attr *attr, void (*fn)(void *), void *arg); |