nuttx/sched/task
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 sched/pthread/join: refactor pthread join to support join task 2024-03-13 18:06:56 +09:00
exit.c libc/stdio: Flush streams in userspace when process exits 2022-12-22 20:16:11 +08:00
Make.defs sched/pthread/join: refactor pthread join to support join task 2024-03-13 18:06:56 +09:00
spawn.h sched/task: Remove spawn_proxyattrs as obsolete implementation 2023-10-30 22:30:03 +08:00
task_activate.c sched/logging: add task activation/exit logs 2024-01-14 23:04:42 -08:00
task_cancelpt.c task/pthread_cancelpt: Fix task_delete from another task group 2023-11-22 08:05:58 -08:00
task_create.c sched/tcb: add free tcb flag to support static tcb 2024-03-04 20:05:11 +08:00
task_delete.c sched: fix the minor style issue 2023-10-25 15:46:45 +08:00
task_execve.c libc/exit: Purge calls to userspace API exit() from kernel 2023-02-17 23:07:17 +08:00
task_exit.c sched/logging: add task activation/exit logs 2024-01-14 23:04:42 -08:00
task_exithook.c sched/group: change type of task group member to single queue 2024-03-07 12:39:29 +08:00
task_fork.c sched/pthread/join: refactor pthread join to support join task 2024-03-13 18:06:56 +09:00
task_getgroup.c sched/group: replace group_findbypid to task_getgroup 2024-03-05 22:24:52 +08:00
task_getpid.c sched/task: add kernel interface nxsched_* gettid/getpid/getppid 2023-02-02 10:33:01 +08:00
task_getppid.c sched/task: add kernel interface nxsched_* gettid/getpid/getppid 2023-02-02 10:33:01 +08:00
task_gettid.c sched/task: add kernel interface nxsched_* gettid/getpid/getppid 2023-02-02 10:33:01 +08:00
task_init.c sched/pthread/join: refactor pthread join to support join task 2024-03-13 18:06:56 +09:00
task_join.c sched/pthread/join: refactor pthread join to support join task 2024-03-13 18:06:56 +09:00
task_posixspawn.c sched/task: Remove spawn_proxyattrs as obsolete implementation 2023-10-30 22:30:03 +08:00
task_prctl.c
task_recover.c sched/mqueue: make mqueue and mqueue sysv can disable separately 2022-11-16 20:03:40 +08:00
task_reparent.c sched/group: replace group_findbypid to task_getgroup 2024-03-05 22:24:52 +08:00
task_restart.c semantic/parser: fix compile warning found by sparse 2023-05-30 23:00:00 +08:00
task_setup.c sched/task: save argument counter to avoid limit check 2024-03-05 22:25:28 +08:00
task_spawn.c sched/tcb: add free tcb flag to support static tcb 2024-03-04 20:05:11 +08:00
task_spawnparms.c sched/taskfiles: skip unnecessary file open/close operations to improve performance 2023-11-16 07:30:36 -08:00
task_start.c sched/task: save argument counter to avoid limit check 2024-03-05 22:25:28 +08:00
task_starthook.c
task_terminate.c sched: Fix nxstyle errors 2023-05-11 11:25:58 -03:00
task.h sched/pthread/join: refactor pthread join to support join task 2024-03-13 18:06:56 +09:00