mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 17:33:08 +08:00
libc: Move pthread_create to user space
Signed-off-by: Huang Qi <huangqi3@xiaomi.com> Change-Id: I5c447d94077debc79158686935f288e4c8e51e01
This commit is contained in:
@@ -569,9 +569,10 @@ void up_task_start(main_t taskentry, int argc, FAR char *argv[])
|
||||
* pthread by calling this function.
|
||||
*
|
||||
* Normally the a user-mode start-up stub will also execute before the
|
||||
* pthread actually starts. See libc/pthread/pthread_startup.c
|
||||
* pthread actually starts. See libc/pthread/pthread_create.c
|
||||
*
|
||||
* Input Parameters:
|
||||
* startup - The user-space pthread startup function
|
||||
* entrypt - The user-space address of the pthread entry point
|
||||
* arg - Standard argument for the pthread entry point
|
||||
*
|
||||
@@ -584,7 +585,8 @@ void up_task_start(main_t taskentry, int argc, FAR char *argv[])
|
||||
|
||||
#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) && \
|
||||
!defined(CONFIG_DISABLE_PTHREAD)
|
||||
void up_pthread_start(pthread_startroutine_t entrypt, pthread_addr_t arg)
|
||||
void up_pthread_start(pthread_trampoline_t startup,
|
||||
pthread_startroutine_t entrypt, pthread_addr_t arg);
|
||||
noreturn_function;
|
||||
#endif
|
||||
|
||||
|
||||
+29
-1
@@ -100,7 +100,7 @@
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -111,6 +111,10 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* Default pthread attributes. This global can only be shared within the
|
||||
* kernel- or within the user- address space.
|
||||
*/
|
||||
@@ -121,6 +125,30 @@ EXTERN const pthread_attr_t g_default_pthread_attr;
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_pthread_create
|
||||
*
|
||||
* Description:
|
||||
* This function creates and activates a new thread with specified
|
||||
* attributes.
|
||||
*
|
||||
* Input Parameters:
|
||||
* trampoline
|
||||
* thread
|
||||
* attr
|
||||
* start_routine
|
||||
* arg
|
||||
*
|
||||
* Returned Value:
|
||||
* OK (0) on success; a (non-negated) errno value on failure. The errno
|
||||
* variable is not set.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread,
|
||||
FAR const pthread_attr_t *attr,
|
||||
pthread_startroutine_t entry, pthread_addr_t arg);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -770,6 +770,7 @@ struct pthread_tcb_s
|
||||
|
||||
/* Task Management Fields *****************************************************/
|
||||
|
||||
pthread_trampoline_t trampoline; /* User-space pthread startup function */
|
||||
pthread_addr_t arg; /* Startup argument */
|
||||
FAR void *joininfo; /* Detach-able info to support join */
|
||||
};
|
||||
|
||||
@@ -100,13 +100,9 @@ struct userspace_s
|
||||
|
||||
FAR struct mm_heap_s *us_heap;
|
||||
|
||||
/* Task/thread startup routines */
|
||||
/* Task startup routine */
|
||||
|
||||
CODE void (*task_startup)(main_t entrypt, int argc, FAR char *argv[]);
|
||||
#ifndef CONFIG_DISABLE_PTHREAD
|
||||
CODE void (*pthread_startup)(pthread_startroutine_t entrypt,
|
||||
pthread_addr_t arg);
|
||||
#endif
|
||||
|
||||
/* Signal handler trampoline */
|
||||
|
||||
@@ -136,26 +132,6 @@ extern "C"
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pthread_startup
|
||||
*
|
||||
* Description:
|
||||
* This function is the user-space, pthread startup function. It is called
|
||||
* from up_pthread_start() in user-mode.
|
||||
*
|
||||
* Input Parameters:
|
||||
* entrypt - The user-space address of the pthread entry point
|
||||
* arg - Standard argument for the pthread entry point
|
||||
*
|
||||
* Returned Value:
|
||||
* None. This function does not return.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if !defined(__KERNEL__) && !defined(CONFIG_DISABLE_PTHREAD)
|
||||
void pthread_startup(pthread_startroutine_t entrypt, pthread_addr_t arg);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -225,6 +225,8 @@ typedef FAR void *pthread_addr_t;
|
||||
typedef CODE pthread_addr_t (*pthread_startroutine_t)(pthread_addr_t);
|
||||
typedef pthread_startroutine_t pthread_func_t;
|
||||
|
||||
typedef void (*pthread_trampoline_t)(pthread_startroutine_t, pthread_addr_t);
|
||||
|
||||
struct pthread_attr_s
|
||||
{
|
||||
uint8_t priority; /* Priority of the pthread */
|
||||
|
||||
@@ -305,7 +305,7 @@ SYSCALL_LOOKUP(telldir, 1)
|
||||
SYSCALL_LOOKUP(pthread_cond_broadcast, 1)
|
||||
SYSCALL_LOOKUP(pthread_cond_signal, 1)
|
||||
SYSCALL_LOOKUP(pthread_cond_wait, 2)
|
||||
SYSCALL_LOOKUP(pthread_create, 4)
|
||||
SYSCALL_LOOKUP(nx_pthread_create, 5)
|
||||
SYSCALL_LOOKUP(pthread_detach, 1)
|
||||
SYSCALL_LOOKUP(pthread_exit, 1)
|
||||
SYSCALL_LOOKUP(pthread_getschedparam, 3)
|
||||
|
||||
Reference in New Issue
Block a user