source: rtems/doc/posix_users/mutex.t @ 6449498

4.104.114.84.95
Last change on this file since 6449498 was 6449498, checked in by Joel Sherrill <joel.sherrill@…>, on 01/17/02 at 21:47:47

2001-01-17 Joel Sherrill <joel@…>

  • SUPPORT, LICENSE: New files.
  • Numerous files touched as part of merging the 4.5 branch onto the mainline development trunk and ensuring that the script that cuts snapshots and releases works on the documentation.
  • Property mode set to 100644
File size: 13.7 KB
RevLine 
[ae68ff0]1@c
[6449498]2@c COPYRIGHT (c) 1988-2002.
[7479042]3@c On-Line Applications Research Corporation (OAR).
4@c All rights reserved.
[ae68ff0]5@c
[7479042]6@c $Id$
[139b2e4a]7@c
[ae68ff0]8
9@chapter Mutex Manager
[c4dddee]10
[ae68ff0]11@section Introduction
12
[56853af]13The mutex manager implements the functionality required of the mutex
[7479042]14manager as defined by POSIX 1003.1b-1996. This standard requires that
[56853af]15a compliant operating system provide the facilties to ensure that
16threads can operate with mutual exclusion from one another and
17defines the API that must be provided.
[ae68ff0]18
[56853af]19The services provided by the mutex manager are:
[ae68ff0]20
21@itemize @bullet
[56853af]22@item @code{pthread_mutexattr_init} - Initialize a Mutex Attribute Set
23@item @code{pthread_mutexattr_destroy} - Destroy a Mutex Attribute Set
24@item @code{pthread_mutexattr_setprotocol} - Set the Blocking Protocol
25@item @code{pthread_mutexattr_getprotocol} - Get the Blocking Protocol
26@item @code{pthread_mutexattr_setprioceiling} - Set the Priority Ceiling
27@item @code{pthread_mutexattr_getprioceiling} - Get the Priority Ceiling
28@item @code{pthread_mutexattr_setpshared} - Set the Visibility
29@item @code{pthread_mutexattr_getpshared} - Get the Visibility
30@item @code{pthread_mutex_init} - Initialize a Mutex
31@item @code{pthread_mutex_destroy} - Destroy a Mutex
32@item @code{pthread_mutex_lock} - Lock a Mutex
33@item @code{pthread_mutex_trylock} - Poll to Lock a Mutex
34@item @code{pthread_mutex_timedlock} - Lock a Mutex with Timeout
35@item @code{pthread_mutex_unlock} - Unlock a Mutex
36@item @code{pthread_mutex_setprioceiling} - Dynamically Set the Priority Ceiling
37@item @code{pthread_mutex_getprioceiling} - Dynamically Get the Priority Ceiling
[ae68ff0]38@end itemize
39
40@section Background
41
[56853af]42@subsection Mutex Attributes
43
[7479042]44Mutex attributes are utilized only at mutex creation time. A mutex
[56853af]45attribute structure may be initialized and passed as an argument to
[7479042]46the @code{mutex_init} routine. Note that the priority ceiling of
[56853af]47a mutex may be set at run-time.
48
49@table @b
50@item blocking protcol
51is the XXX
52
53@item priority ceiling
54is the XXX
55
56@item pshared
57is the XXX
58
59@end table
60
61@subsection PTHREAD_MUTEX_INITIALIZER
62
63This is a special value that a variable of type @code{pthread_mutex_t}
64may be statically initialized to as shown below:
65
66@example
67pthread_mutex_t my_mutex = PTHREAD_MUTEX_INITIALIZER;
68@end example
69
70This indicates that @code{my_mutex} will be automatically initialized
71by an implicit call to @code{pthread_mutex_init} the first time
[7479042]72the mutex is used.
[56853af]73
74Note that the mutex will be initialized with default attributes.
[c4dddee]75
[ae68ff0]76@section Operations
77
[c4dddee]78There is currently no text in this section.
79
[56853af]80@section Services
[ae68ff0]81
[56853af]82This section details the mutex manager's services.
83A subsection is dedicated to each of this manager's services
[ae68ff0]84and describes the calling sequence, related constants, usage,
85and status codes.
86
[7479042]87@c
88@c
89@c
[ae68ff0]90@page
[56853af]91@subsection pthread_mutexattr_init - Initialize a Mutex Attribute Set
[ae68ff0]92
[7479042]93@findex pthread_mutexattr_init
94@cindex  initialize a mutex attribute set
95
[ae68ff0]96@subheading CALLING SEQUENCE:
97
98@example
99#include <pthread.h>
100
101int pthread_mutexattr_init(
[d2bfbaf]102  pthread_mutexattr_t *attr
[ae68ff0]103);
104@end example
105
106@subheading STATUS CODES:
107
108@table @b
109@item EINVAL
110The attribute pointer argument is invalid.
111
112@end table
113
114@subheading DESCRIPTION:
115
[56853af]116The @code{pthread_mutexattr_init} routine initializes the mutex attributes
117object specified by @code{attr} with the default value for all of the
118individual attributes.
119
[ae68ff0]120@subheading NOTES:
121
[56853af]122XXX insert list of default attributes here.
123
[7479042]124@c
125@c
126@c
[ae68ff0]127@page
[56853af]128@subsection pthread_mutexattr_destroy - Destroy a Mutex Attribute Set
[ae68ff0]129
[7479042]130@findex pthread_mutexattr_destroy
131@cindex  destroy a mutex attribute set
132
[ae68ff0]133@subheading CALLING SEQUENCE:
134
135@example
136#include <pthread.h>
137
138int pthread_mutexattr_destroy(
[d2bfbaf]139  pthread_mutexattr_t *attr
[ae68ff0]140);
141@end example
142
143@subheading STATUS CODES:
144
145@table @b
146@item EINVAL
147The attribute pointer argument is invalid.
148
149@item EINVAL
150The attribute set is not initialized.
151
152@end table
153
154@subheading DESCRIPTION:
155
[56853af]156The @code{pthread_mutex_attr_destroy} routine is used to destroy a mutex
[7479042]157attributes object. The behavior of using an attributes object after
[56853af]158it is destroyed is implementation dependent.
159
[ae68ff0]160@subheading NOTES:
161
[56853af]162NONE
163
[7479042]164@c
165@c
166@c
[ae68ff0]167@page
[56853af]168@subsection pthread_mutexattr_setprotocol - Set the Blocking Protocol
[ae68ff0]169
[7479042]170@findex pthread_mutexattr_setprotocol
171@cindex  set the blocking protocol
172
[ae68ff0]173@subheading CALLING SEQUENCE:
174
175@example
176#include <pthread.h>
177
178int pthread_mutexattr_setprotocol(
[d2bfbaf]179  pthread_mutexattr_t *attr,
180  int                  protocol
[ae68ff0]181);
182@end example
183
184@subheading STATUS CODES:
185
186@table @b
187@item EINVAL
188The attribute pointer argument is invalid.
189
190@item EINVAL
191The attribute set is not initialized.
[7479042]192
[ae68ff0]193@item EINVAL
194The protocol argument is invalid.
[7479042]195
[ae68ff0]196@end table
197
198@subheading DESCRIPTION:
199
[56853af]200The @code{pthread_mutexattr_setprotocol} routine is used to set value of the
[7479042]201@code{protocol} attribute. This attribute controls the order in which
[56853af]202threads waiting on this mutex will receive it.
203
204The @code{protocol} can be one of the following:
205
206@table @b
207
208@item @code{PTHREAD_PRIO_NONE}
209in which case blocking order is FIFO.
210
211@item @code{PTHREAD_PRIO_INHERIT}
[7479042]212in which case blocking order is priority with the priority inheritance
[56853af]213protocol in effect.
214
215@item @code{PTHREAD_PRIO_PROTECT}
[7479042]216in which case blocking order is priority with the priority ceiling
[56853af]217protocol in effect.
218
219@end table
220
[ae68ff0]221@subheading NOTES:
222
[56853af]223There is currently no way to get simple priority blocking ordering
224with POSIX mutexes even though this could easily by supported by RTEMS.
225
[7479042]226@c
227@c
228@c
[ae68ff0]229@page
[56853af]230@subsection pthread_mutexattr_getprotocol - Get the Blocking Protocol
[7479042]231
232@findex pthread_mutexattr_getprotocol
233@cindex  get the blocking protocol
234
[ae68ff0]235@subheading CALLING SEQUENCE:
[7479042]236
[ae68ff0]237@example
238#include <pthread.h>
[7479042]239
[ae68ff0]240int pthread_mutexattr_getprotocol(
[d2bfbaf]241  pthread_mutexattr_t *attr,
242  int                 *protocol
[ae68ff0]243);
244@end example
[7479042]245
[ae68ff0]246@subheading STATUS CODES:
[7479042]247
[ae68ff0]248@table @b
249@item EINVAL
250The attribute pointer argument is invalid.
251
252@item EINVAL
253The attribute set is not initialized.
[7479042]254
[ae68ff0]255@item EINVAL
256The protocol pointer argument is invalid.
[7479042]257
[ae68ff0]258@end table
[7479042]259
[ae68ff0]260@subheading DESCRIPTION:
[7479042]261
[56853af]262The @code{pthread_mutexattr_getprotocol} routine is used to obtain
[7479042]263the value of the @code{protocol} attribute. This attribute controls
[56853af]264the order in which threads waiting on this mutex will receive it.
265
[ae68ff0]266@subheading NOTES:
267
[56853af]268NONE
269
[7479042]270@c
271@c
272@c
[ae68ff0]273@page
[56853af]274@subsection pthread_mutexattr_setprioceiling - Set the Priority Ceiling
[ae68ff0]275
[7479042]276@findex pthread_mutexattr_setprioceiling
277@cindex  set the priority ceiling
278
[ae68ff0]279@subheading CALLING SEQUENCE:
280
281@example
282#include <pthread.h>
283
284int pthread_mutexattr_setprioceiling(
[d2bfbaf]285  pthread_mutexattr_t *attr,
286  int                  prioceiling
[ae68ff0]287);
288@end example
289
290@subheading STATUS CODES:
[7479042]291
[ae68ff0]292@table @b
293@item EINVAL
294The attribute pointer argument is invalid.
295
296@item EINVAL
297The attribute set is not initialized.
[7479042]298
[ae68ff0]299@item EINVAL
300The prioceiling argument is invalid.
[7479042]301
[ae68ff0]302@end table
303
304@subheading DESCRIPTION:
305
[56853af]306The @code{pthread_mutexattr_setprioceiling} routine is used to set value of the
[7479042]307@code{prioceiling} attribute. This attribute specifies the priority that
308is the ceiling for threads obtaining this mutex. Any task obtaining this
309mutex may not be of greater priority that the ceiling. If it is of lower
310priority, then its priority will be elevated to @code{prioceiling}.
[56853af]311
[ae68ff0]312@subheading NOTES:
313
[56853af]314NONE
315
[7479042]316@c
317@c
318@c
[ae68ff0]319@page
[56853af]320@subsection pthread_mutexattr_getprioceiling - Get the Priority Ceiling
[ae68ff0]321
[7479042]322@findex pthread_mutexattr_getprioceiling
323@cindex  get the priority ceiling
324
[ae68ff0]325@subheading CALLING SEQUENCE:
326
327@example
328#include <pthread.h>
329
330int pthread_mutexattr_getprioceiling(
[d2bfbaf]331  const pthread_mutexattr_t *attr,
332  int                       *prioceiling
[ae68ff0]333);
334@end example
335
336@subheading STATUS CODES:
[7479042]337
[ae68ff0]338@table @b
339@item EINVAL
340The attribute pointer argument is invalid.
341
342@item EINVAL
343The attribute set is not initialized.
[7479042]344
[ae68ff0]345@item EINVAL
346The prioceiling pointer argument is invalid.
[7479042]347
[ae68ff0]348@end table
349
350@subheading DESCRIPTION:
351
[56853af]352The @code{pthread_mutexattr_getprioceiling} routine is used to obtain the
[7479042]353value of the @code{prioceiling} attribute. This attribute specifies the
[56853af]354priority ceiling for this mutex.
355
356
[ae68ff0]357@subheading NOTES:
358
[56853af]359
360NONE
[7479042]361@c
362@c
363@c
[ae68ff0]364@page
[56853af]365@subsection pthread_mutexattr_setpshared - Set the Visibility
[ae68ff0]366
[7479042]367@findex pthread_mutexattr_setpshared
368@cindex  set the visibility
369
[ae68ff0]370@subheading CALLING SEQUENCE:
371
372@example
373#include <pthread.h>
374
375int pthread_mutexattr_setpshared(
[d2bfbaf]376  pthread_mutexattr_t *attr,
377  int                  pshared
[ae68ff0]378);
379@end example
380
381@subheading STATUS CODES:
[7479042]382
[ae68ff0]383@table @b
384@item EINVAL
385The attribute pointer argument is invalid.
386
387@item EINVAL
388The attribute set is not initialized.
[7479042]389
[ae68ff0]390@item EINVAL
391The pshared argument is invalid.
[7479042]392
[ae68ff0]393@end table
394
395@subheading DESCRIPTION:
396
397@subheading NOTES:
398
[7479042]399@c
400@c
401@c
[ae68ff0]402@page
[56853af]403@subsection pthread_mutexattr_getpshared - Get the Visibility
[ae68ff0]404
[7479042]405@findex pthread_mutexattr_getpshared
406@cindex  get the visibility
407
[ae68ff0]408@subheading CALLING SEQUENCE:
409
410@example
411#include <pthread.h>
412
413int pthread_mutexattr_getpshared(
[d2bfbaf]414  const pthread_mutexattr_t *attr,
415  int                       *pshared
[ae68ff0]416);
417@end example
418
419@subheading STATUS CODES:
[7479042]420
[ae68ff0]421@table @b
422@item EINVAL
423The attribute pointer argument is invalid.
424
425@item EINVAL
426The attribute set is not initialized.
[7479042]427
[ae68ff0]428@item EINVAL
429The pshared pointer argument is invalid.
[7479042]430
[ae68ff0]431@end table
432
433@subheading DESCRIPTION:
434
435@subheading NOTES:
436
[7479042]437@c
438@c
439@c
[ae68ff0]440@page
[56853af]441@subsection pthread_mutex_init - Initialize a Mutex
[ae68ff0]442
[7479042]443@findex pthread_mutex_init
444@cindex  initialize a mutex
445
[ae68ff0]446@subheading CALLING SEQUENCE:
447
448@example
449#include <pthread.h>
450
451int pthread_mutex_init(
[d2bfbaf]452  pthread_mutex_t           *mutex,
453  const pthread_mutexattr_t *attr
[ae68ff0]454);
455@end example
456
457@subheading STATUS CODES:
458
459@table @b
460@item EINVAL
461The attribute set is not initialized.
[7479042]462
[ae68ff0]463@item EINVAL
464The specified protocol is invalid.
465
466@item EAGAIN
467The system lacked the necessary resources to initialize another mutex.
468
469@item ENOMEM
470Insufficient memory exists to initialize the mutex.
471
472@item EBUSY
473Attempted to reinialize the object reference by mutex, a previously
474initialized, but not yet destroyed.
475
476@end table
477
478@subheading DESCRIPTION:
479
480@subheading NOTES:
481
[7479042]482@c
483@c
484@c
[ae68ff0]485@page
[56853af]486@subsection pthread_mutex_destroy - Destroy a Mutex
[ae68ff0]487
[7479042]488@findex pthread_mutex_destroy
489@cindex  destroy a mutex
490
[ae68ff0]491@subheading CALLING SEQUENCE:
492
493@example
494#include <pthread.h>
495
496int pthread_mutex_destroy(
[d2bfbaf]497  pthread_mutex_t *mutex
[ae68ff0]498);
499@end example
500
501@subheading STATUS CODES:
[7479042]502
[ae68ff0]503@table @b
504@item EINVAL
505The specified mutex is invalid.
506
507@item EBUSY
508Attempted to destroy the object reference by mutex, while it is locked or
509referenced by another thread.
[7479042]510
[ae68ff0]511@end table
512
513@subheading DESCRIPTION:
514
515@subheading NOTES:
516
[7479042]517@c
518@c
519@c
[ae68ff0]520@page
[56853af]521@subsection pthread_mutex_lock - Lock a Mutex
[ae68ff0]522
[7479042]523@findex pthread_mutex_lock
524@cindex  lock a mutex
525
[ae68ff0]526@subheading CALLING SEQUENCE:
527
528@example
529#include <pthread.h>
530
531int pthread_mutex_lock(
[d2bfbaf]532  pthread_mutex_t *mutex
[ae68ff0]533);
534@end example
535
536@subheading STATUS CODES:
537
538@table @b
539@item EINVAL
540The specified mutex is invalid.
541
542@item EINVAL
[7479042]543The mutex has the protocol attribute of PTHREAD_PRIO_PROTECT and the
[ae68ff0]544priority of the calling thread is higher than the current priority
545ceiling.
546
547@item EDEADLK
548The current thread already owns the mutex.
549
550@end table
551
552@subheading DESCRIPTION:
553
554@subheading NOTES:
555
[7479042]556@c
557@c
558@c
[ae68ff0]559@page
[56853af]560@subsection pthread_mutex_trylock - Poll to Lock a Mutex
[7479042]561
562@findex pthread_mutex_trylock
563@cindex  poll to lock a mutex
564
[ae68ff0]565@subheading CALLING SEQUENCE:
[7479042]566
[ae68ff0]567@example
568#include <pthread.h>
[7479042]569
[ae68ff0]570int pthread_mutex_trylock(
[d2bfbaf]571  pthread_mutex_t *mutex
[ae68ff0]572);
573@end example
[7479042]574
[ae68ff0]575@subheading STATUS CODES:
[7479042]576
[ae68ff0]577@table @b
578@item EINVAL
579The specified mutex is invalid.
[7479042]580
[ae68ff0]581@item EINVAL
582The mutex has the protocol attribute of PTHREAD_PRIO_PROTECT and the
583priority of the calling thread is higher than the current priority
584ceiling.
[7479042]585
[ae68ff0]586@item EDEADLK
587The current thread already owns the mutex.
[7479042]588
[ae68ff0]589@end table
[7479042]590
[ae68ff0]591@subheading DESCRIPTION:
[7479042]592
[ae68ff0]593@subheading NOTES:
[7479042]594
595@c
596@c
597@c
[ae68ff0]598@page
[56853af]599@subsection pthread_mutex_timedlock - Lock a Mutex with Timeout
[7479042]600
601@findex pthread_mutex_timedlock
602@cindex  lock a mutex with timeout
603
[ae68ff0]604@subheading CALLING SEQUENCE:
[7479042]605
[ae68ff0]606@example
607#include <pthread.h>
608#include <time.h>
[7479042]609
[ae68ff0]610int pthread_mutex_timedlock(
[d2bfbaf]611  pthread_mutex_t       *mutex,
612  const struct timespec *timeout
[ae68ff0]613);
614@end example
[7479042]615
[ae68ff0]616@subheading STATUS CODES:
[7479042]617
[ae68ff0]618@table @b
619@item EINVAL
620The specified mutex is invalid.
[7479042]621
[ae68ff0]622@item EINVAL
623The nanoseconds field of timeout is invalid.
624
625@item EINVAL
626The mutex has the protocol attribute of PTHREAD_PRIO_PROTECT and the
627priority of the calling thread is higher than the current priority
628ceiling.
[7479042]629
[ae68ff0]630@item EDEADLK
631The current thread already owns the mutex.
632
633@end table
[7479042]634
[ae68ff0]635@subheading DESCRIPTION:
[7479042]636
[ae68ff0]637@subheading NOTES:
638
[7479042]639
640@c
641@c
642@c
[ae68ff0]643@page
[56853af]644@subsection pthread_mutex_unlock - Unlock a Mutex
[ae68ff0]645
[7479042]646@findex pthread_mutex_unlock
647@cindex  unlock a mutex
648
[ae68ff0]649@subheading CALLING SEQUENCE:
650
651@example
652#include <pthread.h>
653
654int pthread_mutex_unlock(
[d2bfbaf]655  pthread_mutex_t *mutex
[ae68ff0]656);
657@end example
658
659@subheading STATUS CODES:
660
661@table @b
662@item EINVAL
663The specified mutex is invalid.
[7479042]664
[ae68ff0]665@end table
666
667@subheading DESCRIPTION:
668
669@subheading NOTES:
670
[7479042]671@c
672@c
673@c
[ae68ff0]674@page
[56853af]675@subsection pthread_mutex_setprioceiling - Dynamically Set the Priority Ceiling
[ae68ff0]676
[7479042]677@findex pthread_mutex_setprioceiling
678@cindex  dynamically set the priority ceiling
679
[ae68ff0]680@subheading CALLING SEQUENCE:
681
682@example
683#include <pthread.h>
684
685int pthread_mutex_setprioceiling(
[d2bfbaf]686  pthread_mutex_t *mutex,
687  int              prioceiling,
688  int             *oldceiling
[ae68ff0]689);
690@end example
691
692@subheading STATUS CODES:
[7479042]693
[ae68ff0]694@table @b
695@item EINVAL
696The oldceiling pointer parameter is invalid.
697
698@item EINVAL
699The prioceiling parameter is an invalid priority.
700
701@item EINVAL
702The specified mutex is invalid.
[7479042]703
[ae68ff0]704@end table
705
706@subheading DESCRIPTION:
707
708@subheading NOTES:
709
[7479042]710@c
711@c
712@c
[ae68ff0]713@page
[56853af]714@subsection pthread_mutex_getprioceiling - Get the Current Priority Ceiling
[ae68ff0]715
[7479042]716@findex pthread_mutex_getprioceiling
717@cindex  get the current priority ceiling
718
[ae68ff0]719@subheading CALLING SEQUENCE:
720
721@example
722#include <pthread.h>
723
724int pthread_mutex_getprioceiling(
[d2bfbaf]725  pthread_mutex_t *mutex,
726  int             *prioceiling
[ae68ff0]727);
728@end example
729
730@subheading STATUS CODES:
[7479042]731
[ae68ff0]732@table @b
733@item EINVAL
734The prioceiling pointer parameter is invalid.
735
736@item EINVAL
737The specified mutex is invalid.
[7479042]738
[ae68ff0]739@end table
740
741@subheading DESCRIPTION:
742
743@subheading NOTES:
744
Note: See TracBrowser for help on using the repository browser.