Newer
Older
<p>
<ul>
<li><code>To be provided</code>. </li>
</ul>
<b>Assumptions/Limitations:</b>
<p>
<b>POSIX Compatibility:</b> Comparable to the POSIX
<H3><a name="pthreadmutexlock">2.9.34 pthread_mutex_lock</a></H3>
#include <pthread.h>
int pthread_mutex_lock(pthread_mutex_t *mutex);
The mutex object referenced by mutex is locked by calling <code>pthread_mutex_lock()</code>.
If the mutex is already locked, the calling thread blocks until the mutex
becomes available. This operation returns with the mutex object referenced
by mutex in the locked state with the calling thread as its owner.
</p>
<p>
If the mutex type is <code>PTHREAD_MUTEX_NORMAL</code>, deadlock detection is not provided.
Attempting to re-lock the mutex causes deadlock. If a thread attempts to unlock
a mutex that it has not locked or a mutex which is unlocked, undefined behavior
results.
</p>
<p>
In NuttX, <code>PTHREAD_MUTEX_NORMAL</code> is not implemented. Rather, the behavior described
for <code>PTHREAD_MUTEX_ERRORCHECK</code> is the <i>normal</i> behavior.
</p>
<p>
If the mutex type is <code>PTHREAD_MUTEX_ERRORCHECK</code>, then error checking is provided.
If a thread attempts to re-lock a mutex that it has already locked, an error
will be returned. If a thread attempts to unlock a mutex that it has not
locked or a mutex which is unlocked, an error will be returned.
</p>
<p>
If the mutex type is <code>PTHREAD_MUTEX_RECURSIVE</code>, then the mutex maintains the concept
of a lock count. When a thread successfully acquires a mutex for the first time,
the lock count is set to one. Every time a thread re-locks this mutex, the lock count
is incremented by one. Each time the thread unlocks the mutex, the lock count is
decremented by one. When the lock count reaches zero, the mutex becomes available
for other threads to acquire. If a thread attempts to unlock a mutex that it has
not locked or a mutex which is unlocked, an error will be returned.
</p>
<p>
If a signal is delivered to a thread waiting for a mutex, upon return from
the signal handler the thread resumes waiting for the mutex as if it was
not interrupted.
</p>
<li><code>mutex</code>. A reference to the mutex to be locked.</li>
If successful, the <I>pthread_mutex_lock()</I> function will return zero (<I>OK</I>).
Otherwise, an error number will be returned to indicate the error:
<p>
<ul>
<li><code>To be provided</code>. </li>
</ul>
<p>Note that this function will never return the error EINTR.</p>
<b>Assumptions/Limitations:</b>
<p>
<b>POSIX Compatibility:</b> Comparable to the POSIX
<H3><a name="pthreadmutextrylock">2.9.35 pthread_mutex_trylock</a></H3>
#include <pthread.h>
int pthread_mutex_trylock(pthread_mutex_t *mutex);
The function pthread_mutex_trylock() is identical to <a href="#pthreadmutexlock"><code>pthread_mutex_lock()</code></a>
except that if the mutex object referenced by mutex is currently locked
(by any thread, including the current thread), the call returns immediately
with the errno <code>EBUSY</code>.
<p>
If a signal is delivered to a thread waiting for a mutex, upon return from
the signal handler the thread resumes waiting for the mutex as if it was
not interrupted.
</p>
<li><code>mutex</code>. A reference to the mutex to be locked.</li>
If successful, the <I>pthread_mutex_trylock()</I> function will return zero (<I>OK</I>).
Otherwise, an error number will be returned to indicate the error:
<p>
<ul>
<li><code>To be provided</code>. </li>
</ul>
<p>Note that this function will never return the error EINTR.</p>
<b>Assumptions/Limitations:</b>
<p>
<b>POSIX Compatibility:</b> Comparable to the POSIX
<H3><a name="pthreadmutexunlock">2.9.36 pthread_mutex_unlock</a></H3>
#include <pthread.h>
int pthread_mutex_unlock(pthread_mutex_t *mutex);
The <code>pthread_mutex_unlock()</code> function releases the mutex object referenced
by mutex. The manner in which a mutex is released is dependent upon the
mutex's type attribute. If there are threads blocked on the mutex object
referenced by mutex when <code>pthread_mutex_unlock()</code> is called, resulting in
the mutex becoming available, the scheduling policy is used to determine
which thread shall acquire the mutex. (In the case of <code>PTHREAD_MUTEX_RECURSIVE</code>
mutexes, the mutex becomes available when the count reaches zero and the
calling thread no longer has any locks on this mutex).
</p>
<p>
If a signal is delivered to a thread waiting for a mutex, upon return from
the signal handler the thread resumes waiting for the mutex as if it was
not interrupted.
</p>
If successful, the <I>pthread_mutex_unlock()</I> function will return
zero (<I>OK</I>). Otherwise, an error number will be
returned to indicate the error:
<p>
<ul>
<li><code>To be provided</code>. </li>
</ul>
<p>Note that this function will never return the error EINTR.</p>
<b>Assumptions/Limitations:</b>
<p>
<b>POSIX Compatibility:</b> Comparable to the POSIX
<H3><a name="pthreadconaddrinit">2.9.37 pthread_condattr_init</a></H3>
#include <pthread.h>
int pthread_condattr_init(pthread_condattr_t *attr);
<p>
<b>Description:</b>
<p>
<b>Input Parameters:</b>
<p>
<ul>
<li><code>To be provided</code>.</li>
</ul>
<p>
<b>Returned Values:</b>
<p>
If successful, the <I>pthread_condattr_init()</I> function will return
zero (<I>OK</I>). Otherwise, an error number will be
returned to indicate the error:
<p>
<ul>
<li><code>To be provided</code>. </li>
</ul>
<b>Assumptions/Limitations:</b>
<p>
<b>POSIX Compatibility:</b> Comparable to the POSIX
<H3><a name="pthreadocndattrdestroy">2.9.38 pthread_condattr_destroy</a></H3>
#include <pthread.h>
int pthread_condattr_destroy(pthread_condattr_t *attr);
<p>
<b>Description:</b>
<p>
<b>Input Parameters:</b>
<p>
<ul>
<li><code>To be provided</code>.</li>
</ul>
<p>
<b>Returned Values:</b>
<p>
If successful, the <I>pthread_condattr_destroy()</I> function will return
zero (<I>OK</I>). Otherwise, an error number will be
returned to indicate the error:
<p>
<ul>
<li><code>To be provided</code>. </li>
</ul>
<b>Assumptions/Limitations:</b>
<p>
<b>POSIX Compatibility:</b> Comparable to the POSIX
<H3><a name="pthreadcondinit">2.9.39 pthread_cond_init</a></H3>
#include <pthread.h>
int pthread_cond_init(pthread_cond_t *cond, pthread_condattr_t *attr);
<p>
<b>Description:</b>
<p>
<b>Input Parameters:</b>
<p>
<ul>
<li><code>To be provided</code>.</li>
</ul>
<p>
<b>Returned Values:</b>
<p>
If successful, the <I>pthread_cond_init()</I> function will return
zero (<I>OK</I>). Otherwise, an error number will be
returned to indicate the error:
<p>
<ul>
<li><code>To be provided</code>. </li>
</ul>
<b>Assumptions/Limitations:</b>
<p>
<b>POSIX Compatibility:</b> Comparable to the POSIX
<H3><a name="pthreadconddestroy">2.9.40 pthread_cond_destroy</a></H3>
#include <pthread.h>
int pthread_cond_destroy(pthread_cond_t *cond);
<p>
<b>Description:</b>
<p>
<b>Input Parameters:</b>
<p>
<ul>
<li><code>To be provided</code>.</li>
</ul>
<p>
<b>Returned Values:</b>
<p>
If successful, the <I>pthread_cond_destroy()</I> function will return
zero (<I>OK</I>). Otherwise, an error number will be
returned to indicate the error:
<p>
<ul>
<li><code>To be provided</code>. </li>
</ul>
<b>Assumptions/Limitations:</b>
<p>
<b>POSIX Compatibility:</b> Comparable to the POSIX
<H3><a name="pthreadcondbroadcast">2.9.41 pthread_cond_broadcast</a></H3>
#include <pthread.h>
int pthread_cond_broadcast(pthread_cond_t *cond);
<p>
<b>Description:</b>
<p>
<b>Input Parameters:</b>
<p>
<ul>
<li><code>To be provided</code>.</li>
</ul>
<p>
<b>Returned Values:</b>
<p>
If successful, the <I>pthread_cond_broadcast()</I> function will return
zero (<I>OK</I>). Otherwise, an error number will be
returned to indicate the error:
<p>
<ul>
<li><code>To be provided</code>. </li>
</ul>
<b>Assumptions/Limitations:</b>
<p>
<b>POSIX Compatibility:</b> Comparable to the POSIX
<H3><a name="pthreadcondsignal">2.9.42 pthread_cond_signal</a></H3>
#include <pthread.h>
int pthread_cond_signal(pthread_cond_t *dond);
<p>
<b>Description:</b>
<p>
<b>Input Parameters:</b>
<p>
<ul>
<li><code>To be provided</code>.</li>
</ul>
<p>
<b>Returned Values:</b>
<p>
If successful, the <I>pthread_cond_signal()</I> function will return
zero (<I>OK</I>). Otherwise, an error number will be
returned to indicate the error:
<p>
<ul>
<li><code>To be provided</code>. </li>
</ul>
<b>Assumptions/Limitations:</b>
<p>
<b>POSIX Compatibility:</b> Comparable to the POSIX
<H3><a name="pthreadcondwait">2.9.43 pthread_cond_wait</a></H3>
#include <pthread.h>
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
<p>
<b>Description:</b>
<p>
<b>Input Parameters:</b>
<p>
<ul>
<li><code>To be provided</code>.</li>
</ul>
<p>
If successful, the <I>pthread_cond_wait()</I> function will return
zero (<I>OK</I>). Otherwise, an error number will be
returned to indicate the error:
<p>
<ul>
<li><code>To be provided</code>. </li>
</ul>
<b>Assumptions/Limitations:</b>
<p>
<b>POSIX Compatibility:</b> Comparable to the POSIX
<H3><a name="pthreadcondtimedwait">2.9.44 pthread_cond_timedwait</a></H3>
<p>
<b>Function Prototype:</b>
</p>
<pre>
#include <pthread.h>
int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
const struct timespec *abstime);
</pre>
<p>
<b>Description:</b>
</p>
<p>
<b>Input Parameters:</b>
</p>
<p>
<ul>
</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>
</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.45 pthread_barrierattr_init</a></h3>
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
<p>
<b>Function Prototype:</b>
</p>
<pre>
#include <pthread.h>
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.46 pthread_barrierattr_destroy</a></h3>
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
<p>
<b>Function Prototype:</b>
</p>
<pre>
#include <pthread.h>
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.47 pthread_barrierattr_setpshared</a></h3>
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
<p>
<b>Function Prototype:</b>
</p>
<pre>
#include <pthread.h>
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.48 pthread_barrierattr_getpshared</a></h3>
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
<p>
<b>Function Prototype:</b>
</p>
<pre>
#include <pthread.h>
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.49 pthread_barrier_init</a></h3>
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
<p>
<b>Function Prototype:</b>
</p>
<pre>
#include <pthread.h>
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.50 pthread_barrier_destroy</a></h3>
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
<p>
<b>Function Prototype:</b>
</p>
<pre>
#include <pthread.h>
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.51 pthread_barrier_wait</a></h3>
<p>
<b>Function Prototype:</b>
</p>
<pre>
#include <pthread.h>
int pthread_barrier_wait(FAR pthread_barrier_t *barrier);
</pre>
<p>
<b>Description:</b>
The <code>pthread_barrier_wait()</code> function synchronizes participating
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
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.52 pthread_once</a></h3>
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
<p>
<b>Function Prototype:</b>
</p>
<pre>
#include <pthread.h>
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 initialized 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.53 pthread_kill</a></h3>
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
<p>
<b>Function Prototype:</b>
</p>
<pre>
#include <signal.h>
#include <pthread.h>
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.54 pthread_sigmask</a></h3>
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
<p>
<b>Function Prototype:</b>
</p>
<pre>
#include <signal.h>
#include <pthread.h>
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>
</p>
<p>
<b>Assumptions/Limitations:</b>
</p>
<p>
<b>POSIX Compatibility:</b> Comparable to the POSIX interface of the same name.
</p>
<table width ="100%">
<tr bgcolor="#e4e4e4">
<td>
<a name="Environ"><h2>2.10 Environment Variables</h2></a>
</td>
</tr>
</table>
<p><b>Overview</b>.
NuttX supports environment variables that can be used to control the behavior of programs.
In the spirit of NuttX the environment variable behavior attempts to emulate the behavior of
</p>
<ul>
<li><b>Task environments</b>.
When a new task is created using <a href="#taskcreate">task_create</a>, the environment
of the child task is an inherited, exact copy of the environment of the parent.
However, after child task has been created, subsequent operations by the child task on
its environment does not alter the environment of the parent.
No do operations by the parent effect the child's environment.
The environments start identical but are independent and may diverge.
</li>
<li><b>Thread environments</b>.
When a pthread is created using <a href="#pthreadcreate">pthread_create</a>, the child
thread also inherits that environment of the parent.
However, the child does not receive a copy of the environment but, rather, shares the same
Changes to the environment are visible to all threads with the same parentage.
</li>
</ul>
<p><b>Programming Interfaces</b>.
The following environment variable programming interfaces are provided by Nuttx and are
described in detail in the following paragraphs.
</p>
<ul>
<li><a href="#getenv">2.10.1 <code>getenv</code></a></li>
<li><a href="#putenv">2.10.2 <code>putenv</code></a></li>
<li><a href="#clearenv">2.10.3 <code>clearenv</code></a></li>
<li><a href="#setenv">2.10.4 <code>setenv</code></a></li>
<li><a href="#unsetenv">2.10.5 <code>unsetenv</code></a></li>
</ul>
<p><b>Disabling Environment Variable Support</b>.
All support for environment variables can be disabled by setting <code>CONFIG_DISABLE_ENVIRON</code>
in the board configuration file.
</p>
<h3><a name="getenv">2.10.1 <code>getenv</code></a></h3>
<p>
<b>Function Prototype:</b>
</p>
<pre>
FAR char *getenv(const char *name);
</pre>
<p>
<b>Description:</b>
The <code>getenv()</code> function searches the environment list for a string that
matches the string pointed to by <code>name</code>.
</p>
<p>
<b>Input Parameters:</b>
</p>
<p>
<ul>
<li>
<code>name</code>.
The name of the variable to find.
</li>
</ul>
<p>
<b>Returned Values:</b>
<h3><a name="putenv">2.10.2 <code>putenv</code></a></h3>
<p>
<b>Function Prototype:</b>
</p>
<pre>
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
int putenv(char *string);
</pre>
<p>
<b>Description:</b>
The <code>putenv()</code> function adds or changes the value of environment variables.
The argument string is of the form <i>name=value</i>. If name does not already
exist in the environment, then string is added to the environment. If
name does exist, then the value of name in the environment is changed to
value.
</p>
<p>
<b>Input Parameters:</b>
</p>
<p>
<ul>
<li>
<code>string</code>
name=value string describing the environment setting to add/modify.
</li>
</ul>
<p>
<b>Returned Values:</b>
<h3><a name="clearenv">2.10.3 <code>clearenv</code></a></h3>
<p>
<b>Function Prototype:</b>
</p>
<pre>