nuttx/sched/pthread
chao an df30a1f8d3 sched/pthread/join: refactor pthread join to support join task
1. add support to join main task

| static pthread_t self;
|
| static void *join_task(void *arg)
| {
|   int ret;
|   ret = pthread_join(self, NULL);          <---  /* Fix Task could not be joined */
|   return NULL;
| }
|
| int main(int argc, char *argv[])
| {
|   pthread_t thread;
|
|   self = pthread_self();
|
|   pthread_create(&thread, NULL, join_task, NULL);
|   sleep(1);
|
|   pthread_exit(NULL);
|   return 0;
| }

2. Detach active thread will not alloc for additional join, just update the task flag.
3. Remove the return value waiting lock logic (data_sem),
   the return value will be stored in the waiting tcb.
4. Revise the return value of pthread_join(), consistent with linux
   e.g:
       Joining a detached and canceled thread should return EINVAL, not ESRCH

   https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_join.html

   [EINVAL]
      The value specified by thread does not refer to a joinable thread.

NOTE:

This PR will not increase stack usage, but struct tcb_s will increase 32 bytes.

Signed-off-by: chao an <anchao@lixiang.com>
2024-03-13 18:06:56 +09:00
..
CMakeLists.txt cmake:complete missing changes during cmake reforming for sched 2023-09-08 21:20:16 +03:00
Make.defs system: pthread_barrierwait should be moved to kernel space 2023-04-25 15:34:40 +08:00
pthread_barrierwait.c sched/pthread/barrierwait: replace syscall(2) to kernel api 2023-10-25 09:18:55 +08:00
pthread_cancel.c sched/pthread: Don't do cancel when it is already in the exit process 2023-08-03 03:12:36 -07:00
pthread_completejoin.c sched/pthread/join: refactor pthread join to support join task 2024-03-13 18:06:56 +09:00
pthread_condbroadcast.c sched: Remove the unnecessary (FAR sem_t *) cast 2022-10-29 21:12:40 +02:00
pthread_condclockwait.c signal: remove unused SIGCONDTIMEDOUT 2023-03-23 17:17:25 -06:00
pthread_condsignal.c sched: Remove the unnecessary (FAR sem_t *) cast 2022-10-29 21:12:40 +02:00
pthread_condwait.c sched/pthread: fix race condition on pthread_cond_wait() 2023-06-28 02:25:05 +08:00
pthread_create.c sched/pthread/join: refactor pthread join to support join task 2024-03-13 18:06:56 +09:00
pthread_detach.c sched/pthread/join: refactor pthread join to support join task 2024-03-13 18:06:56 +09:00
pthread_exit.c sched: fix pthread_exit crash 2023-06-28 15:17:17 +08:00
pthread_findjoininfo.c sched/pthread/join: refactor pthread join to support join task 2024-03-13 18:06:56 +09:00
pthread_getaffinity.c Don't include assert.h from public header file 2021-06-03 08:36:03 -07:00
pthread_getschedparam.c sched: Remove "0x" prefix preceding "%p" specifier on format string 2022-06-30 22:08:58 +03:00
pthread_initialize.c sched/pthread: add missing FAR and fix alignment issues 2023-07-07 17:39:39 -03:00
pthread_join.c sched/pthread/join: refactor pthread join to support join task 2024-03-13 18:06:56 +09:00
pthread_mutex.c Remove intr param from pthread_mutex_take 2022-12-08 03:13:44 +08:00
pthread_mutexconsistent.c sched: Remove the unnecessary (FAR sem_t *) cast 2022-10-29 21:12:40 +02:00
pthread_mutexdestroy.c sched: Remove the unnecessary (FAR sem_t *) cast 2022-10-29 21:12:40 +02:00
pthread_mutexinconsistent.c sched: Author Gregory Nutt: update licenses to Apache 2021-02-09 01:21:53 -08:00
pthread_mutexinit.c sched: Remove the unnecessary (FAR sem_t *) cast 2022-10-29 21:12:40 +02:00
pthread_mutextimedlock.c sched/pthread: repalce sched_lock to enter_critical_section 2023-04-24 01:54:44 +08:00
pthread_mutextrylock.c sched/getpid: replace syscall getpid/tid/ppid() to kernel version 2023-02-02 10:33:01 +08:00
pthread_mutexunlock.c pthread: sched_lock should replace with enter_critical_secion 2023-05-06 23:12:20 +08:00
pthread_release.c sched/pthread/join: refactor pthread join to support join task 2024-03-13 18:06:56 +09:00
pthread_setaffinity.c Don't include assert.h from public header file 2021-06-03 08:36:03 -07:00
pthread_setschedparam.c sched: Remove "0x" prefix preceding "%p" specifier on format string 2022-06-30 22:08:58 +03:00
pthread_setschedprio.c Run nxstyle against all .c and .h files modified by this PR. 2020-05-09 14:19:08 -03:00
pthread_sigmask.c ltp: sigprocmask fix 2023-07-31 22:29:31 -07:00
pthread.h sched/pthread/join: refactor pthread join to support join task 2024-03-13 18:06:56 +09:00