Add a start hook that can be setup to call a function in the context of a new thread before the new threads main() has been called.

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5571 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2013-01-27 15:52:58 +00:00
parent 4c3b71131e
commit 151dfee1f9
15 changed files with 237 additions and 55 deletions
+22 -2
View File
@@ -183,7 +183,13 @@ union entry_u
};
typedef union entry_u entry_t;
/* These is the types of the functions that are executed with exit() is called
/* This is the type of the function called at task startup */
#ifdef CONFIG_SCHED_STARTHOOK
typedef CODE void (*starthook_t)(FAR void *arg);
#endif
/* These are the types of the functions that are executed with exit() is called
* (if registered via atexit() on on_exit()).
*/
@@ -298,7 +304,10 @@ struct task_group_s
#endif
/* PIC data space and address environments ************************************/
/* Not yet (see struct dspace_s) */
/* Logically the PIC data space belongs here (see struct dspace_s). The
* current logic needs review: There are differences in the away that the
* life of the PIC data is managed.
*/
/* File descriptors ***********************************************************/
@@ -354,6 +363,11 @@ struct _TCB
start_t start; /* Thread start function */
entry_t entry; /* Entry Point into the thread */
#ifdef CONFIG_SCHED_STARTHOOK
starthook_t starthook; /* Task startup function */
FAR void *starthookarg; /* The argument passed to the function */
#endif
#if defined(CONFIG_SCHED_ATEXIT) && !defined(CONFIG_SCHED_ONEXIT)
# if defined(CONFIG_SCHED_ATEXIT_MAX) && CONFIG_SCHED_ATEXIT_MAX > 1
atexitfunc_t atexitfunc[CONFIG_SCHED_ATEXIT_MAX];
@@ -516,6 +530,12 @@ FAR struct streamlist *sched_getstreams(void);
FAR struct socketlist *sched_getsockets(void);
#endif /* CONFIG_NSOCKET_DESCRIPTORS */
/* Setup up a start hook */
#ifdef CONFIG_SCHED_STARTHOOK
void task_starthook(FAR _TCB *tcb, starthook_t starthook, FAR void *arg);
#endif
/* Internal vfork support.The overall sequence is:
*
* 1) User code calls vfork(). vfork() is provided in architecture-specific