Skip to content
Snippets Groups Projects
NuttxUserGuide.html 178 KiB
Newer Older
patacongo's avatar
patacongo committed
<pre>
patacongo's avatar
patacongo committed
    #include &lt;pthread.h&gt;
    int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
				  const struct timespec *abstime);
patacongo's avatar
patacongo committed
</pre>
<p>
  <b>Description:</b>
</p>
<p>
  <b>Input Parameters:</b>
</p>
<p>
<ul>
patacongo's avatar
patacongo committed
  <li><code>To be provided</code>.</li>
patacongo's avatar
patacongo committed
</ul>
<p>
  <b>Returned Values:</b>
</p>
<p>
  If successful, the <code>pthread_cond_timedwait()</code> function will return
  zero (<code>OK</code>).  Otherwise, an error number will be
  returned to indicate the error:
</p>
<ul>
patacongo's avatar
patacongo committed
  <li><code>To be provided</code>. </li>
patacongo's avatar
patacongo committed
5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503
</ul>
<p>
  <b>Assumptions/Limitations:</b>
</p>
<p>
  <b>POSIX Compatibility:</b> Comparable to the POSIX interface of the same name.
</p>

<h3><a name="pthreadbarrierattrinit">2.9.43 pthread_barrierattr_init</a></h3>
<p>
  <b>Function Prototype:</b>
</p>
<pre>
    #include &lt;pthread.h&gt;
    int pthread_barrierattr_init(FAR pthread_barrierattr_t *attr);
</pre>
<p>
  <b>Description:</b>
  The <code>pthread_barrierattr_init()</code> function will initialize a barrier
  attribute object <code>attr</code> with the default value for all of the attributes
  defined by the implementation.
</p>
<p>
  <b>Input Parameters:</b>
</p>
<ul>
  <li>
    <code>attr</code>. Barrier attributes to be initialized.
</li>
</ul>
<p>
  <b>Returned Values:</b>
  0 (<code>OK</code>) on success or <code>EINVAL</code> if <code>attr</code> is invalid.
</p>
<p>
  <b>Assumptions/Limitations:</b>
</p>
<p>
  <b>POSIX Compatibility:</b> Comparable to the POSIX interface of the same name.
</p>

<h3><a name="pthreadbarrierattrdestroy">2.9.44 pthread_barrierattr_destroy</a></h3>
<p>
  <b>Function Prototype:</b>
</p>
<pre>
    #include &lt;pthread.h&gt;
    int pthread_barrierattr_destroy(FAR pthread_barrierattr_t *attr);
</pre>
<p>
  <b>Description:</b>
  The <code>pthread_barrierattr_destroy()</code> function will destroy a barrier attributes object.
  A destroyed attributes object can be reinitialized using <code>pthread_barrierattr_init()</code>;
  the results of otherwise referencing the object after it has been destroyed are undefined.
</p>
<p>
  <b>Input Parameters:</b>
</p>
<ul>
  <li>
    <code>attr</code>. Barrier attributes to be destroyed.
</li>
</ul>
<p>
  <b>Returned Values:</b> 0 (OK) on success or EINVAL if attr is invalid.
</p>
<p>
  <b>Assumptions/Limitations:</b>
</p>
<p>
  <b>POSIX Compatibility:</b> Comparable to the POSIX interface of the same name.
</p>

<h3><a name="pthreadbarrierattrsetpshared">2.9.45 pthread_barrierattr_setpshared</a></h3>
<p>
  <b>Function Prototype:</b>
</p>
<pre>
    #include &lt;pthread.h&gt;
    int pthread_barrierattr_setpshared(FAR pthread_barrierattr_t *attr, int pshared);
</pre>
<p>
  <b>Description:</b>
  The process-shared attribute is set to <code>PTHREAD_PROCESS_SHARED</code> to permit
  a barrier to be operated upon by any thread that has access to the memory where the
  barrier is allocated.
  If the process-shared attribute is <code>PTHREAD_PROCESS_PRIVATE</code>, the barrier can
  only be operated upon by threads created within the same process as the thread that
  initialized the barrier.
  If threads of different processes attempt to operate on such a barrier, the behavior is undefined.
  The default value of the attribute is <code>PTHREAD_PROCESS_PRIVATE</code>.
</p>
<p>
  <b>Input Parameters:</b>
</p>
<ul>
  <li><code>attr</code>. Barrier attributes to be modified.</li>
  <li><code>pshared</code>. The new value of the pshared attribute.</li>
</ul>
<p>
  <b>Returned Values:</b>  0 (<code>OK</code>) on success or <code>EINVAL</code> if either
  <code>attr</code> is invalid or <code>pshared</code> is not one of
  <code>PTHREAD_PROCESS_SHARED</code> or <code>PTHREAD_PROCESS_PRIVATE</code>.
</p>
<p>
  <b>Assumptions/Limitations:</b>
</p>
<p>
  <b>POSIX Compatibility:</b> Comparable to the POSIX interface of the same name.
</p>

<h3><a name="pthreadbarrierattrgetpshared">2.9.46 pthread_barrierattr_getpshared</a></h3>
<p>
  <b>Function Prototype:</b>
</p>
<pre>
    #include &lt;pthread.h&gt;
    int pthread_barrierattr_getpshared(FAR const pthread_barrierattr_t *attr, FAR int *pshared);
</pre>
<p>
  <b>Description:</b>
  The <code>pthread_barrierattr_getpshared()</code> function will obtain the value of the
  process-shared attribute from the attributes object referenced by <code>attr</code>.
</p>
<p>
  <b>Input Parameters:</b>
</p>
<p>
<ul>
  <li><code>attr</code>. Barrier attributes to be queried.</li>
  <li><code>pshared</code>. The location to stored the current value of the pshared attribute.</li>
</ul>
<p>
  <b>Returned Values:</b> 0 (<code>OK</code>) on success or <code>EINVAL</code> if
  either <code>attr</code> or <code>pshared</code> is invalid.
</p>
<p>
  <b>Assumptions/Limitations:</b>
</p>
<p>
  <b>POSIX Compatibility:</b> Comparable to the POSIX interface of the same name.
</p>

<h3><a name="pthreadbarrierinit">2.9.47 pthread_barrier_init</a></h3>
<p>
  <b>Function Prototype:</b>
</p>
<pre>
    #include &lt;pthread.h&gt;
    int pthread_barrier_init(FAR pthread_barrier_t *barrier,
                             FAR const pthread_barrierattr_t *attr, unsigned int count);
</pre>
<p>
  <b>Description:</b>
  The <code>pthread_barrier_init()</code> function allocates any resources required to
  use the barrier referenced by <code>barrier</code> and initialized the barrier with
  the attributes referenced by <code>attr</code>. 
  If <code>attr</code> is NULL, the default barrier attributes will be used.
  The results are undefined if <code>pthread_barrier_init()</code> is called when any
  thread is blocked on the barrier.
  The results are undefined if a barrier is used without first being initialized.
  The results are undefined if <code>pthread_barrier_init()</code> is called specifying
  an already initialized barrier.
</p>
<p>
  <b>Input Parameters:</b>
</p>
<ul>
  <li>
    <code>barrier</code>.
    The barrier to be initialized.
  </li>
  <li>
    <code>attr</code>.
    Barrier attributes to be used in the initialization.
  </li>
  <li>
    <code>count</code>.
    The count to be associated with the barrier.
    The count argument specifies the number of threads that must call
    <code>pthread_barrier_wait()</code> before any of them successfully return from the call.
    The value specified by count must be greater than zero.
  </li>
</ul>
<p>
  <b>Returned Values:</b>0 (OK) on success or on of the following error numbers:
</p>
<ul>
  <li>
    <code>EAGAIN</code>.
    The system lacks the necessary resources to initialize another barrier.
  </li>
  <li>
    <code>EINVAL</code>.
    The barrier reference is invalid, or the values specified by attr are invalid, or
    the value specified by count is equal to zero.
  </li>
  <li>
    <code>ENOMEM</code>.
    Insufficient memory exists to initialize the barrier.
  </li>
  <li>
    <code>EBUSY</code>.
    The implementation has detected an attempt to reinitialize a barrier while it is in use.
  </li>
</ul>
<p>
  <b>Assumptions/Limitations:</b>
</p>
<p>
  <b>POSIX Compatibility:</b> Comparable to the POSIX interface of the same name.
</p>

<h3><a name="pthreadbarrierdestroy">2.9.48 pthread_barrier_destroy</a></h3>
<p>
  <b>Function Prototype:</b>
</p>
<pre>
    #include &lt;pthread.h&gt;
    int pthread_barrier_destroy(FAR pthread_barrier_t *barrier);
</pre>
<p>
  <b>Description:</b>
  The <code>pthread_barrier_destroy()</code> function destroys the barrier referenced
  by <code>barrie</code> and releases any resources used by the barrier.
  The effect of subsequent use of the barrier is undefined until the barrier is
  reinitialized by another call to <code>pthread_barrier_init()</code>.
  The results are undefined if <code>pthread_barrier_destroy()</code> is called when
  any thread is blocked on the barrier, or if this function is called with an
  uninitialized barrier.
</p>
<p>
  <b>Input Parameters:</b>
</p>
<ul>
  <li><code>barrier</code>. The barrier to be destroyed.</li>
</ul>
<p>
  <b>Returned Values:</b> 0 (<code>OK</code>) on success or on of the following error numbers:
</p>
<ul>
  <li>
    <code>EBUSY</code>.
    The implementation has detected an attempt to destroy a barrier while it is in use.
  </li>
  <li>
    <code>EINVAL</code>.
    The value specified by barrier is invalid.
  </li>
</ul>
<p>
  <b>Assumptions/Limitations:</b>
</p>
<p>
  <b>POSIX Compatibility:</b> Comparable to the POSIX interface of the same name.
</p>

<h3><a name="pthreadbarrierwait">2.9.49 pthread_barrier_wait</a></h3>
<p>
  <b>Function Prototype:</b>
</p>
<pre>
    #include &lt;pthread.h&gt;
    int pthread_barrier_wait(FAR pthread_barrier_t *barrier);
</pre>
<p>
  <b>Description:</b>
  The <code>pthread_barrier_wait()</code> function synchronizse participating
  threads at the barrier referenced by <code>barrier</code>.
  The calling thread is blocked until the required number of threads have called
  <code>pthread_barrier_wait()</code> specifying the same <code>barrier</code>.
  When the required number of threads have called <code>pthread_barrier_wait()</code>
  specifying the <code>barrier</code>, the constant <code>PTHREAD_BARRIER_SERIAL_THREAD</code>
  will be returned to one unspecified thread and zero will be returned to each of
  the remaining threads.
  At this point, the barrier will be reset to the state it had as a result of the most
  recent <code>pthread_barrier_init()</code> function that referenced it.
</p>
<p>
  The constant <code>PTHREAD_BARRIER_SERIAL_THREAD</code> is defined in 
 <code>pthread.h</code> and its value must be distinct from any other value
  returned by <code>pthread_barrier_wait()</code>.
</p>
<p>
  The results are undefined if this function is called with an uninitialized barrier.
</p>
<p>
  If a signal is delivered to a thread blocked on a barrier, upon return from the
  signal handler the thread will resume waiting at the barrier if the barrier wait
  has not completed.
  Otherwise, the thread will continue as normal from the completed barrier wait.
  Until the thread in the signal handler returns from it, it is unspecified whether
  other threads may proceed past the barrier once they have all reached it.
</p>
<p>
  A thread that has blocked on a barrier will not prevent any unblocked thread that
  is eligible to use the same processing resources from eventually making forward
  progress in its execution.
  Eligibility for processing resources will be determined by the scheduling policy.
</p>
<p>
  <b>Input Parameters:</b>
</p>
<ul>
  <li><code>barrier</code>. The barrier on which to wait.</li>
</ul>
<p>
  <b>Returned Values:</b> 0 (<code>OK</code>) on success or <code>EINVAL</code> if the barrier is not valid.
</p>
<p>
  <b>Assumptions/Limitations:</b>
</p>
<p>
  <b>POSIX Compatibility:</b> Comparable to the POSIX interface of the same name.
</p>


<h3><a name="pthreadonce">2.9.50 pthread_once</a></h3>
<p>
  <b>Function Prototype:</b>
</p>
<pre>
    #include &lt;pthread.h&gt;
    int pthread_once(FAR pthread_once_t *once_control, CODE void (*init_routine)(void));
</pre>
<p>
  <b>Description:</b>
  The  first  call to <code>pthread_once()</code> by any thread with a given
  <code>once_control</code>, will call the <code>init_routine()</code> with no arguments.
  Subsequent calls to <code>pthread_once()</code> with the same <code>once_control</code> will have no effect.
  On return from <code>pthread_once()</code>, <code>init_routine()</code> will have completed.
</p>
<p>
  <b>Input Parameters:</b>
</p>
<p>
<ul>
  <li>
    <code>once_control</code>.
    Determines if <code>init_routine()</code> should be called.
    <code>once_control</code> should be declared and intialized as follows:
    <ul><pre>pthread_once_t once_control = PTHREAD_ONCE_INIT;
    </pre></ul>
    <code>PTHREAD_ONCE_INIT</code> is defined in <code>pthread.h</code>.
  </li>
  <li>
    <code>init_routine</code>.
    The initialization routine that will be called once.
  </li>
</ul>
<p>
  <b>Returned Values:</b>
  0 (OK) on success or EINVAL if either once_control or init_routine are invalid.
</p>
<p>
  <b>Assumptions/Limitations:</b>
</p>
<p>
  <b>POSIX Compatibility:</b> Comparable to the POSIX interface of the same name.
</p>

<h3><a name="pthreadkill">2.9.51 pthread_kill</a></h3>
<p>
  <b>Function Prototype:</b>
</p>
<pre>
    #include &lt;signal.h&gt;
    #include &lt;pthread.h&gt;
    int pthread_kill(pthread_t thread, int signo)
</pre>
<p>
  <b>Description:</b>
  The <code>pthread_kill()</code> system call can be used to send any
  signal to a thread.  See <code>kill()</code> for further information
  as this is just a simple wrapper around the <code>kill()</code>
  function.
</p>
<p>
  <b>Input Parameters:</b>
</p>
<p>
<ul>
  <li>
    <code>thread</code>.
    The id of the thread to receive the signal. Only positive, non-zero values of <code>tthread</code>t are supported.
  </li>
  <li>
    <code>signo</code>.
    The signal number to send.  If <code>signo</code> is zero, no signal is sent, but all error checking is performed.
  </li>
</ul>
<p>
  <b>Returned Values:</b>
</p>
<p>
  On success, the signal was sent and zero is returned.
  On error one of the following error numbers is returned.
</p>
<ul>
  <li>
    <code>EINVAL</code>.
    An invalid signal was specified.
  </li>
  <li>
    <code>EPERM</code>.
    The thread does not have permission to send the signal to the target thread.
  </li>
  <li>
    <code>ESRCH</code>.
    No thread could be found corresponding to that specified by the given thread ID.
  </li>
  <li>
    <code>ENOSYS</code>.
    Do not support sending signals to process groups.
  </li>
</ul>
<p>
  <b>Assumptions/Limitations:</b>
</p>
<p>
  <b>POSIX Compatibility:</b> Comparable to the POSIX interface of the same name.
</p>

<h3><a name="pthreadsigmask">2.9.52 pthread_sigmask</a></h3>
<p>
  <b>Function Prototype:</b>
</p>
<pre>
    #include &lt;signal.h&gt;
    #include &lt;pthread.h&gt;
    int pthread_sigmask(int how, FAR const sigset_t *set, FAR sigset_t *oset);
</pre>
<p>
  <b>Description:</b>
  This function is a simple wrapper around <code>sigprocmask()</code>.
  See the <code>sigprocmask()</code> function description for further information.
</p>
<p>
  <b>Input Parameters:</b>
</p>
<p>
<ul>
  <li>
    <code>how</code>. How the signal mast will be changed:
    <ul>
      <li>
        <code>SIG_BLOCK</code>:
        The resulting set is the union of the current set and the signal set pointed to by <code>set</code>.
      </li>
      <li>
        <code>SIG_UNBLOCK</code>:
        The resulting set is the intersection of the current set and the complement of the signal set pointed to by <code>set</code>.
      </li>
      <li>
        <code>SIG_SETMASK</code>:
        The resulting set is the signal set pointed to by <code>set</code>.
      </li>
    </ul>
  </li>
  <li>
    <code>set</code>. Location of the new signal mask.
  </li>
  <li>
    <code>oset</code>. Location to store the old signal mask.
  </li>
</ul>
<p>
  <b>Returned Values:</b>
</p>
<p>
  0 (OK) on succes or EINVAL if <code>how</code> is invalid.
</p>
<p>
  <b>Assumptions/Limitations:</b>
</p>
<p>
  <b>POSIX Compatibility:</b> Comparable to the POSIX interface of the same name.
</p>
patacongo's avatar
patacongo committed

patacongo's avatar
patacongo committed
<hr>
<h1>3.0 <A NAME="Data_Structures">OS Data Structures</a></h1>
patacongo's avatar
patacongo committed
<H2>3.1 Scalar types</H2>
patacongo's avatar
patacongo committed
<p>
Many of the types used to communicate with NuttX are simple
patacongo's avatar
patacongo committed
scalar types. These types are used to provide architecture independence
of the OS from the application. The scalar types used at the NuttX
patacongo's avatar
patacongo committed
interface include:
patacongo's avatar
patacongo committed
<ul>
<li>pid_t
<li>size_t
<li>sigset_t
<li>STATUS
<li>time_t
</ul>
patacongo's avatar
patacongo committed

<H2>3.2 Hidden Interface Structures</H2>
patacongo's avatar
patacongo committed
<p>
Several of the types used to interface with NuttX are
patacongo's avatar
patacongo committed
structures that are intended to be hidden from the application.
From the standpoint of the application, these structures (and
structure pointers) should be treated as simple handles to reference
OS resources. These hidden structures include:
patacongo's avatar
patacongo committed
<ul>
<li>_TCB
<li>mqd_t
<li>sem_t
<li>WDOG_ID
<li>pthread_key_t
</ul>
<p>
patacongo's avatar
patacongo committed
In order to maintain portability, applications should not reference
specific elements within these hidden structures. These hidden
structures will not be described further in this user's manual.
patacongo's avatar
patacongo committed
<p>
patacongo's avatar
patacongo committed

<H2>3.3. Access to the <I>errno</I> Variable</H2>
patacongo's avatar
patacongo committed
<p>
patacongo's avatar
patacongo committed
A pointer to the thread-specific <I>errno</I>. value is available through a
function call:
patacongo's avatar
patacongo committed
<p>
<b>Function Prototype:</b>
<p>
<pre>    int *get_errno_ptr( void )</pre>
patacongo's avatar
patacongo committed
<p>
<b>Description</b>:  <I>osGetErrnorPtr()</I> returns a pointer to
patacongo's avatar
patacongo committed
the thread-specific <I>errno</I> value.
patacongo's avatar
patacongo committed
<p>
patacongo's avatar
patacongo committed
This differs somewhat from the use for errno in a multi-threaded process environment:
Each pthread will have its own private copy of errno and the errno will not be shared
between pthreads.
patacongo's avatar
patacongo committed
<p>
<b>Input Parameters</b>:  None
<p>
<b>Returned Values</b>:
<p>
<ul>
<li>A pointer to the thread-specific <I>errno</I> value.
</ul>
<p>
patacongo's avatar
patacongo committed

<H2>3.4 User Interface Structures</H2>
patacongo's avatar
patacongo committed
<p>
patacongo's avatar
patacongo committed
<H3>3.4.1 main_t</H3>
patacongo's avatar
patacongo committed
<p>
patacongo's avatar
patacongo committed
main_t defines the type of a task entry point. main_t is declared
in sys/types.h as:
patacongo's avatar
patacongo committed
    typedef int (*main_t)(int argc, char *argv[]);
patacongo's avatar
patacongo committed

<H3>3.4.2 struct sched_param</H3>

patacongo's avatar
patacongo committed
<p>
patacongo's avatar
patacongo committed
This structure is used to pass scheduling priorities to and from
patacongo's avatar
patacongo committed
    struct sched_param
    {
      int sched_priority;
    };
patacongo's avatar
patacongo committed

<H3>3.4.3 struct timespec</H3>

patacongo's avatar
patacongo committed
<p>
patacongo's avatar
patacongo committed
This structure is used to pass timing information between the
patacongo's avatar
patacongo committed
    struct timespec
    {
      time_t tv_sec;  /* Seconds */
      long   tv_nsec; /* Nanoseconds */
    };
patacongo's avatar
patacongo committed

<H3>3.4.4 struct mq_attr</H3>

patacongo's avatar
patacongo committed
<p>
patacongo's avatar
patacongo committed
This structure is used to communicate message queue attributes
between NuttX and a MoBY application:
patacongo's avatar
patacongo committed
    struct mq_attr {
      size_t       mq_maxmsg;   /* Max number of messages in queue */
      size_t       mq_msgsize;  /* Max message size */
      unsigned     mq_flags;    /* Queue flags */
      size_t       mq_curmsgs;  /* Number of messages currently in queue */
    };
patacongo's avatar
patacongo committed

<H3>3.4.5 struct sigaction</H3>

patacongo's avatar
patacongo committed
<p>
patacongo's avatar
patacongo committed
The following structure defines the action to take for given signal:
    struct sigaction
    {
      union
      {
        void (*_sa_handler)(int);
        void (*_sa_sigaction)(int, siginfo_t *, void *);
patacongo's avatar
patacongo committed
      } sa_u;
      sigset_t           sa_mask;
      int                sa_flags;
    };
    #define sa_handler   sa_u._sa_handler
    #define sa_sigaction sa_u._sa_sigaction
patacongo's avatar
patacongo committed

<H3>3.4.6 struct siginfo/siginfo_t</H3>

patacongo's avatar
patacongo committed
<p>
patacongo's avatar
patacongo committed
The following types is used to pass parameters to/from signal
handlers:
patacongo's avatar
patacongo committed
    typedef struct siginfo
    {
      int          si_signo;
      int          si_code;
      union sigval si_value;
   } siginfo_t;
patacongo's avatar
patacongo committed

<H3>3.4.7 union sigval</H3>

patacongo's avatar
patacongo committed
<p>
patacongo's avatar
patacongo committed
This defines the type of the struct siginfo si_value field and
is used to pass parameters with signals.
patacongo's avatar
patacongo committed
    union sigval
    {
      int   sival_int;
      void *sival_ptr;
    };
patacongo's avatar
patacongo committed

<H3>3.4.8 struct sigevent</H3>

patacongo's avatar
patacongo committed
<p>
patacongo's avatar
patacongo committed
The following is used to attach a signal to a message queue to
notify a task when a message is available on a queue.
patacongo's avatar
patacongo committed
    struct sigevent
    {
      int          sigev_signo;
      union sigval sigev_value;
      int          sigev_notify;
    };

<H3>3.4.9 Watchdog Data Types</H3>

<p>
  When a watchdog expires, the callback function with this
  type is called:
</p>
<pre>
    typedef void (*wdentry_t)(int argc, ...);
</pre>
<p>
  Where argc is the number of uint32 type arguments that follow.
</p>
  The arguments are passed as uint32 values.
  For systems where the sizeof(pointer) &lt; sizeof(uint32), the
  following union defines the alignment of the pointer within the
  uint32.  For example, the SDCC MCS51 general pointer is
  24-bits, but uint32 is 32-bits (of course).
</p>
<pre>
    union wdparm_u
    {
      void   *pvarg;
      uint32 *dwarg;
    };
    typedef union wdparm_u wdparm_t;
</pre>
<p>
  For most 32-bit systems, pointers and uint32 are the same size
  For systems where sizeof(pointer) > sizeof(uint32), we will
  have to do some redesign.
</p>

<h1><a name="FileSystem">2.10 Filesystem Interfaces</a></h1>
<p>
  The NuttX filesystem is very simple; it does not involve any block drivers or
  particular filesystem (like FAT or EXT2 etc.).
  The NuttX filesystem simply supports a set a filesystem APIs
  (<code>open()</code>, <code>close()</code>, <code>read()</code>, <code>write</code>, etc.)
  and a registration mechanism that allows devices drivers to a associated with <i>nodes</i>
  in a file-system-like name space.
</p>

<h2><a name="driveroperations">2.10.1 Driver Operations</a></h2>
<ul><pre>
  #include &lt;fcntl.h&gt;
  int open(const char *path, int oflag, ...);
</pre></ul>

<ul><pre>
  #include &lt;unistd.h&gt;
  int   close(int fd);
  int   dup(int fildes);
  int   dup2(int fildes1, int fildes2);
  off_t lseek(int fd, off_t offset, int whence);           /* Prototyped but not implemented */
  int   read(int fd, void *buf, unsigned int nbytes);
  int   unlink(const char *path);
  int   write(int fd, const void *buf, unsigned int nbytes);
</pre></ul>

<ul><pre>
  #include &lt;sys/ioctl.h&gt;
  int    ioctl(int fd, int req, unsigned long arg);
</pre></ul>

<h2><a name="directoryoperations">2.10.2 Directory Operations</a></h2>
<ul><pre>
  #include &lt;dirent.h&gt;
  int        closedir(DIR *dirp);
  FAR DIR   *opendir(const char *path);
  FAR struct dirent *readdir(FAR DIR *dirp);
  int        readdir_r(FAR DIR *dirp, FAR struct dirent *entry, FAR struct dirent **result);
  void       rewinddir(FAR DIR *dirp);
  void       seekdir(FAR DIR *dirp, int loc);
  int        telldir(FAR DIR *dirp);
</pre></ul>

<h2><a name="standardio">2.10.3 Standard I/O</a></h2>
<ul><pre>
  #include &lt;stdio.h&gt;
  int    fclose(FILE *stream);
  int    fflush(FILE *stream);
  int    feof(FILE *stream);                               /* Prototyped but not implemented */
  int    ferror(FILE *stream);                             /* Prototyped but not implemented */
  int    fgetc(FILE *stream);
  char  *fgets(char *s, int n, FILE *stream);
  FILE  *fopen(const char *path, const char *type);
  int    fprintf(FILE *stream, const char *format, ...);
  int    fputc(int c, FILE *stream);
  int    fputs(const char *s, FILE *stream);
  size_t fread(void *ptr, size_t size, size_t n_items, FILE *stream);
  int    fseek(FILE *stream, long int offset, int whence); /* Prototyped but not implemented */
  size_t fwrite(const void *ptr, size_t size, size_t n_items, FILE *stream);
  char  *gets(char *s);

  int    printf(const char *format, ...);
  int    puts(const char *s);
  int    rename(const char *source, const char *target);   /* Prototyped but not implemented */
  int    sprintf(char *dest, const char *format, ...);
  int    ungetc(int c, FILE *stream);
  int    vprintf(const char *s, va_list ap);
  int    vfprintf(FILE *stream, const char *s, va_list ap);
  int    vsprintf(char *buf, const char *s, va_list ap);

  int    chdir(const char *path);                          /* Prototyped but not implemented */
  FILE  *fdopen(int fd, const char *type);
  int    fstat(int fd, FAR struct stat *buf);              /* Prototyped but not implemented */
  char  *getcwd(FAR char *buf, size_t size);               /* Prototyped but not implemented */
  int    mkdir(const char *path, mode_t mode);             /* Prototyped but not implemented */
  int    rmdir(const char *path);                          /* Prototyped but not implemented */
  int    stat(const char *path, FAR struct stat *buf);     /* Prototyped but not implemented */
  int    statfs(const char *path, FAR struct statfs *buf); /* Prototyped but not implemented */
patacongo's avatar
patacongo committed
<h1><a name="index">Index</a></h1>
<ul>
  <li><a href="#clockgetres">clock_getres</a></li>
  <li><a href="#clockgettime">clock_gettime</a></li>
  <li><a href="#ClocksNTimers">Clocks</a></li>
  <li><a href="#clocksettime">clock_settime</a></li>
  <li><a href="#Data_Structures">Data structures</a></li>
  <li><a href="#directoryoperations">Directory operations</a></li>
  <li><a href="#driveroperations">Driver operations</a></li>
patacongo's avatar
patacongo committed
  <li><a href="#exit">exit</a></li>
  <li><a href="#FileSystem">Filesystem interfaces</a></li>
patacongo's avatar
patacongo committed
  <li><a href="#getpid">getpid</a></li>
  <li><a href="#gmtimer">gmtime_r</a></li>
patacongo's avatar
patacongo committed
  <li><a href="#Introduction">Introduction</a>
  <li><a href="#kill">kill</a></li>
  <li><a href="#localtimer">localtime_r</a></li>
patacongo's avatar
patacongo committed
  <li><a href="#Message_Queue">Named Message Queue Interfaces</a>
  <li><a href="#mktime">mktime</a></li>
patacongo's avatar
patacongo committed
  <li><a href="#mqclose">mq_close</a></li>
  <li><a href="#mqgetattr">mq_getattr</a></li>
  <li><a href="#mqnotify">mq_notify</a></li>
  <li><a href="#mqopen">mq_open</a></li>
  <li><a href="#mqreceive">mq_receive</a></li>
  <li><a href="#mqsend">mq_send</a></li>
  <li><a href="#mqsetattr">mq_setattr</a></li>
  <li><a href="#mqtimedreceive">mq_timedreceive</a></li>
  <li><a href="#mqtimedsend">mq_timedsend</a></li>
patacongo's avatar
patacongo committed
  <li><a href="#mqunlink">mq_unlink</a></li>
  <li><a href="#OS_Interfaces">OS Interfaces</a>
patacongo's avatar
patacongo committed
  <li><a href="#Pthread">Pthread Interfaces</a>
patacongo's avatar
patacongo committed
  <li><a href="#pthreadattrdestroy">pthread_attr_destroy</a></li>
  <li><a href="#pthreadattrgetinheritsched">pthread_attr_getinheritsched</a></li>
  <li><a href="#pthreadattrgetschedparam">pthread_attr_getschedparam</a></li>
  <li><a href="#pthreadattrgetschedpolicy">pthread_attr_getschedpolicy</a></li>
  <li><a href="#pthreadattrgetstacksize">0 pthread_attr_getstacksize</a></li>
  <li><a href="#pthreadattrinit">pthread_attr_init</a></li>
  <li><a href="#pthreadattrsetinheritsched">pthread_attr_setinheritsched</a></li>
  <li><a href="#pthreadattrsetschedparam">pthread_attr_setschedparam</a></li>
  <li><a href="#pthreadattrsetschedpolity">pthread_attr_setschedpolicy</a></li>
  <li><a href="#pthreadattrsetstacksize">pthread_attr_setstacksize</a></li>
patacongo's avatar
patacongo committed
  <li><a href="#pthreadbarrierattrinit">pthread_barrierattr_init</a></li>
  <li><a href="#pthreadbarrierattrdestroy">pthread_barrierattr_destroy</a></li>
  <li><a href="#pthreadbarrierattrgetpshared">pthread_barrierattr_getpshared</a></li>
  <li><a href="#pthreadbarrierattrsetpshared">pthread_barrierattr_setpshared</a></li>
  <li><a href="#pthreadbarrierdestroy">pthread_barrier_destroy</a></li>
  <li><a href="#pthreadbarrierinit">pthread_barrier_init</a></li>
  <li><a href="#pthreadbarrierwait">pthread_barrier_wait</a></li>
patacongo's avatar
patacongo committed
  <li><a href="#pthreadcancel">pthread_cancel</a></li>
  <li><a href="#pthreadconaddrinit">pthread_condattr_init</a></li>
  <li><a href="#pthreadcondbroadcast">pthread_cond_broadcast</a></li>
  <li><a href="#pthreadconddestroy">pthread_cond_destroy</a></li>
  <li><a href="#pthreadcondinit">pthread_cond_init</a></li>
  <li><a href="#pthreadcondsignal">pthread_cond_signal</a></li>
  <li><a href="#pthreadcondtimedwait">pthread_cond_timedwait</a></li>
  <li><a href="#pthreadcondwait">pthread_cond_wait</a></li>
  <li><a href="#pthreadcreate">pthread_create</a></li>
  <li><a href="#pthreaddetach">pthread_detach</a></li>
  <li><a href="#pthreadexit">pthread_exit</a></li>
  <li><a href="#pthreadgetschedparam">pthread_getschedparam</a></li>
  <li><a href="#pthreadgetspecific">pthread_getspecific</a></li>
  <li><a href="#Pthread"><i>pthreads</i></a> share some resources.
  <li><a href="#pthreadjoin">pthread_join</a></li>
  <li><a href="#pthreadkeycreate">pthread_key_create</a></li>
  <li><a href="#pthreadkeydelete">pthread_key_delete</a></li>
patacongo's avatar
patacongo committed
  <li><a href="#pthreadkill">pthread_kill</a></li>
patacongo's avatar
patacongo committed
  <li><a href="#pthreadmutexattrdestroy">pthread_mutexattr_destroy</a></li>
  <li><a href="#pthreadmutexattrgetpshared">pthread_mutexattr_getpshared</a></li>
  <li><a href="#pthreadmutexattrinit">pthread_mutexattr_init</a></li>
  <li><a href="#pthreadmutexattrsetpshared">pthread_mutexattr_setpshared</a></li>
  <li><a href="#pthreadmutexdestrory">pthread_mutex_destroy</a></li>
  <li><a href="#pthreadmutexinit">pthread_mutex_init</a></li>
  <li><a href="#pthreadmutexlock">pthread_mutex_lock</a></li>
  <li><a href="#pthreadmutextrylock">pthread_mutex_trylock</a></li>
  <li><a href="#pthreadmutexunlock">pthread_mutex_unlock</a></li>
  <li><a href="#pthreadocndattrdestroy">pthread_condattr_destroy</a></li>
patacongo's avatar
patacongo committed
  <li><a href="#pthreadonce">pthread_once</a></li>
patacongo's avatar
patacongo committed
  <li><a href="#pthreadself">pthread_self</a></li>
  <li><a href="#pthreadsetcancelstate">pthread_setcancelstate</a></li>
  <li><a href="#pthreadsetschedparam">pthread_setschedparam</a></li>
  <li><a href="#pthreadsetspecific">pthread_setspecific</a></li>
patacongo's avatar
patacongo committed
  <li><a href="#pthreadsigmask">pthread_sigmask</a></li>
patacongo's avatar
patacongo committed
  <li><a href="#pthreadtestcancelstate">pthread_testcancelstate</a></li>
  <li><a href="#pthreadyield">pthread_yield</a></li>
  <li><a href="#schedgetparam">sched_getparam</a></li>
  <li><a href="#schedgetprioritymax">sched_get_priority_max</a></li>
  <li><a href="#schedgetprioritymin">sched_get_priority_min</a></li>
  <li><a href="#schedgetrrinterval">sched_get_rr_interval</a></li>
  <li><a href="#schedlockcount">sched_lockcount</a></li>
  <li><a href="#schedlock">sched_lock</a></li>
  <li><a href="#schedsetparam">sched_setparam</a></li>
  <li><a href="#schedsetscheduler">sched_setscheduler</a></li>
  <li><a href="#schedunlock">sched_unlock</a></li>
  <li><a href="#sched_yield">sched_yield</a></li>
  <li><a href="#Semaphores">Counting Semaphore Interfaces</a>
  <li><a href="#semclose">sem_close</a></li>
  <li><a href="#semdestroy">sem_destroy</a></li>
  <li><a href="#semgetvalue">sem_getvalue</a></li>
  <li><a href="#seminit">sem_init</a></li>
  <li><a href="#semopen">sem_open</a></li>
  <li><a href="#sempost">sem_post</a></li>
  <li><a href="#semtrywait">sem_trywait</a></li>
  <li><a href="#semunlink">sem_unlink</a></li>
  <li><a href="#semwait">sem_wait</a></li>
  <li><a href="#setgetscheduler">sched_getscheduler</a></li>
  <li><a href="#sigaction">sigaction</a></li>
  <li><a href="#sigaddset">sigaddset</a></li>
  <li><a href="#sigdelset">sigdelset</a></li>
  <li><a href="#sigemptyset">sigemptyset</a></li>
  <li><a href="#sigfillset">sigfillset</a></li>
  <li><a href="#sigismember">sigismember</a></li>
  <li><a href="#Signals">Signal Interfaces</a>
  <li><a href="#sigpending">sigpending</a></li>
  <li><a href="#sigprocmask">sigprocmask</a></li>
  <li><a href="#sigqueue">sigqueue</a></li>
  <li><a href="#sigsuspend">sigsuspend</a></li>
  <li><a href="#sigtimedwait">sigtimedwait</a></li>
  <li><a href="#sigwaitinfo">sigwaitinfo</a></li>
  <li><a href="#standardio">Standard I/O</a></li>
patacongo's avatar
patacongo committed
  <li><a href="#taskactivate">task_activate</a></li>
  <li><a href="#Task_Control">Task Control Interfaces</a>
  <li><a href="#taskcreate">task_create</a></li>
  <li><a href="#taskdelete">task_delete</a></li>
  <li><a href="#taskinit">task_init</a></li>
  <li><a href="#taskrestart">task_restart</a></li>
  <li><a href="#Task_Schedule">Task Scheduling Interfaces</a>
  <li><a href="#Task_Switch">Task Switching Interfaces</a>
  <li><a href="#timercreate">timer_create</a></li>
  <li><a href="#timerdelete">timer_delete</a></li>
  <li><a href="#timergetoverrun">timer_getoverrun</a></li>
  <li><a href="#timergettime">timer_gettime</a></li>
  <li><a href="#ClocksNTimers">Timers</a></li>
  <li><a href="#timersettime">timer_settime</a></li>
patacongo's avatar
patacongo committed
  <li><a href="#Watchdogs">Watchdog Timer Interfaces</a>
  <li><a href="#wdcancel">wd_cancel</a></li>
  <li><a href="#wdcreate">wd_create</a></li>
  <li><a href="#wddelete">wd_delete</a></li>
  <li><a href="#wdgettime">wd_gettime</a></li>
patacongo's avatar
patacongo committed
  <li><a href="#wdstart">wd_start</a></li>
</ul>

patacongo's avatar
patacongo committed
</BODY>
</HTML>