From b3f3dd123c181fe851f0a9756bed7acd4ba4ef7d Mon Sep 17 00:00:00 2001
From: patacongo
-
Last Updated: January 12, 2013
+Last Updated: January 13, 2013
CONFIG_SCHED_HAVE_PARENT
: Remember the ID of the parent thread when a new child thread is created.
- This support enables a few minor features (such as SIGCHLD
) and slightly increases the size of the Task Control Block (TCB) of every task to hold the ID of the parent thread.
+ This support enables some additional features (such as SIGCHLD
) and modifies the behavior of other interfaces.
+ For example, it makes waitpid()
more standards complete by restricting the waited-for tasks to the children of the caller.
Default: disabled.
CONFIG_SCHED_LPWORKPERIOD
: How often the lower priority worker thread checks for work in units of microseconds. Default: 50*1000 (50 MS).
CONFIG_SCHED_LPWORKSTACKSIZE - The stack size allocated for the lower priority worker thread. Default: CONFIG_IDLETHREAD_STACKSIZE.
+ CONFIG_SCHED_LPWORKSTACKSIZE
: The stack size allocated for the lower priority worker thread. Default: CONFIG_IDLETHREAD_STACKSIZE.
CONFIG_SCHED_WAITPID
: Enables the waitpid()
API
+ CONFIG_SCHED_WAITPID
: Enables the waitpid()
interface in a default, non-standard mode (non-standard in the sense that the waited for PID need not be child of the caller).
+ If SCHED_HAVE_PARENT
is also defined, then this setting will modify the behavior or waitpid()
(making more spec compliant) and will enable the waitid()
and waitp()
interfaces as well.
CONFIG_SCHED_ATEXIT
: Enables the atexit() API
diff --git a/nuttx/Documentation/NuttxUserGuide.html b/nuttx/Documentation/NuttxUserGuide.html
index c6eabd29a..3cfb63f11 100644
--- a/nuttx/Documentation/NuttxUserGuide.html
+++ b/nuttx/Documentation/NuttxUserGuide.html
@@ -13,7 +13,7 @@
User's Manual
by
Gregory Nutt
-
Last Updated: January 11, 2013
+Last Updated: January 13, 2013
@@ -1776,8 +1776,10 @@ priority of the calling task is returned.Task synchronization interfaces
- The following discussion is a general description of the@@ -2038,7 +2042,158 @@ on this thread of execution. Comparable to the POSIX interface of the same name, but the implementation is incomplete (as detailed above). -waitpid(
) interface. - However, as of this writing, the implementation ofwaitpid()
is fragmentary (but usable). - It simply supports waiting for any task to complete execution. - NuttX does not support any concept of parent/child processes or of process groups nor signals related to child processes (SIGCHLD
). + The following discussion is a general description of thewaitpid()
interface. + However, as of this writing, the implementation ofwaitpid()
is incomplete (but usable). + IfCONFIG_SCHED_HAVE_PARENT
is defined,waitpid()
will be a little more compliant to specifications. + WithoutCONFIG_SCHED_HAVE_PARENT
,waitpid()
simply supports waiting for any task to complete execution. + WithCONFIG_SCHED_HAVE_PARENT
,waitpid()
will useSIGCHLD
and can, therefore, wait for any child of the parent to complete. + The implementation is incomplete in either case, however: NuttX does not support any concept of process groups. Nor does NuttX retain the status of exited tasks so ifwaitpid()
is called after a task has exited, then no status will be available. The options argument is currently ignored.
+Function Prototype: +
+ #include <sys/wait.h> + #ifdef CONFIG_SCHED_HAVE_PARENT + int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options); + #endif ++
+ Description: +
++ The following discussion is a general description of the+waitid()
interface. + However, as of this writing, the implementation ofwaitid()
is incomplete (but usable). + IfCONFIG_SCHED_HAVE_PARENT
is defined,waitid()
will be a little more compliant to specifications. +waitpid()
simply supports waiting a specific child task (P_PID
or for any child taskP_ALL
to complete execution. +SIGCHLD
is used. + The implementation is incomplete in either case, however: NuttX does not support any concept of process groups. + Nor does NuttX retain the status of exited tasks so ifwaitpid()
is called after a task has exited, then no status will be available. + The options argument is currently ignored. +
+ The waitid()
function suspends the calling thread until one child of the process containing the calling thread changes state.
+ It records the current state of a child in the structure pointed to by info
.
+ If a child process changed state prior to the call to waitid()
, waitid()
returns immediately.
+ If more than one thread is suspended in wait()
or waitpid()
waiting termination of the same process, exactly one thread will return the process status at the time of the target process termination
+
+ The idtype
and id
arguments are used to specify which children waitid()
will wait for.
+
+
idtype
is P_PID, waitid()
will wait for the child with a process ID equal to (pid_t)id
.
+ idtype
is P_PGID, waitid()
will wait for any child with a process group ID equal to (pid_t)id
.
+ idtype
is P_ALL, waitid()
will wait for any children and id
is ignored.
+
+ The options
argument is used to specify which state changes waitid()
will will wait for.
+ It is formed by OR-ing together one or more of the following flags:
+
WEXITED
:
+ Wait for processes that have exited.
+ WSTOPPED
:
+ Status will be returned for any child that has stopped upon receipt of a signal.
+ WCONTINUES
:
+ Status will be returned for any child that was stopped and has been continued.
+ WNOHANG
:
+ Return immediately if there are no children to wait for.
+ WNOWAIT
:
+ Keep the process whose status is returned in info
in a waitable state.
+ This will not affect the state of the process;
+ the process may be waited for again after this call completes.
+ info
argument must point to a siginfo_t
structure.
+ If waitid()
returns because a child process was found that satisfied the conditions indicated by the arguments idtype
and options, then the structure pointed to by info
will be filled in by the system with the status of the process.
+ The si_signo
member will always be equal to SIGCHLD
.
+
++ Input Parameters: + See the description above. +
+
+ Returned Value:
+ If waitid()
returns due to the change of state of one of its children, 0 is returned.
+ Otherwise, -1 is returned and errno
is set to indicate the error.
+
+ The waitid()
function will fail if:
+
ECHILD
:
+ EINTR
:
+ waitid()
function was interrupted by a signal.
+ EINVAL
:
+ An invalid value was specified for options
, or idtype
and id
specify an invalid set of processes.
+ + Assumptions/Limitations: +
+ POSIX Compatibility: + Comparable to the POSIX interface of the same name, but the implementation is incomplete (as detailed in the description above). +
+ ++Function Prototype: +
+ #include <sys/wait.h> + #ifdef CONFIG_SCHED_HAVE_PARENT + pid_t wait(FAR int *stat_loc); + #endif ++
+ Description: +
++ The following discussion is a general description of the+wait()
interface. + However, as of this writing, the implementation ofwait()
is incomplete (but usable). +wait()
is based onwaitpaid()
. + See the description ofwaitpaid()
for further information. +
+ The wait()
function will suspend execution of the calling thread until status information for one of its terminated child processes is available, or until delivery of a signal whose action is either to execute a signal-catching function or to terminate the process.
+ If more than one thread is suspended in wait()
awaiting termination of the same process, exactly one thread will return the process status at the time of the target process termination.
+ If status information is available prior to the call towait()
, return will be immediate.
+
+ The waitpid()
function will behave identically to wait()
, if its pid
argument is (pid_t)-1 and the options argument is 0.
+ Otherwise, its behavior will be modified by the values of the pid
and options
arguments.
+
+ Input Parameters: +
+stat_loc
. The location to return the exit status
+ Returned Value:
+ See the values returned by waitpaid()
.
+
+ Assumptions/Limitations: +
+ POSIX Compatibility:
+ Comparable to the POSIX interface of the same name, but the implementation is incomplete (as detailed in the description waitpaid()
).
+
Function Prototype: @@ -2077,7 +2232,7 @@ on this thread of execution.
atexit()
functions are not inherited when a new task is created.Function Prototype: @@ -9023,9 +9178,9 @@ notify a task when a message is available on a queue.