lpc1788 update from Rommel Marcelo; Beginning of logic to retain child exit status

git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5549 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2013-01-22 23:42:51 +00:00
parent 7dad51762d
commit 336f91b4e6
12 changed files with 1331 additions and 828 deletions
+52 -18
View File
@@ -62,21 +62,30 @@
/* This is the maximum number of times that a lock can be set */
#define MAX_LOCK_COUNT 127
#define MAX_LOCK_COUNT 127
/* Values for the _TCB flags flag bits */
#define TCB_FLAG_TTYPE_SHIFT (0) /* Bits 0-1: thread type */
#define TCB_FLAG_TTYPE_MASK (3 << TCB_FLAG_TTYPE_SHIFT)
# define TCB_FLAG_TTYPE_TASK (0 << TCB_FLAG_TTYPE_SHIFT) /* Normal user task */
# define TCB_FLAG_TTYPE_PTHREAD (1 << TCB_FLAG_TTYPE_SHIFT) /* User pthread */
# define TCB_FLAG_TTYPE_KERNEL (2 << TCB_FLAG_TTYPE_SHIFT) /* Kernel thread */
#define TCB_FLAG_NONCANCELABLE (1 << 2) /* Bit 2: Pthread is non-cancelable */
#define TCB_FLAG_CANCEL_PENDING (1 << 3) /* Bit 3: Pthread cancel is pending */
#define TCB_FLAG_ROUND_ROBIN (1 << 4) /* Bit 4: Round robin sched enabled */
#define TCB_FLAG_TTYPE_SHIFT (0) /* Bits 0-1: thread type */
#define TCB_FLAG_TTYPE_MASK (3 << TCB_FLAG_TTYPE_SHIFT)
# define TCB_FLAG_TTYPE_TASK (0 << TCB_FLAG_TTYPE_SHIFT) /* Normal user task */
# define TCB_FLAG_TTYPE_PTHREAD (1 << TCB_FLAG_TTYPE_SHIFT) /* User pthread */
# define TCB_FLAG_TTYPE_KERNEL (2 << TCB_FLAG_TTYPE_SHIFT) /* Kernel thread */
#define TCB_FLAG_NONCANCELABLE (1 << 2) /* Bit 2: Pthread is non-cancelable */
#define TCB_FLAG_CANCEL_PENDING (1 << 3) /* Bit 3: Pthread cancel is pending */
#define TCB_FLAG_ROUND_ROBIN (1 << 4) /* Bit 4: Round robin sched enabled */
/* Values for struct child_status_s ch_flags */
#define CHILD_FLAG_TTYPE_SHIFT (0) /* Bits 0-1: child thread type */
#define CHILD_FLAG_TTYPE_MASK (3 << CHILD_FLAG_TTYPE_SHIFT)
# define CHILD_FLAG_TTYPE_TASK (0 << CHILD_FLAG_TTYPE_SHIFT) /* Normal user task */
# define CHILD_FLAG_TTYPE_PTHREAD (1 << CHILD_FLAG_TTYPE_SHIFT) /* User pthread */
# define CHILD_FLAG_TTYPE_KERNEL (2 << CHILD_FLAG_TTYPE_SHIFT) /* Kernel thread */
#define CHILD_FLAG_EXITED (1 << 0) /* Bit 2: The child thread has exit'ed */
/********************************************************************************
* Global Type Definitions
* Public Type Definitions
********************************************************************************/
#ifndef __ASSEMBLY__
@@ -163,6 +172,22 @@ typedef struct environ_s environ_t;
# define SIZEOF_ENVIRON_T(alloc) (sizeof(environ_t) + alloc - 1)
#endif
/* This structure is used to maintin information about child tasks.
* pthreads work differently, they have join information. This is
* only for child tasks.
*/
#ifdef CONFIG_SCHED_CHILD_STATUS
struct child_status_s
{
FAR struct child_status_s *flink;
uint8_t ch_flags; /* Child status: See CHILD_FLAG_* definitions */
pid_y ch_pid; /* Child task ID */
int ch_status; /* Child exit status */
};
#endif
/* This structure describes a reference counted D-Space region. This must be a
* separately allocated "break-away" structure that can be owned by a task and
* any pthreads created by the task.
@@ -202,9 +227,13 @@ struct _TCB
/* Task Management Fields *****************************************************/
pid_t pid; /* This is the ID of the thread */
#ifdef CONFIG_SCHED_HAVE_PARENT
#ifdef CONFIG_SCHED_HAVE_PARENT /* Support parent-child relationship */
pid_t parent; /* This is the ID of the parent thread */
#ifdef CONFIG_SCHED_CHILD_STATUS /* Retain child thread status */
FAR struct child_status_s *children; /* Head of a list of child status */
#else
uint16_t nchildren; /* This is the number active children */
#endif
#endif
start_t start; /* Thread start function */
entry_t entry; /* Entry Point into the thread */
@@ -357,33 +386,38 @@ typedef void (*sched_foreach_t)(FAR _TCB *tcb, FAR void *arg);
#endif /* __ASSEMBLY__ */
/********************************************************************************
* Global Function Prototypes
* Public Data
********************************************************************************/
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
extern "C"
{
#else
#define EXTERN extern
#endif
/********************************************************************************
* Public Function Prototypes
********************************************************************************/
/* TCB helpers */
EXTERN FAR _TCB *sched_self(void);
FAR _TCB *sched_self(void);
/* File system helpers */
#if CONFIG_NFILE_DESCRIPTORS > 0
EXTERN FAR struct filelist *sched_getfiles(void);
FAR struct filelist *sched_getfiles(void);
#if CONFIG_NFILE_STREAMS > 0
EXTERN FAR struct streamlist *sched_getstreams(void);
FAR struct streamlist *sched_getstreams(void);
#endif /* CONFIG_NFILE_STREAMS */
#endif /* CONFIG_NFILE_DESCRIPTORS */
#if CONFIG_NSOCKET_DESCRIPTORS > 0
EXTERN FAR struct socketlist *sched_getsockets(void);
FAR struct socketlist *sched_getsockets(void);
#endif /* CONFIG_NSOCKET_DESCRIPTORS */
/* Internal vfork support.The overall sequence is:
@@ -417,7 +451,7 @@ void task_vforkabort(FAR _TCB *child, int errcode);
* will be disabled throughout this enumeration!
*/
EXTERN void sched_foreach(sched_foreach_t handler, FAR void *arg);
void sched_foreach(sched_foreach_t handler, FAR void *arg);
#undef EXTERN
#if defined(__cplusplus)
+35 -30
View File
@@ -79,7 +79,7 @@
#endif
/********************************************************************************
* Global Type Definitions
* Public Type Definitions
********************************************************************************/
/* This is the POSIX-like scheduling parameter structure */
@@ -90,56 +90,61 @@ struct sched_param
};
/********************************************************************************
* Global Function Prototypes
* Public Data
********************************************************************************/
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
extern "C"
{
#else
#define EXTERN extern
#endif
/********************************************************************************
* Public Function Prototypes
********************************************************************************/
/* Task Control Interfaces (non-standard) */
#ifndef CONFIG_CUSTOM_STACK
EXTERN int task_init(FAR _TCB *tcb, const char *name, int priority,
FAR uint32_t *stack, uint32_t stack_size,
main_t entry, const char *argv[]);
int task_init(FAR _TCB *tcb, const char *name, int priority,
FAR uint32_t *stack, uint32_t stack_size, main_t entry,
FAR const char *argv[]);
#else
EXTERN int task_init(FAR _TCB *tcb, const char *name, int priority,
main_t entry, const char *argv[]);
int task_init(FAR _TCB *tcb, const char *name, int priority, main_t entry,
FAR const char *argv[]);
#endif
EXTERN int task_activate(FAR _TCB *tcb);
int task_activate(FAR _TCB *tcb);
#ifndef CONFIG_CUSTOM_STACK
EXTERN int task_create(const char *name, int priority, int stack_size,
main_t entry, const char *argv[]);
int task_create(FAR const char *name, int priority, int stack_size, main_t entry,
FAR const char *argv[]);
#else
EXTERN int task_create(const char *name, int priority,
main_t entry, const char *argv[]);
int task_create(FAR const char *name, int priority, main_t entry,
FAR const char *argv[]);
#endif
EXTERN int task_delete(pid_t pid);
EXTERN int task_restart(pid_t pid);
int task_delete(pid_t pid);
int task_restart(pid_t pid);
/* Task Scheduling Interfaces (based on POSIX APIs) */
EXTERN int sched_setparam(pid_t pid, const struct sched_param *param);
EXTERN int sched_getparam(pid_t pid, struct sched_param *param);
EXTERN int sched_setscheduler(pid_t pid, int policy,
const struct sched_param *param);
EXTERN int sched_getscheduler(pid_t pid);
EXTERN int sched_yield(void);
EXTERN int sched_get_priority_max(int policy);
EXTERN int sched_get_priority_min(int policy);
EXTERN int sched_rr_get_interval(pid_t pid, struct timespec *interval);
int sched_setparam(pid_t pid, const struct sched_param *param);
int sched_getparam(pid_t pid, struct sched_param *param);
int sched_setscheduler(pid_t pid, int policy,
FAR const struct sched_param *param);
int sched_getscheduler(pid_t pid);
int sched_yield(void);
int sched_get_priority_max(int policy);
int sched_get_priority_min(int policy);
int sched_rr_get_interval(pid_t pid, FAR struct timespec *interval);
/* Task Switching Interfaces (non-standard) */
EXTERN int sched_lock(void);
EXTERN int sched_unlock(void);
EXTERN int sched_lockcount(void);
int sched_lock(void);
int sched_unlock(void);
int sched_lockcount(void);
/* If instrumentation of the scheduler is enabled, then some outboard logic
* must provide the following interfaces.
@@ -147,9 +152,9 @@ EXTERN int sched_lockcount(void);
#ifdef CONFIG_SCHED_INSTRUMENTATION
EXTERN void sched_note_start(FAR _TCB *tcb);
EXTERN void sched_note_stop(FAR _TCB *tcb);
EXTERN void sched_note_switch(FAR _TCB *pFromTcb, FAR _TCB *pToTcb);
void sched_note_start(FAR _TCB *tcb);
void sched_note_stop(FAR _TCB *tcb);
void sched_note_switch(FAR _TCB *pFromTcb, FAR _TCB *pToTcb);
#else
# define sched_note_start(t)