diff options
79 files changed, 8933 insertions, 276 deletions
@@ -1,5 +1,5 @@ - PTHREADS-WIN32 RELEASE 1.8.0 (2005-04-26) - ------------------------------------------- + PTHREADS-WIN32 RELEASE 1.9.0 (2005-05-06) + ----------------------------------------- Web Site: http://sources.redhat.com/pthreads-win32/ FTP Site: ftp://sources.redhat.com/pub/pthreads-win32 Maintainer: Ross Johnson <rpj@callisto.canberra.edu.au> @@ -40,6 +40,13 @@ Aurelio Medina and improved by Alexander Terekhov. Many others have contributed significant time and effort to solve crutial problems in order to make the library workable, robust and reliable. +Thanks to Xavier Leroy for granting permission to use and modify his +LinuxThreads manual pages. + +Thanks to The Open Group for making the Single Unix Specification +publicly available - many of the manual pages included in the package +were extracted from it. + There is also a separate CONTRIBUTORS file. This file and others are on the web site: @@ -1,3 +1,39 @@ +2005-05-06 Ross Johnson <ross at callisto.canberra.edu.au> + + * signal.c (sigwait): Add a cancellation point to this otherwise + no-op. + * sem_init.c (sem_init): Check for and return ERANGE error. + * sem_post.c (sem_post): Likewise. + * sem_post_multiple.c (sem_post_multiple): Likewise. + * manual (directory): Added; see ChangeLog inside. + +2005-05-02 Ross Johnson <ross at callisto.canberra.edu.au> + + * implement.h (struct pthread_key_t_): Change threadsLock to keyLock + so as not to be confused with the per thread lock 'threadlock'; + change all references to it. + * implement.h (struct ThreadKeyAssoc): Remove lock; add prevKey + and prevThread pointers; re-implemented all routines that use this + struct. The effect of this is to save one handle per association, + which could potentially equal the number of keys multiplied by the + number of threads, accumulating over time - and to free the + association memory as soon as it is no longer referenced by either + the key or the thread. Previously, the handle and memory were + released only after BOTH key and thread no longer referenced the + association. That is, often no association resources were released + until the process itself exited. In addition, at least one race + condition has been removed - where two threads could attempt to + release the association resources simultaneously - one via + ptw32_callUserDestroyRoutines and the other via + pthread_key_delete. + - thanks to Richard Hughes at Aculab for discovering the problem. + * pthread_key_create.c: See above. + * pthread_key_delete.c: See above. + * pthread_setspecific.c: See above. + * ptw32_callUserDestroyRoutines.c: See above. + * ptw32_tkAssocCreate.c: See above. + * ptw32_tkAssocDestroy.c: See above. + 2005-04-27 Ross Johnson <ross at callisto.canberra.edu.au> * sem_wait.c (ptw32_sem_wait_cleanup): after cancellation re-attempt @@ -1,3 +1,46 @@ +RELEASE 1.9.0 +------------- +(2005-05-06) + +General +------- + +All of the bug fixes and new features in this release have been +back-ported from release 2.5.0. + +The package now includes a reference documentation set consisting of +HTML formatted Unix-style manual pages that have been edited for +consistency with Pthreads-w32. The set can also be read online at: +http://sources.redhat.com/pthreads-win32/manual/index.html + +Bugs fixed +---------- + +* Thread Specific Data (TSD) key management has been altered to +eliminate a source of resource leakage (HANDLEs plus memory). +Thanks to Richard Hughes at Aculab for identifying the leak. + +* Fix a semaphore accounting race between sem_post/sem_post_multiple +and sem_wait cancellation. This is the same issue as with +sem_timedwait that was fixed in the last release. + +* sem_init, sem_post, and sem_post_multiple now check that the +semaphore count never exceeds _POSIX_SEM_VALUE_MAX. + +* Although sigwait() is nothing more than a no-op, it should at least +be a cancellation point to be consistent with the standard. + +New tests +--------- + +* stress1.c - attempts to expose problems in condition variable +and semaphore timed wait logic. This test was inspired by Stephan +Mueller's sample test code used to identify the sem_timedwait bug +from the last release. It's not a part of the regular test suite +because it can take awhile to run. To run it: +nmake clean VC-stress + + RELEASE 1.8.0 ------------- (2005-04-26) @@ -92,6 +92,7 @@ pthread_create (pthread_t * tid, ThreadParms *parms = NULL; long stackSize; int priority; + pthread_t self; /* * Before doing anything, check that tid can be stored through @@ -128,18 +129,23 @@ pthread_create (pthread_t * tid, parms->start = start; parms->arg = arg; +#if defined(HAVE_SIGSET_T) + + /* + * Threads inherit their initial sigmask from their creator thread. + */ + self = pthread_self(); + tp->sigmask = ((ptw32_thread_t *)self.p)->sigmask; + +#endif /* HAVE_SIGSET_T */ + + if (a != NULL) { stackSize = a->stacksize; tp->detachState = a->detachstate; priority = a->param.sched_priority; -#if HAVE_SIGSET_T - - tp->sigmask = a->sigmask; - -#endif /* HAVE_SIGSET_T */ - #if (THREAD_PRIORITY_LOWEST > THREAD_PRIORITY_NORMAL) /* WinCE */ #else @@ -164,7 +170,9 @@ pthread_create (pthread_t * tid, * then the inherited priority could be the result of a temporary * system adjustment. This is not the case for POSIX threads. */ - pthread_t self = pthread_self (); +#if ! defined(HAVE_SIGSET_T) + self = pthread_self (); +#endif priority = ((ptw32_thread_t *) self.p)->sched_priority; } diff --git a/implement.h b/implement.h index d575539..994a768 100644 --- a/implement.h +++ b/implement.h @@ -266,7 +266,7 @@ struct pthread_key_t_ { DWORD key; void (*destructor) (void *); - pthread_mutex_t threadsLock; + pthread_mutex_t keyLock; void *threads; }; @@ -347,26 +347,67 @@ struct ThreadKeyAssoc { /* * Purpose: - * This structure creates an association between a - * thread and a key. - * It is used to implement the implicit invocation - * of a user defined destroy routine for thread - * specific data registered by a user upon exiting a - * thread. + * This structure creates an association between a thread and a key. + * It is used to implement the implicit invocation of a user defined + * destroy routine for thread specific data registered by a user upon + * exiting a thread. * - * Attributes: - * lock - * protects access to the rest of the structure + * Graphically, the arrangement is as follows, where: + * + * K - Key with destructor + * (head of chain is key->threads) + * T - Thread that has called pthread_setspecific(Kn) + * (head of chain is thread->keys) + * A - Association. Each association is a node at the + * intersection of two doubly-linked lists. + * + * T1 T2 T3 + * | | | + * | | | + * K1 -----+-----A-----A-----> + * | | | + * | | | + * K2 -----A-----A-----+-----> + * | | | + * | | | + * K3 -----A-----+-----A-----> + * | | | + * | | | + * V V V + * + * Access to the association is guarded by two locks: the key's + * general lock (guarding the row) and the thread's general + * lock (guarding the column). This avoids the need for a + * dedicated lock for each association, which not only consumes + * more handles but requires that: before the lock handle can + * be released - both the key must be deleted and the thread + * must have called the destructor. The two-lock arrangement + * allows the resources to be freed as soon as either thread or + * key is concluded. + * + * To avoid deadlock: whenever both locks are required, the key + * and thread locks are always applied in the order: key lock + * then thread lock. * + * An association is created when a thread first calls + * pthread_setspecific() on a key that has a specified + * destructor. + * + * An association is destroyed either immediately after the + * thread calls the key destructor function on thread exit, or + * when the key is deleted. + * + * Attributes: * thread - * reference to the thread that owns the association. - * As long as this is not NULL, the association remains - * referenced by the pthread_t. + * reference to the thread that owns the + * association. This is actually the pointer to the + * thread struct itself. Since the association is + * destroyed before the thread exits, this can never + * point to a different logical thread to the one that + * created the assoc, i.e. after thread struct reuse. * * key * reference to the key that owns the association. - * As long as this is not NULL, the association remains - * referenced by the pthread_key_t. * * nextKey * The pthread_t->keys attribute is the head of a @@ -375,6 +416,9 @@ struct ThreadKeyAssoc * between a pthread_t and all pthread_key_t on which * it called pthread_setspecific. * + * prevKey + * Similarly. + * * nextThread * The pthread_key_t->threads attribute is the head of * a chain of assoctiations that runs through the @@ -383,11 +427,13 @@ struct ThreadKeyAssoc * PThreads that have called pthread_setspecific for * this pthread_key_t. * + * prevThread + * Similarly. * * Notes: - * 1) As long as one of the attributes, thread or key, is - * not NULL, the association is being referenced; once - * both are NULL, the association must be released. + * 1) As soon as either the key or the thread is no longer + * referencing the association, it can be destroyed. The + * association will be removed from both chains. * * 2) Under WIN32, an association is only created by * pthread_setspecific if the user provided a @@ -395,11 +441,12 @@ struct ThreadKeyAssoc * * */ - pthread_mutex_t lock; - pthread_t thread; + ptw32_thread_t * thread; pthread_key_t key; ThreadKeyAssoc *nextKey; ThreadKeyAssoc *nextThread; + ThreadKeyAssoc *prevKey; + ThreadKeyAssoc *prevThread; }; @@ -564,7 +611,7 @@ extern "C" void ptw32_callUserDestroyRoutines (pthread_t thread); int ptw32_tkAssocCreate (ThreadKeyAssoc ** assocP, - pthread_t thread, pthread_key_t key); + ptw32_thread_t * thread, pthread_key_t key); void ptw32_tkAssocDestroy (ThreadKeyAssoc * assoc); diff --git a/manual/ChangeLog b/manual/ChangeLog new file mode 100644 index 0000000..c07cdd7 --- /dev/null +++ b/manual/ChangeLog @@ -0,0 +1,62 @@ +2005-05-06 Ross Johnson <ross at callisto.canberra.edu.au> + + * PortabilityIssues.html: Was nonPortableIssues.html. + * index.html: Updated; add table of contents at top. + * *.html: Add Pthreads-win32 header info; add link back to the + index page 'index.html'. + +2005-05-06 Ross Johnson <ross at callisto.canberra.edu.au> + + * index.html: New. + * nonPortableIssues.html: New. + * pthread_attr_init.html: New. + * pthread_attr_setstackaddr.html: New. + * pthread_attr_setstacksize.html: New. + * pthread_barrierattr_init.html: New. + * pthread_barrierattr_setpshared.html: New. + * pthread_barrier_init.html: New. + * pthread_barrier_wait.html: New. + * pthreadCancelableWait.html: New. + * pthread_cancel.html: New. + * pthread_cleanup_push.html: New. + * pthread_condattr_init.html: New. + * pthread_condattr_setpshared.html: New. + * pthread_cond_init.html: New. + * pthread_create.html: New. + * pthread_delay_np.html: New. + * pthread_detach.html: New. + * pthread_equal.html: New. + * pthread_exit.html: New. + * pthread_getw32threadhandle_np.html: New. + * pthread_join.html: New. + * pthread_key_create.html: New. + * pthread_kill.html: New. + * pthread_mutexattr_init.html: New. + * pthread_mutexattr_setpshared.html: New. + * pthread_mutex_init.html: New. + * pthread_num_processors_np.html: New. + * pthread_once.html: New. + * pthread_rwlockattr_init.html: New. + * pthread_rwlockattr_setpshared.html: New. + * pthread_rwlock_init.html: New. + * pthread_rwlock_rdlock.html: New. + * pthread_rwlock_timedrdlock.html: New. + * pthread_rwlock_timedwrlock.html: New. + * pthread_rwlock_unlock.html: New. + * pthread_rwlock_wrlock.html: New. + * pthread_self.html: New. + * pthread_setcancelstate.html: New. + * pthread_setcanceltype.html: New. + * pthread_setconcurrency.html: New. + * pthread_setschedparam.html: New. + * pthread_spin_init.html: New. + * pthread_spin_lock.html: New. + * pthread_spin_unlock.html: New. + * pthread_timechange_handler_np.html: New. + * pthread_win32_attach_detach_np.html: New. + * pthread_win32_test_features_np.html: New. + * sched_get_priority_max.html: New. + * sched_getscheduler.html: New. + * sched_setscheduler.html: New. + * sched_yield.html: New. + * sem_init.html: New. diff --git a/manual/PortabilityIssues.html b/manual/PortabilityIssues.html new file mode 100644 index 0000000..376a5f0 --- /dev/null +++ b/manual/PortabilityIssues.html @@ -0,0 +1,718 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PORTABILITYISSUES manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;322600"> + <META NAME="CHANGED" CONTENT="20050506;11580000"> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<H4><A HREF="#toc">Table of Contents</A></H4> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P STYLE="font-weight: medium">Portability issues</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>Thread priority</B></P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<H3>Thread priority</H3> +<P STYLE="margin-left: 2cm">POSIX defines a single contiguous range +of numbers that determine a thread's priority. Win32 defines priority +classes - and priority levels relative to these classes. Classes are +simply priority base levels that the defined priority levels are +relative to such that, changing a process's priority class will +change the priority of all of it's threads, while the threads retain +the same relativity to each other.</P> +<P STYLE="margin-left: 2cm">A Win32 system defines a single +contiguous monotonic range of values that define system priority +levels, just like POSIX. However, Win32 restricts individual threads +to a subset of this range on a per-process basis.</P> +<P STYLE="margin-left: 2cm">The following table shows the base +priority levels for combinations of priority class and priority value +in Win32.</P> +<DL> + <DL> + <DD> + <TABLE WIDTH=742 BORDER=0 CELLPADDING=0 CELLSPACING=0 STYLE="page-break-inside: avoid"> + <COL WIDTH=50> + <COL WIDTH=356> + <COL WIDTH=336> + <THEAD> + <TR VALIGN=TOP> + <TD WIDTH=50> + <P ALIGN=CENTER><BR> + </P> + </TD> + <TD WIDTH=356> + <P ALIGN=LEFT><B>Process Priority Class</B></P> + </TD> + <TD WIDTH=336> + <P ALIGN=LEFT><B>Thread Priority Level</B></P> + </TD> + </TR> + </THEAD> + <TBODY> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="1" SDNUM="3081;"> + <P ALIGN=CENTER>1</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>IDLE_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_IDLE</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="1" SDNUM="3081;"> + <P ALIGN=CENTER>1</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>BELOW_NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_IDLE</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="1" SDNUM="3081;"> + <P ALIGN=CENTER>1</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_IDLE</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="1" SDNUM="3081;"> + <P ALIGN=CENTER>1</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>ABOVE_NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_IDLE</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="1" SDNUM="3081;"> + <P ALIGN=CENTER>1</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>HIGH_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_IDLE</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="2" SDNUM="3081;"> + <P ALIGN=CENTER>2</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>IDLE_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_LOWEST</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="3" SDNUM="3081;"> + <P ALIGN=CENTER>3</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>IDLE_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_BELOW_NORMAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="4" SDNUM="3081;"> + <P ALIGN=CENTER>4</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>IDLE_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_NORMAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="4" SDNUM="3081;"> + <P ALIGN=CENTER>4</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>BELOW_NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_LOWEST</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="5" SDNUM="3081;"> + <P ALIGN=CENTER>5</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>IDLE_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_ABOVE_NORMAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="5" SDNUM="3081;"> + <P ALIGN=CENTER>5</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>BELOW_NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_BELOW_NORMAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="5" SDNUM="3081;"> + <P ALIGN=CENTER>5</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>Background NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_LOWEST</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="6" SDNUM="3081;"> + <P ALIGN=CENTER>6</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>IDLE_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_HIGHEST</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="6" SDNUM="3081;"> + <P ALIGN=CENTER>6</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>BELOW_NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_NORMAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="6" SDNUM="3081;"> + <P ALIGN=CENTER>6</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>Background NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_BELOW_NORMAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="7" SDNUM="3081;"> + <P ALIGN=CENTER>7</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>BELOW_NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_ABOVE_NORMAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="7" SDNUM="3081;"> + <P ALIGN=CENTER>7</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>Background NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_NORMAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="7" SDNUM="3081;"> + <P ALIGN=CENTER>7</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>Foreground NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_LOWEST</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="8" SDNUM="3081;"> + <P ALIGN=CENTER>8</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>BELOW_NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_HIGHEST</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="8" SDNUM="3081;"> + <P ALIGN=CENTER>8</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_ABOVE_NORMAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="8" SDNUM="3081;"> + <P ALIGN=CENTER>8</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>Foreground NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_BELOW_NORMAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="8" SDNUM="3081;"> + <P ALIGN=CENTER>8</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>ABOVE_NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_LOWEST</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="9" SDNUM="3081;"> + <P ALIGN=CENTER>9</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_HIGHEST</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="9" SDNUM="3081;"> + <P ALIGN=CENTER>9</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>Foreground NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_NORMAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="9" SDNUM="3081;"> + <P ALIGN=CENTER>9</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>ABOVE_NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_BELOW_NORMAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="10" SDNUM="3081;"> + <P ALIGN=CENTER>10</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>Foreground NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_ABOVE_NORMAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="10" SDNUM="3081;"> + <P ALIGN=CENTER>10</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>ABOVE_NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_NORMAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="11" SDNUM="3081;"> + <P ALIGN=CENTER>11</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>Foreground NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_HIGHEST</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="11" SDNUM="3081;"> + <P ALIGN=CENTER>11</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>ABOVE_NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_ABOVE_NORMAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="11" SDNUM="3081;"> + <P ALIGN=CENTER>11</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>HIGH_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_LOWEST</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="12" SDNUM="3081;"> + <P ALIGN=CENTER>12</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>ABOVE_NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_HIGHEST</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="12" SDNUM="3081;"> + <P ALIGN=CENTER>12</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>HIGH_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_BELOW_NORMAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="13" SDNUM="3081;"> + <P ALIGN=CENTER>13</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>HIGH_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_NORMAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="14" SDNUM="3081;"> + <P ALIGN=CENTER>14</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>HIGH_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_ABOVE_NORMAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="15" SDNUM="3081;"> + <P ALIGN=CENTER>15</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>HIGH_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_HIGHEST</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="15" SDNUM="3081;"> + <P ALIGN=CENTER>15</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>HIGH_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_TIME_CRITICAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="15" SDNUM="3081;"> + <P ALIGN=CENTER>15</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>IDLE_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_TIME_CRITICAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="15" SDNUM="3081;"> + <P ALIGN=CENTER>15</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>BELOW_NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_TIME_CRITICAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="15" SDNUM="3081;"> + <P ALIGN=CENTER>15</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_TIME_CRITICAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="15" SDNUM="3081;"> + <P ALIGN=CENTER>15</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>ABOVE_NORMAL_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_TIME_CRITICAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="16" SDNUM="3081;"> + <P ALIGN=CENTER>16</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>REALTIME_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_IDLE</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="17" SDNUM="3081;"> + <P ALIGN=CENTER>17</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>REALTIME_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=BOTTOM SDVAL="-7" SDNUM="3081;"> + <P ALIGN=LEFT>-7</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="18" SDNUM="3081;"> + <P ALIGN=CENTER>18</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>REALTIME_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=BOTTOM SDVAL="-6" SDNUM="3081;"> + <P ALIGN=LEFT>-6</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="19" SDNUM="3081;"> + <P ALIGN=CENTER>19</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>REALTIME_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=BOTTOM SDVAL="-5" SDNUM="3081;"> + <P ALIGN=LEFT>-5</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="20" SDNUM="3081;"> + <P ALIGN=CENTER>20</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>REALTIME_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=BOTTOM SDVAL="-4" SDNUM="3081;"> + <P ALIGN=LEFT>-4</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="21" SDNUM="3081;"> + <P ALIGN=CENTER>21</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>REALTIME_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=BOTTOM SDVAL="-3" SDNUM="3081;"> + <P ALIGN=LEFT>-3</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="22" SDNUM="3081;"> + <P ALIGN=CENTER>22</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>REALTIME_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_LOWEST</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="23" SDNUM="3081;"> + <P ALIGN=CENTER>23</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>REALTIME_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_BELOW_NORMAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="24" SDNUM="3081;"> + <P ALIGN=CENTER>24</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>REALTIME_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_NORMAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="25" SDNUM="3081;"> + <P ALIGN=CENTER>25</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>REALTIME_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_ABOVE_NORMAL</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="26" SDNUM="3081;"> + <P ALIGN=CENTER>26</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>REALTIME_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_HIGHEST</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="27" SDNUM="3081;"> + <P ALIGN=CENTER>27</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>REALTIME_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=BOTTOM SDVAL="3" SDNUM="3081;"> + <P ALIGN=LEFT>3</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="28" SDNUM="3081;"> + <P ALIGN=CENTER>28</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>REALTIME_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=BOTTOM SDVAL="4" SDNUM="3081;"> + <P ALIGN=LEFT>4</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="29" SDNUM="3081;"> + <P ALIGN=CENTER>29</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>REALTIME_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=BOTTOM SDVAL="5" SDNUM="3081;"> + <P ALIGN=LEFT>5</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="30" SDNUM="3081;"> + <P ALIGN=CENTER>30</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>REALTIME_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=BOTTOM SDVAL="6" SDNUM="3081;"> + <P ALIGN=LEFT>6</P> + </TD> + </TR> + <TR> + <TD WIDTH=50 VALIGN=BOTTOM SDVAL="31" SDNUM="3081;"> + <P ALIGN=CENTER>31</P> + </TD> + <TD WIDTH=356 VALIGN=TOP> + <P ALIGN=LEFT>REALTIME_PRIORITY_CLASS</P> + </TD> + <TD WIDTH=336 VALIGN=TOP> + <P ALIGN=LEFT>THREAD_PRIORITY_TIME_CRITICAL</P> + </TD> + </TR> + </TBODY> + </TABLE> + </DL> +</DL> +<P STYLE="margin-left: 2cm">Windows NT: Values -7, -6, -5, -4, -3, 3, +4, 5, and 6 are not supported.</P> +<P STYLE="margin-left: 2cm">As you can see, the real priority levels +available to any individual Win32 thread are non-contiguous.</P> +<P STYLE="margin-left: 2cm">An application using Pthreads-w32 should +not make assumptions about the numbers used to represent thread +priority levels, except that they are monotonic between the values +returned by sched_get_priority_min() and sched_get_priority_max(). +E.g. Windows 95, 98, NT, 2000, XP make available a non-contiguous +range of numbers between -15 and 15, while at least one version of +WinCE (3.0) defines the minimum priority (THREAD_PRIORITY_LOWEST) as +5, and the maximum priority (THREAD_PRIORITY_HIGHEST) as 1.</P> +<P STYLE="margin-left: 2cm">Internally, pthreads-win32 maps any +priority levels between THREAD_PRIORITY_IDLE and +THREAD_PRIORITY_LOWEST to THREAD_PRIORITY_LOWEST, or between +THREAD_PRIORITY_TIME_CRITICAL and THREAD_PRIORITY_HIGHEST to +THREAD_PRIORITY_HIGHEST. Currently, this also applies to +REALTIME_PRIORITY_CLASS even if levels -7, -6, -5, -4, -3, 3, 4, 5, +and 6 are supported.</P> +<P STYLE="margin-left: 2cm">If it wishes, a Win32 application using +pthreads-w32 can use the Win32 defined priority macros +THREAD_PRIORITY_IDLE through THREAD_PRIORITY_TIME_CRITICAL.</P> +<H2><A HREF="#toc3" NAME="sect3">Author</A></H2> +<P>Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<H2><A HREF="#toc4" NAME="sect4">See also</A></H2> +<P><BR><BR> +</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Author</A> + </P> + <LI><P><A HREF="#sect4" NAME="toc4">See also</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/index.html b/manual/index.html new file mode 100644 index 0000000..a209dc0 --- /dev/null +++ b/manual/index.html @@ -0,0 +1,146 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE></TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;17350500"> + <META NAME="CHANGED" CONTENT="20050506;12240700"> +</HEAD> +<BODY LANG="en-GB" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<H3>Table of Contents</H3> +<P STYLE="margin-left: 2cm"><A HREF="#sect1" NAME="toc1">POSIX +threads API reference</A><BR><A HREF="#sect2" NAME="toc2">Miscellaneous +POSIX thread safe routines provided by Pthreads-w32</A><BR><A HREF="#sect3" NAME="toc3">Non-portable +Pthreads-w32 routines</A><BR><A HREF="#sect4" NAME="toc4">Other</A></P> +<H2><A HREF="#toc1" NAME="sect1">POSIX threads API reference</A></H2> +<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_destroy</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_getdetachstate</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_getinheritsched</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_getschedparam</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_getschedpolicy</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_getscope</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_setstackaddr.html"><B>pthread_attr_getstackaddr</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_setstacksize.html"><B>pthread_attr_getstacksize</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_init</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_setdetachstate</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_setinheritsched</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_setschedparam</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_setschedpolicy</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_init.html"><B>pthread_attr_setscope</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_setstackaddr.html"><B>pthread_attr_setstackaddr</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_attr_setstacksize.html"><B>pthread_attr_setstacksize</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_barrierattr_init.html"><B>pthread_barrierattr_destroy</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_barrierattr_setpshared.html"><B>pthread_barrierattr_getpshared</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_barrierattr_init.html"><B>pthread_barrierattr_init</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_barrierattr_setpshared.html"><B>pthread_barrierattr_setpshared</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_barrier_init.html"><B>pthread_barrier_destroy</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_barrier_init.html"><B>pthread_barrier_init</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_barrier_wait.html"><B>pthread_barrier_wait</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_cancel.html"><B>pthread_cancel</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_cleanup_push.html"><B>pthread_cleanup_pop</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_cleanup_push.html"><B>pthread_cleanup_push</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_condattr_init.html"><B>pthread_condattr_destroy</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_condattr_setpshared.html"><B>pthread_condattr_getpshared</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_condattr_init.html"><B>pthread_condattr_init</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_condattr_setpshared.html"><B>pthread_condattr_setpshared</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_cond_init.html"><B>pthread_cond_broadcast</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_cond_init.html"><B>pthread_cond_destroy</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_cond_init.html"><B>pthread_cond_init</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_cond_init.html"><B>pthread_cond_signal</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_cond_init.html"><B>pthread_cond_timedwait</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_cond_init.html"><B>pthread_cond_wait</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_create.html"><B>pthread_create</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_detach.html"><B>pthread_detach</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_equal.html"><B>pthread_equal</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_exit.html"><B>pthread_exit</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_setconcurrency.html"><B>pthread_getconcurrency</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_setschedparam.html"><B>pthread_getschedparam</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_key_create.html"><B>pthread_getspecific</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_join.html"><B>pthread_join</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_key_create.html"><B>pthread_key_create</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_key_create.html"><B>pthread_key_delete</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_kill.html"><B>pthread_kill</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_destroy</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_getkind_np</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_mutexattr_setpshared.html"><B>pthread_mutexattr_getpshared</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_gettype</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_init</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_setkind_np</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_mutexattr_setpshared.html"><B>pthread_mutexattr_setpshared</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_settype</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_destroy</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_init</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_lock</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_timedlock</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_trylock</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_mutex_init.html"><B>pthread_mutex_unlock</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_once.html"><B>pthread_once</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlockattr_init.html"><B>pthread_rwlockattr_destroy</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlockattr_setpshared.html"><B>pthread_rwlockattr_getpshared</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlockattr_init.html"><B>pthread_rwlockattr_init</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlockattr_setpshared.html"><B>pthread_rwlockattr_setpshared</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlock_init.html"><B>pthread_rwlock_destroy</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlock_init.html"><B>pthread_rwlock_init</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlock_rdlock.html"><B>pthread_rwlock_rdlock</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlock_timedrdlock.html"><B>pthread_rwlock_timedrdlock</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlock_timedwrlock.html"><B>pthread_rwlock_timedwrlock</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlock_rdlock.html"><B>pthread_rwlock_tryrdlock</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlock_wrlock.html"><B>pthread_rwlock_trywrlock</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlock_unlock.html"><B>pthread_rwlock_unlock</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_rwlock_wrlock.html"><B>pthread_rwlock_wrlock</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_self.html"><B>pthread_self</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_cancel.html"><B>pthread_setcancelstate</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_cancel.html"><B>pthread_setcanceltype</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_setconcurrency.html"><B>pthread_setconcurrency</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_setschedparam.html"><B>pthread_setschedparam</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_key_create.html"><B>pthread_setspecific</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_kill.html"><B>pthread_sigmask</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_spin_init.html"><B>pthread_spin_destroy</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_spin_init.html"><B>pthread_spin_init</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_spin_lock.html"><B>pthread_spin_lock</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_spin_lock.html"><B>pthread_spin_trylock</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_spin_unlock.html"><B>pthread_spin_unlock</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_cancel.html"><B>pthread_testcancel</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="sched_get_priority_max.html"><B>sched_get_priority_max</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="sched_get_priority_max.html"><B>sched_get_priority_min</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="sched_getscheduler.html"><B>sched_getscheduler</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="sched_setscheduler.html"><B>sched_setscheduler</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="sched_yield.html"><B>sched_yield</B></A></P> +<P STYLE="margin-left: 2cm"><B>sem_close</B></P> +<P STYLE="margin-left: 2cm"><A HREF="sem_init.html"><B>sem_destroy</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="sem_init.html"><B>sem_getvalue</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="sem_init.html"><B>sem_init</B></A></P> +<P STYLE="margin-left: 2cm"><B>sem_open</B></P> +<P STYLE="margin-left: 2cm"><A HREF="sem_init.html"><B>sem_post</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="sem_init.html"><B>sem_post_multiple</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="sem_init.html"><B>sem_timedwait</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="sem_init.html"><B>sem_trywait</B></A></P> +<P STYLE="margin-left: 2cm"><B>sem_unlink</B></P> +<P STYLE="margin-left: 2cm"><A HREF="sem_init.html"><B>sem_wait</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_kill.html"><B>sigwait</B></A></P> +<H2><A HREF="#toc2" NAME="sect2">Miscellaneous POSIX thread safe +routines provided by Pthreads-w32</A></H2> +<P STYLE="margin-left: 2cm"><B>asctime_r</B></P> +<P STYLE="margin-left: 2cm"><B>ctime_r</B></P> +<P STYLE="margin-left: 2cm"><B>gmtime_r</B></P> +<P STYLE="margin-left: 2cm"><B>localtime_r</B></P> +<P STYLE="margin-left: 2cm"><B>rand_r</B></P> +<H2><A HREF="#toc3" NAME="sect3">Non-portable Pthreads-w32 routines</A></H2> +<P STYLE="margin-left: 2cm"><A HREF="pthreadCancelableWait.html"><B>pthreadCancelableTimedWait</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthreadCancelableWait.html"><B>pthreadCancelableWait</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_delay_np.html"><B>pthread_delay_np</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_getw32threadhandle_np.html"><B>pthread_getw32threadhandle_np</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_num_processors_np.html"><B>pthread_num_processors_np</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_win32_test_features_np.html"><B>pthread_win32_test_features_np</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_timechange_handler_np.html"><B>pthread_timechange_handler_np</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_win32_attach_detach_np.html"><B>pthread_win32_process_attach_np</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_win32_attach_detach_np.html"><B>pthread_win32_process_detach_np</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_win32_attach_detach_np.html"><B>pthread_win32_thread_attach_np</B></A></P> +<P STYLE="margin-left: 2cm"><A HREF="pthread_win32_attach_detach_np.html"><B>pthread_win32_thread_detach_np</B></A></P> +<H2><A HREF="#toc4" NAME="sect4">Other</A></H2> +<P STYLE="margin-left: 2cm"><A HREF="PortabilityIssues.html"><B>Portability +issues</B></A></P> +</BODY> +</HTML> diff --git a/manual/pthreadCancelableWait.html b/manual/pthreadCancelableWait.html new file mode 100644 index 0000000..9d7c1a4 --- /dev/null +++ b/manual/pthreadCancelableWait.html @@ -0,0 +1,86 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREADCANCELLABLEWAIT manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;322600"> + <META NAME="CHANGED" CONTENT="20050505;23242300"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P STYLE="font-weight: medium">pthreadCancelableTimedWait, +pthreadCancelableWait – provide cancellation hooks for user Win32 +routines</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>int pthreadCancelableTimedWait (HANDLE </B><I>waitHandle</I><B>, +DWORD </B><I>timeout</I><B>);</B></P> +<P><B>int pthreadCancelableWait (HANDLE </B><I>waitHandle</I><B>);</B></P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>These two functions provide hooks into the <A HREF="pthread_cancel.html"><B>pthread_cancel</B></A>() +mechanism that will allow you to wait on a Windows handle and make it +a cancellation point. Both functions block until either the given +Win32 <B>HANDLE</B> is signalled, or <A HREF="pthread_cancel.html"><B>pthread_cancel</B></A>() +has been called. They are implemented using <B>WaitForMultipleObjects</B> +on <I>waitHandle</I> and the manually reset Win32 event handle that +is the target of <A HREF="pthread_cancel.html"><B>pthread_cancel</B></A>(). +These routines may be called from Win32 native threads but +<A HREF="pthread_cancel.html"><B>pthread_cancel</B></A>() will +require that thread's POSIX thread ID that the thread must retrieve +using <A HREF="pthread_self.html"><B>pthread_self</B></A>().</P> +<P><B>pthreadCancelableTimedWait</B> is the timed version that will +return with the code <B>ETIMEDOUT</B> if the interval <I>timeout</I> +milliseconds elapses before <I>waitHandle</I> is signalled.</P> +<H2><A HREF="#toc3" NAME="sect3">Cancellation</A></H2> +<P>These routines allow routines that block on Win32 HANDLEs to be +cancellable via <A HREF="pthread_cancel.html"><B>pthread_cancel</B></A>().</P> +<H2><A HREF="#toc4" NAME="sect4">Return Value</A></H2> +<P><BR><BR> +</P> +<H2><A HREF="#toc5" NAME="sect5">Errors</A></H2> +<P>The <B>pthreadCancelableTimedWait</B> function returns the +following error code on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>ETIMEDOUT</B> + </DT></DL> +</DL> +<P STYLE="margin-left: 2cm"> +The interval <I>timeout</I> milliseconds elapsed before <I>waitHandle</I> +was signalled.</P> +<H2><A HREF="#toc6" NAME="sect6">Author</A></H2> +<P>Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<H2><A HREF="#toc7" NAME="sect7">See also</A></H2> +<P><A HREF="pthread_cancel.html"><B>pthread_cancel()</B></A>, +<A HREF="pthread_self.html"><B>pthread_self()</B></A></P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Cancellation</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4"></A><A HREF="#sect4" NAME="toc4">Return + Value</A><A HREF="#sect4" NAME="toc4"></A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Author</A> + </P> + <LI><P><A HREF="#sect7" NAME="toc7">See also</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_attr_init.html b/manual/pthread_attr_init.html new file mode 100644 index 0000000..fa5ab58 --- /dev/null +++ b/manual/pthread_attr_init.html @@ -0,0 +1,280 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_ATTR_INIT(3) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;10092900"> + <META NAME="CHANGED" CONTENT="20050505;16540200"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_attr_init, pthread_attr_destroy, +pthread_attr_setdetachstate, pthread_attr_getdetachstate, +pthread_attr_setschedparam, pthread_attr_getschedparam, +pthread_attr_setschedpolicy, pthread_attr_getschedpolicy, +pthread_attr_setinheritsched, pthread_attr_getinheritsched, +pthread_attr_setscope, pthread_attr_getscope - thread creation +attributes +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>int pthread_attr_init(pthread_attr_t *</B><I>attr</I><B>);</B> +</P> +<P><B>int pthread_attr_destroy(pthread_attr_t *</B><I>attr</I><B>);</B> +</P> +<P><B>int pthread_attr_setdetachstate(pthread_attr_t *</B><I>attr</I><B>, +int </B><I>detachstate</I><B>);</B> +</P> +<P><B>int pthread_attr_getdetachstate(const pthread_attr_t *</B><I>attr</I><B>, +int *</B><I>detachstate</I><B>);</B> +</P> +<P><B>int pthread_attr_setschedpolicy(pthread_attr_t *</B><I>attr</I><B>, +int </B><I>policy</I><B>);</B> +</P> +<P><B>int pthread_attr_getschedpolicy(const pthread_attr_t *</B><I>attr</I><B>, +int *</B><I>policy</I><B>);</B> +</P> +<P><B>int pthread_attr_setschedparam(pthread_attr_t *</B><I>attr</I><B>, +const struct sched_param *</B><I>param</I><B>);</B> +</P> +<P><B>int pthread_attr_getschedparam(const pthread_attr_t *</B><I>attr</I><B>, +struct sched_param *</B><I>param</I><B>);</B> +</P> +<P><B>int pthread_attr_setinheritsched(pthread_attr_t *</B><I>attr</I><B>, +int </B><I>inherit</I><B>);</B> +</P> +<P><B>int pthread_attr_getinheritsched(const pthread_attr_t *</B><I>attr</I><B>, +int *</B><I>inherit</I><B>);</B> +</P> +<P><B>int pthread_attr_setscope(pthread_attr_t *</B><I>attr</I><B>, +int </B><I>scope</I><B>);</B> +</P> +<P><B>int pthread_attr_getscope(const pthread_attr_t *</B><I>attr</I><B>, +int *</B><I>scope</I><B>);</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>Setting attributes for threads is achieved by filling a thread +attribute object <I>attr</I> of type <B>pthread_attr_t</B>, then +passing it as second argument to <A HREF="pthread_create.html"><B>pthread_create</B>(3)</A> +. Passing <B>NULL</B> is equivalent to passing a thread attribute +object with all attributes set to their default values. +</P> +<P><B>pthread_attr_init</B> initializes the thread attribute object +<I>attr</I> and fills it with default values for the attributes. (The +default values are listed below for each attribute.) +</P> +<P>Each attribute <I>attrname</I> (see below for a list of all +attributes) can be individually set using the function +<B>pthread_attr_set</B><I>attrname</I> and retrieved using the +function <B>pthread_attr_get</B><I>attrname.</I> +</P> +<P><B>pthread_attr_destroy</B> destroys a thread attribute object, +which must not then be reused until it is reinitialized. +</P> +<P>Attribute objects are consulted only when creating a new thread. +The same attribute object can be used for creating several threads. +Modifying an attribute object after a call to <B>pthread_create</B> +does not change the attributes of the thread previously created. +</P> +<P>The following thread attributes are supported: +</P> +<H3><A HREF="#toc3" NAME="sect3">detachstate</A></H3> +<P>Control whether the thread is created in the joinable state (value +<B>PTHREAD_CREATE_JOINABLE</B>) or in the detached state ( +<B>PTHREAD_CREATE_DETACHED</B>). +</P> +<P>Default value: <B>PTHREAD_CREATE_JOINABLE</B>. +</P> +<P>In the joinable state, another thread can synchronize on the +thread termination and recover its termination code using +<A HREF="pthread_join.html"><B>pthread_join</B>(3)</A> . When a +joinable thread terminates, some of the thread resources are kept +allocated, and released only when another thread performs +<A HREF="pthread_join.html"><B>pthread_join</B>(3)</A> on that +thread. +</P> +<P>In the detached state, the thread's resources are released +immediately when it terminates. <A HREF="pthread_join.html"><B>pthread_join</B>(3)</A> +cannot be used to synchronize on the thread termination. +</P> +<P>A thread created in the joinable state can later be put in the +detached thread using <A HREF="pthread_detach.html"><B>pthread_detach</B>(3)</A> +. +</P> +<H3><A HREF="#toc4" NAME="sect4">schedpolicy</A></H3> +<P>Select the scheduling policy for the thread: one of <B>SCHED_OTHER</B> +(regular, non-real-time scheduling), <B>SCHED_RR</B> (real-time, +round-robin) or <B>SCHED_FIFO</B> (real-time, first-in first-out). +</P> +<P><B>Pthreads-w32</B> only supports <B>SCHED_OTHER</B> - attempting +to set one of the other policies will return an error ENOTSUP.</P> +<P>Default value: <B>SCHED_OTHER</B>. +</P> +<P><B>Pthreads-w32</B> only supports <B>SCHED_OTHER</B> - attempting +to set one of the other policies will return an error ENOTSUP.</P> +<P>The scheduling policy of a thread can be changed after creation +with <A HREF="pthread_setschedparam.html"><B>pthread_setschedparam</B>(3)</A> +. +</P> +<H3><A HREF="#toc5" NAME="sect5">schedparam</A></H3> +<P>Contain the scheduling parameters (essentially, the scheduling +priority) for the thread.</P> +<P><B>Pthreads-w32</B> supports the priority levels defined by the +Windows system it is running on. Under Windows, thread priorities are +relative to the process priority class, which must be set via the +Windows W32 API.</P> +<P>Default value: priority is 0 (Win32 level <B>THREAD_PRIORITY_NORMAL</B>). +</P> +<P>The scheduling priority of a thread can be changed after creation +with <A HREF="pthread_setschedparam.html"><B>pthread_setschedparam</B>(3)</A> +. +</P> +<H3><A HREF="#toc6" NAME="sect6">inheritsched</A></H3> +<P>Indicate whether the scheduling policy and scheduling parameters +for the newly created thread are determined by the values of the +<I>schedpolicy</I> and <I>schedparam</I> attributes (value +<B>PTHREAD_EXPLICIT_SCHED</B>) or are inherited from the parent +thread (value <B>PTHREAD_INHERIT_SCHED</B>). +</P> +<P>Default value: <B>PTHREAD_EXPLICIT_SCHED</B>. +</P> +<H3><A HREF="#toc7" NAME="sect7">scope</A></H3> +<P>Define the scheduling contention scope for the created thread. The +only value supported in the <B>Pthreads-w32</B> implementation is +<B>PTHREAD_SCOPE_SYSTEM</B>, meaning that the threads contend for CPU +time with all processes running on the machine. The other value +specified by the standard, <B>PTHREAD_SCOPE_PROCESS</B>, means that +scheduling contention occurs only between the threads of the running +process.</P> +<P><B>Pthreads-w32</B> only supports <B>PTHREAD_SCOPE_SYSTEM</B>.</P> +<P>Default value: <B>PTHREAD_SCOPE_SYSTEM</B>. +</P> +<H2><A HREF="#toc8" NAME="sect8">Return Value</A></H2> +<P>All functions return 0 on success and a non-zero error code on +error. On success, the <B>pthread_attr_get</B><I>attrname</I> +functions also store the current value of the attribute <I>attrname</I> +in the location pointed to by their second argument. +</P> +<H2><A HREF="#toc9" NAME="sect9">Errors</A></H2> +<P>The <B>pthread_attr_setdetachstate</B> function returns the +following error codes on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the specified <I>detachstate</I> is not one of + <B>PTHREAD_CREATE_JOINABLE</B> or <B>PTHREAD_CREATE_DETACHED</B>. + </DD></DL> +</DL> +<P> +The <B>pthread_attr_setschedparam</B> function returns the following +error codes on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the priority specified in <I>param</I> is outside the range of + allowed priorities for the scheduling policy currently in <I>attr</I> + (1 to 99 for <B>SCHED_FIFO</B> and <B>SCHED_RR</B>; 0 for + <B>SCHED_OTHER</B>). + </DD></DL> +</DL> +<P> +The <B>pthread_attr_setschedpolicy</B> function returns the following +error codes on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the specified <I>policy</I> is not one of <B>SCHED_OTHER</B>, + <B>SCHED_FIFO</B>, or <B>SCHED_RR</B>. + </DD><DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + <B>ENOTSUP</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + <I>policy</I> is not <B>SCHED_OTHER</B>, the only value supported + by <B>Pthreads-w32</B>.</DD></DL> +</DL> +<P> +The <B>pthread_attr_setinheritsched</B> function returns the +following error codes on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the specified <I>inherit</I> is not one of <B>PTHREAD_INHERIT_SCHED</B> + or <B>PTHREAD_EXPLICIT_SCHED</B>. + </DD></DL> +</DL> +<P> +The <B>pthread_attr_setscope</B> function returns the following error +codes on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the specified <I>scope</I> is not one of <B>PTHREAD_SCOPE_SYSTEM</B> + or <B>PTHREAD_SCOPE_PROCESS</B>. + </DD><DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + <B>ENOTSUP</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the specified <I>scope</I> is <B>PTHREAD_SCOPE_PROCESS</B> (not + supported by <B>Pthreads-w32</B>). + </DD></DL> +</DL> +<H2> +<A HREF="#toc10" NAME="sect10">Author</A></H2> +<P>Xavier Leroy <Xavier.Leroy@inria.fr> +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<H2><A HREF="#toc11" NAME="sect11">See Also</A></H2> +<P><A HREF="pthread_create.html"><B>pthread_create</B>(3)</A> , +<A HREF="pthread_join.html"><B>pthread_join</B>(3)</A> , +<A HREF="pthread_detach.html"><B>pthread_detach</B>(3)</A> , +<A HREF="pthread_setschedparam.html"><B>pthread_setschedparam</B>(3)</A> +. +</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">detachstate</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">schedpolicy</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">schedparam</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">inheritsched</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">scope</A> + </P> + </UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect10" NAME="toc10">Author</A> + </P> + <LI><P><A HREF="#sect11" NAME="toc11">See Also</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_attr_setstackaddr.html b/manual/pthread_attr_setstackaddr.html new file mode 100644 index 0000000..868832c --- /dev/null +++ b/manual/pthread_attr_setstackaddr.html @@ -0,0 +1,158 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"PTHREAD_ATTR_GETSTACKADDR"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;11025500"> + <META NAME="CHANGED" CONTENT="20050505;17571400"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_attr_getstackaddr, pthread_attr_setstackaddr - get and set +the stackaddr attribute +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h> </B> +</P> +<P><B>int pthread_attr_getstackaddr(const pthread_attr_t *restrict</B> +<I>attr</I><B>, void **restrict</B> <I>stackaddr</I><B>); <BR>int +pthread_attr_setstackaddr(pthread_attr_t *</B><I>attr</I><B>, void +*</B><I>stackaddr</I><B>); </B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>pthread_attr_getstackaddr</B> and <B>pthread_attr_setstackaddr</B> +functions, respectively, shall get and set the thread creation +<I>stackaddr</I> attribute in the <I>attr</I> object. +</P> +<P>The <I>stackaddr</I> attribute specifies the location of storage +to be used for the created thread’s stack. The size of the storage +shall be at least {PTHREAD_STACK_MIN}. +</P> +<P><B>Pthreads-w32</B> defines <B>_POSIX_THREAD_ATTR_STACKADDR</B> in +pthread.h as -1 to indicate that these routines are implemented but +cannot used to set or get the stack address. These routines always +return the error ENOSYS when called.</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>Upon successful completion, <B>pthread_attr_getstackaddr</B> and +<B>pthread_attr_setstackaddr</B> shall return a value of 0; +otherwise, an error number shall be returned to indicate the error. +</P> +<P>The <B>pthread_attr_getstackaddr</B> function stores the <I>stackaddr</I> +attribute value in <I>stackaddr</I> if successful. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>The <B>pthread_attr_setstackaddr</B> function always returns the +following error code: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>ENOSYS</B></DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + The function is not supported. + </DD></DL> +</DL> +<P> +The <B>pthread_attr_getstackaddr</B> function always returns the +following error code: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>ENOSYS</B></DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + The function is not supported. + </DD></DL> +</DL> +<P> +These functions shall not return an error code of [EINTR]. +</P> +<P><I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P>The specification of the <I>stackaddr</I> attribute presents +several ambiguities that make portable use of these interfaces +impossible. The description of the single address parameter as a +"stack" does not specify a particular relationship between +the address and the "stack" implied by that address. For +example, the address may be taken as the low memory address of a +buffer intended for use as a stack, or it may be taken as the address +to be used as the initial stack pointer register value for the new +thread. These two are not the same except for a machine on which the +stack grows "up" from low memory to high, and on which a +"push" operation first stores the value in memory and then +increments the stack pointer register. Further, on a machine where +the stack grows "down" from high memory to low, +interpretation of the address as the "low memory" address +requires a determination of the intended size of the stack. +IEEE Std 1003.1-2001 has introduced the new interfaces +<A HREF="pthread_attr_setstack.html"><B>pthread_attr_setstack</B>(3)</A> +and <A HREF="pthread_attr_getstack.html"><B>pthread_attr_getstack</B>(3)</A> +to resolve these ambiguities. +</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P><A HREF="pthread_attr_init.html"><B>pthread_attr_destroy</B>(3)</A> +, <A HREF="pthread_attr_init.html"><B>pthread_attr_getdetachstate</B>(3)</A> +, <A HREF="pthread_attr_getstack.html"><B>pthread_attr_getstack</B>(3)</A> +, <A HREF="pthread_attr_getstacksize.html"><B>pthread_attr_getstacksize</B>(3)</A> +, <A HREF="pthread_attr_setstack.html"><B>pthread_attr_setstack</B>(3)</A> +, <A HREF="pthread_create.html"><B>pthread_create</B>(3)</A> , the +Base Definitions volume of IEEE Std 1003.1-2001, +<I><limits.h></I>, <I><pthread.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_attr_setstacksize.html b/manual/pthread_attr_setstacksize.html new file mode 100644 index 0000000..ae9d031 --- /dev/null +++ b/manual/pthread_attr_setstacksize.html @@ -0,0 +1,127 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"PTHREAD_ATTR_GETSTACKSIZE"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;11224900"> + <META NAME="CHANGED" CONTENT="20050505;18003200"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_attr_getstacksize, pthread_attr_setstacksize - get and set +the stacksize attribute +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h> </B> +</P> +<P><B>int pthread_attr_getstacksize(const pthread_attr_t *restrict</B> +<I>attr</I><B>, size_t *restrict</B> <I>stacksize</I><B>); <BR>int +pthread_attr_setstacksize(pthread_attr_t *</B><I>attr</I><B>, size_t</B> +<I>stacksize</I><B>); </B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>pthread_attr_getstacksize</B> and <B>pthread_attr_setstacksize</B> +functions, respectively, shall get and set the thread creation +<I>stacksize</I> attribute in the <I>attr</I> object. +</P> +<P>The <I>stacksize</I> attribute shall define the minimum stack size +(in bytes) allocated for the created threads stack. +</P> +<P><B>Pthreads-w32</B> defines <B>_POSIX_THREAD_ATTR_STACKSIZE</B> in +pthread.h to indicate that these routines are implemented and may be +used to set or get the stack size.</P> +<P>Default value: 0 (in Pthreads-w32 a value of 0 means the stack +will grow as required)</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>Upon successful completion, <B>pthread_attr_getstacksize</B> and +<B>pthread_attr_setstacksize</B> shall return a value of 0; +otherwise, an error number shall be returned to indicate the error. +</P> +<P>The <B>pthread_attr_getstacksize</B> function stores the <I>stacksize</I> +attribute value in <I>stacksize</I> if successful. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>The <B>pthread_attr_setstacksize</B> function shall fail if: +</P> +<DL> + <DT><B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The value of <I>stacksize</I> is less than {PTHREAD_STACK_MIN} or + exceeds a system-imposed limit. + </DD></DL> +<P> +These functions shall not return an error code of [EINTR]. +</P> +<P><I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P>None. +</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P><A HREF="pthread_attr_init.html"><B>pthread_attr_destroy</B>(3)</A> +<B>,</B> <A HREF="pthread_attr_setstackaddr.html"><B>pthread_attr_getstackaddr</B>(3)</A> +<B>,</B> <A HREF="pthread_attr_init.html"><B>pthread_attr_getdetachstate</B>(3)</A> +<B>,</B> <A HREF="pthread_create.html"><B>pthread_create</B>(3)</A> <B>,</B> +the Base Definitions volume of IEEE Std 1003.1-2001, +<I><limits.h></I>, <I><pthread.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_barrier_init.html b/manual/pthread_barrier_init.html new file mode 100644 index 0000000..d12434d --- /dev/null +++ b/manual/pthread_barrier_init.html @@ -0,0 +1,187 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"PTHREAD_BARRIER_DESTROY"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;11372800"> + <META NAME="CHANGED" CONTENT="20050505;18164500"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_barrier_destroy, pthread_barrier_init - destroy and +initialize a barrier object (<B>ADVANCED REALTIME THREADS</B>) +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h> </B> +</P> +<P><B>int pthread_barrier_destroy(pthread_barrier_t *</B><I>barrier</I><B>); +<BR>int pthread_barrier_init(pthread_barrier_t *restrict</B> <I>barrier</I><B>, +const pthread_barrierattr_t *restrict</B> <I>attr</I><B>, unsigned</B> +<I>count</I><B>); </B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>pthread_barrier_destroy</B> function shall destroy the +barrier referenced by <I>barrier</I> and release 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 +<B>pthread_barrier_init</B> . An implementation may use this function +to set <I>barrier</I> to an invalid value. The results are undefined +if <B>pthread_barrier_destroy</B> is called when any thread is +blocked on the barrier, or if this function is called with an +uninitialized barrier. +</P> +<P>The <B>pthread_barrier_init</B> function shall allocate any +resources required to use the barrier referenced by <I>barrier</I> +and shall initialize the barrier with attributes referenced by <I>attr</I>. +If <I>attr</I> is NULL, the default barrier attributes shall be used; +the effect is the same as passing the address of a default barrier +attributes object. The results are undefined if <B>pthread_barrier_init</B> +is called when any thread is blocked on the barrier (that is, has not +returned from the <A HREF="pthread_barrier_wait.html"><B>pthread_barrier_wait</B>(3)</A> +call). The results are undefined if a barrier is used without first +being initialized. The results are undefined if <B>pthread_barrier_init</B> +is called specifying an already initialized barrier. +</P> +<P>The <I>count</I> argument specifies the number of threads that +must call <A HREF="pthread_barrier_wait.html"><B>pthread_barrier_wait</B>(3)</A> +before any of them successfully return from the call. The value +specified by <I>count</I> must be greater than zero. +</P> +<P>If the <B>pthread_barrier_init</B> function fails, the barrier +shall not be initialized and the contents of <I>barrier</I> are +undefined. +</P> +<P>Only the object referenced by <I>barrier</I> may be used for +performing synchronization. The result of referring to copies of that +object in calls to <B>pthread_barrier_destroy</B> <B>or</B> +<A HREF="pthread_barrier_wait.html"><B>pthread_barrier_wait</B>(3)</A> +is undefined.</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>Upon successful completion, these functions shall return zero; +otherwise, an error number shall be returned to indicate the error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>The <B>pthread_barrier_destroy</B><SPAN STYLE="font-weight: medium"> +function may fail if:</SPAN> +</P> +<DL> + <DT><B>EBUSY</B> + </DT><DD> + The implementation has detected an attempt to destroy a barrier + while it is in use (for example, while being used in a + <A HREF="pthread_barrier_wait.html"><B>pthread_barrier_wait</B>(3)</A> + call) by another thread. + </DD><DT> + <B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The value specified by <I>barrier</I> is invalid. + </DD></DL> +<P> +The <B>pthread_barrier_init</B> function shall fail if: +</P> +<DL> + <DT><B>EAGAIN</B> + </DT><DD> + The system lacks the necessary resources to initialize another + barrier. + </DD><DT> + <B>EINVAL</B> + </DT><DD> + The value specified by <I>count</I> is equal to zero. + </DD><DT> + <B>ENOMEM</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + Insufficient memory exists to initialize the barrier. + </DD></DL> +<P> +The <B>pthread_barrier_init</B> function may fail if: +</P> +<DL> + <DT><B>EBUSY</B> + </DT><DD> + The implementation has detected an attempt to reinitialize a barrier + while it is in use (for example, while being used in a + <A HREF="pthread_barrier_wait.html"><B>pthread_barrier_wait</B>(3)</A> + call) by another thread. + </DD><DT> + <B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The value specified by <I>attr</I> is invalid. + </DD></DL> +<P> +These functions shall not return an error code of [EINTR]. +</P> +<P><I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P>The <B>pthread_barrier_destroy</B> and <B>pthread_barrier_init</B> +functions are part of the Barriers option and need not be provided on +all implementations. +</P> +<P><B>Pthreads-w32</B> defines <B>_POSIX_BARRIERS</B> to indicate +that these routines are implemented and may be used.</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P><A HREF="pthread_barrier_wait.html"><B>pthread_barrier_wait</B>(3)</A> +<B>,</B> the Base Definitions volume of IEEE Std 1003.1-2001, +<I><pthread.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_barrier_wait.html b/manual/pthread_barrier_wait.html new file mode 100644 index 0000000..b44035b --- /dev/null +++ b/manual/pthread_barrier_wait.html @@ -0,0 +1,152 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"PTHREAD_BARRIER_WAIT"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;11484200"> + <META NAME="CHANGED" CONTENT="20050505;18111200"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_barrier_wait - synchronize at a barrier (<B>ADVANCED +REALTIME THREADS</B>) +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h> </B> +</P> +<P><B>int pthread_barrier_wait(pthread_barrier_t *</B><I>barrier</I><B>); +</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>pthread_barrier_wait</B> function shall synchronize +participating threads at the barrier referenced by <I>barrier</I>. +The calling thread shall block until the required number of threads +have called <B>pthread_barrier_wait</B> specifying the barrier. +</P> +<P>When the required number of threads have called +<B>pthread_barrier_wait</B> specifying the barrier, the constant +<B>PTHREAD_BARRIER_SERIAL_THREAD</B> shall be returned to one +unspecified thread and zero shall be returned to each of the +remaining threads. At this point, the barrier shall be reset to the +state it had as a result of the most recent <A HREF="pthread_barrier_init.html"><B>pthread_barrier_init</B>(3)</A> +function that referenced it. +</P> +<P>The constant <B>PTHREAD_BARRIER_SERIAL_THREAD</B> is defined in +<I><pthread.h></I> and its value shall be distinct from any +other value returned by <B>pthread_barrier_wait</B> . +</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 shall resume waiting at the +barrier if the barrier wait has not completed (that is, if the +required number of threads have not arrived at the barrier during the +execution of the signal handler); otherwise, the thread shall +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 shall 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 shall be determined by the +scheduling policy. +</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>Upon successful completion, the <B>pthread_barrier_wait</B> +function shall return <B>PTHREAD_BARRIER_SERIAL_THREAD</B> for a +single (arbitrary) thread synchronized at the barrier and zero for +each of the other threads. Otherwise, an error number shall be +returned to indicate the error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>The <B>pthread_barrier_wait</B> function may fail if: +</P> +<DL> + <DT><B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The value specified by <I>barrier</I> does not refer to an + initialized barrier object. + </DD></DL> +<P> +This function shall not return an error code of [EINTR]. +</P> +<P><I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P>Applications using this function may be subject to priority +inversion, as discussed in the Base Definitions volume of +IEEE Std 1003.1-2001, Section 3.285, Priority Inversion. +</P> +<P>The <B>pthread_barrier_wait</B> function is part of the Barriers +option and need not be provided on all implementations. +</P> +<P><B>Pthreads-w32</B> defines <B>_POSIX_BARRIERS</B> to indicate +that this routine is implemented and may be used.</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P><A HREF="pthread_barrier_init.html"><B>pthread_barrier_destroy</B>(3)</A> +<B>,</B> the Base Definitions volume of IEEE Std 1003.1-2001, +<I><pthread.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_barrierattr_init.html b/manual/pthread_barrierattr_init.html new file mode 100644 index 0000000..a7c8027 --- /dev/null +++ b/manual/pthread_barrierattr_init.html @@ -0,0 +1,142 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"PTHREAD_BARRIERATTR_DESTROY"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;11502600"> + <META NAME="CHANGED" CONTENT="20050505;18032300"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_barrierattr_destroy, pthread_barrierattr_init - destroy +and initialize the barrier attributes object (<B>ADVANCED REALTIME +THREADS</B>) +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h> </B> +</P> +<P>i<B>nt pthread_barrierattr_destroy(pthread_barrierattr_t *</B><I>attr</I><B>); +<BR>int pthread_barrierattr_init(pthread_barrierattr_t *</B><I>attr</I><B>); +</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>pthread_barrierattr_destroy</B> function shall destroy a +barrier attributes object. A destroyed <I>attr</I> attributes object +can be reinitialized using <B>pthread_barrierattr_init</B> ; the +results of otherwise referencing the object after it has been +destroyed are undefined. An implementation may cause +<B>pthread_barrierattr_destroy</B> to set the object referenced by +<I>attr</I> to an invalid value. +</P> +<P>The <B>pthread_barrierattr_init</B> function shall initialize a +barrier attributes object <I>attr</I> with the default value for all +of the attributes defined by the implementation. +</P> +<P>Results are undefined if <B>pthread_barrierattr_init</B> is called +specifying an already initialized <I>attr</I> attributes object. +</P> +<P>After a barrier attributes object has been used to initialize one +or more barriers, any function affecting the attributes object +(including destruction) shall not affect any previously initialized +barrier. +</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>If successful, the <B>pthread_barrierattr_destroy</B> and +<B>pthread_barrierattr_init</B> functions shall return zero; +otherwise, an error number shall be returned to indicate the error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>The <B>pthread_barrierattr_destroy</B> function may fail if: +</P> +<DL> + <DT><B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The value specified by <I>attr</I> is invalid. + </DD></DL> +<P> +The <B>pthread_barrierattr_init</B> function shall fail if: +</P> +<DL> + <DT><B>ENOMEM</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + Insufficient memory exists to initialize the barrier attributes + object. + </DD></DL> +<P> +These functions shall not return an error code of [EINTR]. +</P> +<P><I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P>The <B>pthread_barrierattr_destroy</B> and +<B>pthread_barrierattr_init</B> functions are part of the Barriers +option and need not be provided on all implementations. +</P> +<P><B>Pthreads-w32</B> defines <B>_POSIX_BARRIERS</B> to indicate +that these routines are implemented and may be used.</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P><A HREF="pthread_barrierattr_setpshared.html"><B>pthread_barrierattr_getpshared</B>(3)</A> +<B>,</B> <A HREF="pthread_barrierattr_setpshared.html"><B>pthread_barrierattr_setpshared</B>(3)</A> +, the Base Definitions volume of IEEE Std 1003.1-2001, +<I><pthread.h></I>. +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_barrierattr_setpshared.html b/manual/pthread_barrierattr_setpshared.html new file mode 100644 index 0000000..2c62d3d --- /dev/null +++ b/manual/pthread_barrierattr_setpshared.html @@ -0,0 +1,159 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"PTHREAD_BARRIERATTR_GETPSHARED"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;11552100"> + <META NAME="CHANGED" CONTENT="20050505;18080400"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_barrierattr_getpshared, pthread_barrierattr_setpshared - +get and set the process-shared attribute of the barrier attributes +object (<B>ADVANCED REALTIME THREADS</B>) +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h> </B> +</P> +<P><B>int pthread_barrierattr_getpshared(const pthread_barrierattr_t +* restrict</B> <I>attr</I><B>, int *restrict</B> <I>pshared</I><B>); +<BR>int pthread_barrierattr_setpshared(pthread_barrierattr_t *</B><I>attr</I><B>, +int</B> <I>pshared</I><B>); </B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>pthread_barrierattr_getpshared</B> function shall obtain +the value of the <I>process-shared</I> attribute from the attributes +object referenced by <I>attr</I>. The <B>pthread_barrierattr_setpshared</B> +function shall set the <I>process-shared</I> attribute in an +initialized attributes object referenced by <I>attr</I>. +</P> +<P>The <I>process-shared</I> attribute is set to +PTHREAD_PROCESS_SHARED to permit a barrier to be operated upon by any +thread that has access to the memory where the barrier is allocated. +If the <I>process-shared</I> attribute is PTHREAD_PROCESS_PRIVATE, +the barrier shall 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 shall be +PTHREAD_PROCESS_PRIVATE. Both constants PTHREAD_PROCESS_SHARED and +PTHREAD_PROCESS_PRIVATE are defined in <I><pthread.h></I>. +</P> +<P><B>Pthreads-w32</B> defines _<B>POSIX_THREAD_PROCESS_SHARED</B> in +pthread.h as -1 to indicate that these routines are implemented but +that the process shared attribute is not supported.</P> +<P>Additional attributes, their default values, and the names of the +associated functions to get and set those attribute values are +implementation-defined. +</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>If successful, the <B>pthread_barrierattr_getpshared</B> function +shall return zero and store the value of the <I>process-shared</I> +attribute of <I>attr</I> into the object referenced by the <I>pshared</I> +parameter. Otherwise, an error number shall be returned to indicate +the error. +</P> +<P>If successful, the <B>pthread_barrierattr_setpshared</B> function +shall return zero; otherwise, an error number shall be returned to +indicate the error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>These functions may fail if: +</P> +<DL> + <DT><B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The value specified by <I>attr</I> is invalid. + </DD><DT> + The <B>pthread_barrierattr_setpshared</B> function may fail if: + </DT><DT> + <B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The new value specified for the <I>process-shared</I> attribute is + not one of the legal values <B>PTHREAD_PROCESS_SHARED</B> or + <B>PTHREAD_PROCESS_PRIVATE</B>. + </DD><DT> + <B>ENOSYS</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The value specified by <I>attr</I> was <B>PTHREAD_PROCESS_SHARED</B> + (Pthreads-w32).</DD></DL> +<P> +These functions shall not return an error code of [EINTR]. +</P> +<P><I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P>The <B>pthread_barrierattr_getpshared</B> and +<B>pthread_barrierattr_setpshared</B> functions are part of the +Barriers option and need not be provided on all implementations. +</P> +<P><B>Pthreads-w32</B> defines <B>_POSIX_BARRIERS</B> and +<B>_POSIX_THREAD_PROCESS_SHARED</B> in pthread.h as -1 to indicate +that these routines are implemented and may be used, but do not +support the process shared option.</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P><A HREF="pthread_barrier_init.html"><B>pthread_barrier_destroy</B>(3)</A> +<B>,</B> <A HREF="pthread_barrierattr_init.html"><B>pthread_barrierattr_destroy</B>(3)</A> +<B>,</B> <A HREF="pthread_barrierattr_init.html"><B>pthread_barrierattr_init</B>(3)</A> +<B>,</B> the Base Definitions volume of IEEE Std 1003.1-2001, +<I><pthread.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_cancel.html b/manual/pthread_cancel.html new file mode 100644 index 0000000..d9acd77 --- /dev/null +++ b/manual/pthread_cancel.html @@ -0,0 +1,205 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_CANCEL(3) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;12090500"> + <META NAME="CHANGED" CONTENT="20050505;18220000"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_cancel, pthread_setcancelstate, pthread_setcanceltype, +pthread_testcancel - thread cancellation +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>int pthread_cancel(pthread_t </B><I>thread</I><B>);</B> +</P> +<P><B>int pthread_setcancelstate(int </B><I>state</I><B>, int +*</B><I>oldstate</I><B>);</B> +</P> +<P><B>int pthread_setcanceltype(int </B><I>type</I><B>, int +*</B><I>oldtype</I><B>);</B> +</P> +<P><B>void pthread_testcancel(void);</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>Cancellation is the mechanism by which a thread can terminate the +execution of another thread. More precisely, a thread can send a +cancellation request to another thread. Depending on its settings, +the target thread can then either ignore the request, honor it +immediately, or defer it until it reaches a cancellation point. +</P> +<P>When a thread eventually honors a cancellation request, it +performs as if <B>pthread_exit(PTHREAD_CANCELED)</B> has been called +at that point: all cleanup handlers are executed in reverse order, +destructor functions for thread-specific data are called, and finally +the thread stops executing with the return value <B>PTHREAD_CANCELED</B>. +See <A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> for more +information. +</P> +<P><B>pthread_cancel</B> sends a cancellation request to the thread +denoted by the <I>thread</I> argument. +</P> +<P><B>pthread_setcancelstate</B> changes the cancellation state for +the calling thread -- that is, whether cancellation requests are +ignored or not. The <I>state</I> argument is the new cancellation +state: either <B>PTHREAD_CANCEL_ENABLE</B> to enable cancellation, or +<B>PTHREAD_CANCEL_DISABLE</B> to disable cancellation (cancellation +requests are ignored). If <I>oldstate</I> is not <B>NULL</B>, the +previous cancellation state is stored in the location pointed to by +<I>oldstate</I>, and can thus be restored later by another call to +<B>pthread_setcancelstate</B>. +</P> +<P><B>pthread_setcanceltype</B> changes the type of responses to +cancellation requests for the calling thread: asynchronous +(immediate) or deferred. The <I>type</I> argument is the new +cancellation type: either <B>PTHREAD_CANCEL_ASYNCHRONOUS</B> to +cancel the calling thread as soon as the cancellation request is +received, or <B>PTHREAD_CANCEL_DEFERRED</B> to keep the cancellation +request pending until the next cancellation point. If <I>oldtype</I> +is not <B>NULL</B>, the previous cancellation state is stored in the +location pointed to by <I>oldtype</I>, and can thus be restored later +by another call to <B>pthread_setcanceltype</B>. +</P> +<P><B>Pthreads-w32</B> provides two levels of support for +<B>PTHREAD_CANCEL_ASYNCHRONOUS</B>: full and partial. Full support +requires an additional DLL and driver be installed on the Windows +system (see the See Also section below) that allows blocked threads +to be cancelled immediately. Partial support means that the target +thread will not cancel until it resumes execution naturally. Partial +support is provided if either the DLL or the driver are not +automatically detected by the pthreads-w32 library at run-time.</P> +<P>Threads are always created by <A HREF="pthread_create.html"><B>pthread_create</B>(3)</A> +with cancellation enabled and deferred. That is, the initial +cancellation state is <B>PTHREAD_CANCEL_ENABLE</B> and the initial +type is <B>PTHREAD_CANCEL_DEFERRED</B>. +</P> +<P>Cancellation points are those points in the program execution +where a test for pending cancellation requests is performed and +cancellation is executed if positive. The following POSIX threads +functions are cancellation points: +</P> +<P><A HREF="pthread_join.html"><B>pthread_join</B>(3)</A> +<BR><A HREF="pthread_cond_init.html"><B>pthread_cond_wait</B>(3)</A> +<BR><A HREF="pthread_cond_init.html"><B>pthread_cond_timedwait</B>(3)</A> +<BR><A HREF=""><B>pthread_testcancel</B>(3)</A> <BR><A HREF="sem_init.html"><B>sem_wait</B>(3)</A> +<BR><A HREF="sem_init.html"><B>sem_timedwait</B>(3)</A> <BR><A HREF="pthread_kill.html"><B>sigwait</B>(3)</A></P> +<P><B>Pthreads-w32</B> provides two functions to enable additional +cancellation points to be created in user functions that block on +Win32 HANDLEs:</P> +<P><A HREF="pthreadCancelableWait.html">pthreadCancelableWait()</A> +<BR><A HREF="pthreadCancelableTimedWait.html">pthreadCancelableTimedWait()</A></P> +<P>All other POSIX threads functions are guaranteed not to be +cancellation points. That is, they never perform cancellation in +deferred cancellation mode. +</P> +<P><B>pthread_testcancel</B> does nothing except testing for pending +cancellation and executing it. Its purpose is to introduce explicit +checks for cancellation in long sequences of code that do not call +cancellation point functions otherwise. +</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P><B>pthread_cancel</B>, <B>pthread_setcancelstate</B> and +<B>pthread_setcanceltype</B> return 0 on success and a non-zero error +code on error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P><B>pthread_cancel</B> returns the following error code on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>ESRCH</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + no thread could be found corresponding to that specified by the + <I>thread</I> ID. + </DD></DL> +</DL> +<P> +<B>pthread_setcancelstate</B> returns the following error code on +error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the <I>state</I> argument is not + </DD></DL> +</DL> +<BLOCKQUOTE> +<B>PTHREAD_CANCEL_ENABLE</B> nor <B>PTHREAD_CANCEL_DISABLE</B> +</BLOCKQUOTE> +<P><B>pthread_setcanceltype</B> returns the following error code on +error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the <I>type</I> argument is not + </DD></DL> +</DL> +<BLOCKQUOTE> +<B>PTHREAD_CANCEL_DEFERRED</B> nor <B>PTHREAD_CANCEL_ASYNCHRONOUS</B> +</BLOCKQUOTE> +<H2><A HREF="#toc5" NAME="sect5">Author</A></H2> +<P>Xavier Leroy <Xavier.Leroy@inria.fr> +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<H2><A HREF="#toc6" NAME="sect6">See Also</A></H2> +<P><A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> , +<A HREF="pthread_cleanup_push.html"><B>pthread_cleanup_push</B>(3)</A> +, <A HREF="pthread_cleanup_pop.html"><B>pthread_cleanup_pop</B>(3)</A> +, Pthreads-w32 package README file 'Prerequisites' section. +</P> +<H2><A HREF="#toc7" NAME="sect7">Bugs</A></H2> +<P>POSIX specifies that a number of system calls (basically, all +system calls that may block, such as <A HREF="read.html"><B>read</B>(2)</A> +, <A HREF="write.html"><B>write</B>(2)</A> , <A HREF="wait.html"><B>wait</B>(2)</A> +, etc.) and library functions that may call these system calls (e.g. +<A HREF="fprintf.html"><B>fprintf</B>(3)</A> ) are cancellation +points. <B>Pthreads-win32</B> is not integrated enough with the C +library to implement this, and thus none of the C library functions +is a cancellation point. +</P> +<P>A workaround for these calls is to temporarily switch to +asynchronous cancellation (assuming full asynchronous cancellation +support is installed). So, checking for cancellation during a <B>read</B> +system call, for instance, can be achieved as follows: +</P> +<BLOCKQUOTE><BR><BR> +</BLOCKQUOTE> +<PRE STYLE="margin-left: 1cm; margin-right: 1cm">pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldCancelType); +read(fd, buffer, length); +pthread_setcanceltype(oldCancelType, NULL);</PRE> +<HR> +<BLOCKQUOTE><A NAME="toc"></A><B>Table of Contents</B></BLOCKQUOTE> +<UL> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Author</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">See + Also</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE><A HREF="#sect7" NAME="toc7">Bugs</A> + </BLOCKQUOTE> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_cleanup_push.html b/manual/pthread_cleanup_push.html new file mode 100644 index 0000000..0fc071e --- /dev/null +++ b/manual/pthread_cleanup_push.html @@ -0,0 +1,140 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_CLEANUP(3) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;20152200"> + <META NAME="CHANGED" CONTENT="20050505;18252600"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_cleanup_push, pthread_cleanup_pop - install and remove +cleanup handlers +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>void pthread_cleanup_push(void (*</B><I>routine</I><B>) (void +*), void *</B><I>arg</I><B>);</B> +</P> +<P><B>void pthread_cleanup_pop(int </B><I>execute</I><B>);</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>Cleanup handlers are functions that get called when a thread +terminates, either by calling <A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> +or because of cancellation. Cleanup handlers are installed and +removed following a stack-like discipline. +</P> +<P>The purpose of cleanup handlers is to free the resources that a +thread may hold at the time it terminates. In particular, if a thread +exits or is cancelled while it owns a locked mutex, the mutex will +remain locked forever and prevent other threads from executing +normally. The best way to avoid this is, just before locking the +mutex, to install a cleanup handler whose effect is to unlock the +mutex. Cleanup handlers can be used similarly to free blocks +allocated with <A HREF="malloc.html"><B>malloc</B>(3)</A> or close +file descriptors on thread termination. +</P> +<P><B>pthread_cleanup_push</B> installs the <I>routine</I> function +with argument <I>arg</I> as a cleanup handler. From this point on to +the matching <B>pthread_cleanup_pop</B>, the function <I>routine</I> +will be called with arguments <I>arg</I> when the thread terminates, +either through <A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> +or by cancellation. If several cleanup handlers are active at that +point, they are called in LIFO order: the most recently installed +handler is called first. +</P> +<P><B>pthread_cleanup_pop</B> removes the most recently installed +cleanup handler. If the <I>execute</I> argument is not 0, it also +executes the handler, by calling the <I>routine</I> function with +arguments <I>arg</I>. If the <I>execute</I> argument is 0, the +handler is only removed but not executed. +</P> +<P>Matching pairs of <B>pthread_cleanup_push</B> and +<B>pthread_cleanup_pop</B> must occur in the same function, at the +same level of block nesting. Actually, <B>pthread_cleanup_push</B> +and <B>pthread_cleanup_pop</B> are macros, and the expansion of +<B>pthread_cleanup_push</B> introduces an open brace <B>{</B> with +the matching closing brace <B>}</B> being introduced by the expansion +of the matching <B>pthread_cleanup_pop</B>. +</P> +<H2 STYLE="margin-top: 0cm"><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<BLOCKQUOTE STYLE="margin-left: 0cm; margin-right: 0cm">None. +</BLOCKQUOTE> +<H2 STYLE="margin-top: 0cm"><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<BLOCKQUOTE STYLE="margin-left: 0cm; margin-right: 0cm">None. +</BLOCKQUOTE> +<H2 STYLE="margin-top: 0cm"><A HREF="#toc5" NAME="sect5">Author</A></H2> +<BLOCKQUOTE STYLE="margin-left: 0cm; margin-right: 0cm">Xavier Leroy +<Xavier.Leroy@inria.fr> +</BLOCKQUOTE> +<BLOCKQUOTE STYLE="margin-left: 0cm; margin-right: 0cm">Modified by +Ross Johnson for use with Pthreads-w32.</BLOCKQUOTE> +<H2 STYLE="margin-top: 0cm"><A HREF="#toc6" NAME="sect6">See Also</A></H2> +<BLOCKQUOTE STYLE="margin-left: 0cm; margin-right: 0cm"><A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> +, <A HREF="pthread_cancel.html"><B>pthread_cancel</B>(3)</A> , +<A HREF="pthread_cancel.html"><B>pthread_setcanceltype</B>(3)</A> . +</BLOCKQUOTE> +<H2 STYLE="margin-top: 0cm"><A HREF="#toc7" NAME="sect7">Example</A></H2> +<BLOCKQUOTE STYLE="margin-left: 0cm; margin-right: 0cm">Here is how +to lock a mutex <I>mut</I> in such a way that it will be unlocked if +the thread is canceled while <I>mut</I> is locked: +</BLOCKQUOTE> +<PRE>pthread_cleanup_push(pthread_mutex_unlock, (void *) &mut); +pthread_mutex_lock(&mut); +/* do some work */ +pthread_mutex_unlock(&mut); +pthread_cleanup_pop(0);</PRE><BLOCKQUOTE STYLE="margin-left: 0cm; margin-right: 0cm"> +Equivalently, the last two lines can be replaced by +</BLOCKQUOTE> +<PRE STYLE="margin-bottom: 0.5cm">pthread_cleanup_pop(1);</PRE><BLOCKQUOTE STYLE="margin-left: 0cm; margin-right: 0cm"> +Notice that the code above is safe only in deferred cancellation mode +(see <A HREF="pthread_cancel.html"><B>pthread_setcanceltype</B>(3)</A> +). In asynchronous cancellation mode, a cancellation can occur +between <B>pthread_cleanup_push</B> and <B>pthread_mutex_lock</B>, or +between <B>pthread_mutex_unlock</B> and <B>pthread_cleanup_pop</B>, +resulting in both cases in the thread trying to unlock a mutex not +locked by the current thread. This is the main reason why +asynchronous cancellation is difficult to use. +</BLOCKQUOTE> +<BLOCKQUOTE STYLE="margin-left: 0cm; margin-right: 0cm">If the code +above must also work in asynchronous cancellation mode, then it must +switch to deferred mode for locking and unlocking the mutex: +</BLOCKQUOTE> +<PRE>pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype); +pthread_cleanup_push(pthread_mutex_unlock, (void *) &mut); +pthread_mutex_lock(&mut); +/* do some work */ +pthread_cleanup_pop(1); +pthread_setcanceltype(oldtype, NULL);</PRE> +<HR> +<BLOCKQUOTE STYLE="margin-left: 0cm; margin-right: 0cm"><A NAME="toc"></A> +<B>Table of Contents</B></BLOCKQUOTE> +<UL> + <LI><BLOCKQUOTE STYLE="margin-right: 0cm; margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 0cm; margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 0cm; margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 0cm; margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 0cm; margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 0cm; margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Author</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 0cm; margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">See + Also</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 0cm"><A HREF="#sect7" NAME="toc7">Example</A> + </BLOCKQUOTE> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_cond_init.html b/manual/pthread_cond_init.html new file mode 100644 index 0000000..937e490 --- /dev/null +++ b/manual/pthread_cond_init.html @@ -0,0 +1,313 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_COND(3) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;16454400"> + <META NAME="CHANGED" CONTENT="20050505;19004700"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_cond_init, pthread_cond_destroy, pthread_cond_signal, +pthread_cond_broadcast, pthread_cond_wait, pthread_cond_timedwait - +operations on conditions +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>pthread_cond_t </B><I>cond</I> <B>= PTHREAD_COND_INITIALIZER;</B> +</P> +<P><B>int pthread_cond_init(pthread_cond_t *</B><I>cond</I><B>, +pthread_condattr_t *</B><I>cond_attr</I><B>);</B> +</P> +<P><B>int pthread_cond_signal(pthread_cond_t *</B><I>cond</I><B>);</B> +</P> +<P><B>int pthread_cond_broadcast(pthread_cond_t *</B><I>cond</I><B>);</B> +</P> +<P><B>int pthread_cond_wait(pthread_cond_t *</B><I>cond</I><B>, +pthread_mutex_t *</B><I>mutex</I><B>);</B> +</P> +<P><B>int pthread_cond_timedwait(pthread_cond_t *</B><I>cond</I><B>, +pthread_mutex_t *</B><I>mutex</I><B>, const struct timespec +*</B><I>abstime</I><B>);</B> +</P> +<P><B>int pthread_cond_destroy(pthread_cond_t *</B><I>cond</I><B>);</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>A condition (short for ‘‘condition variable’’) is a +synchronization device that allows threads to suspend execution and +relinquish the processors until some predicate on shared data is +satisfied. The basic operations on conditions are: signal the +condition (when the predicate becomes true), and wait for the +condition, suspending the thread execution until another thread +signals the condition. +</P> +<P>A condition variable must always be associated with a mutex, to +avoid the race condition where a thread prepares to wait on a +condition variable and another thread signals the condition just +before the first thread actually waits on it. +</P> +<P><B>pthread_cond_init</B> initializes the condition variable <I>cond</I>, +using the condition attributes specified in <I>cond_attr</I>, or +default attributes if <I>cond_attr</I> is <B>NULL</B>. +</P> +<P>Variables of type <B>pthread_cond_t</B> can also be initialized +statically, using the constant <B>PTHREAD_COND_INITIALIZER</B>. In +the <B>Pthreads-w32</B> implementation, an application should still +call <B>pthread_cond_destroy</B> at some point to ensure that any +resources consumed by the condition variable are released.</P> +<P><B>pthread_cond_signal</B> restarts one of the threads that are +waiting on the condition variable <I>cond</I>. If no threads are +waiting on <I>cond</I>, nothing happens. If several threads are +waiting on <I>cond</I>, exactly one is restarted, but it is not +specified which. +</P> +<P><B>pthread_cond_broadcast</B> restarts all the threads that are +waiting on the condition variable <I>cond</I>. Nothing happens if no +threads are waiting on <I>cond</I>. +</P> +<P><B>pthread_cond_wait</B> atomically unlocks the <I>mutex</I> (as +per <B>pthread_unlock_mutex</B>) and waits for the condition variable +<I>cond</I> to be signalled. The thread execution is suspended and +does not consume any CPU time until the condition variable is +signalled. The <I>mutex</I> must be locked by the calling thread on +entrance to <B>pthread_cond_wait</B>. Before returning to the calling +thread, <B>pthread_cond_wait</B> re-acquires <I>mutex</I> (as per +<B>pthread_lock_mutex</B>). +</P> +<P>Unlocking the mutex and suspending on the condition variable is +done atomically. Thus, if all threads always acquire the mutex before +signalling the condition, this guarantees that the condition cannot +be signalled (and thus ignored) between the time a thread locks the +mutex and the time it waits on the condition variable. +</P> +<P><B>pthread_cond_timedwait</B> atomically unlocks <I>mutex</I> and +waits on <I>cond</I>, as <B>pthread_cond_wait</B> does, but it also +bounds the duration of the wait. If <I>cond</I> has not been +signalled within the amount of time specified by <I>abstime</I>, the +mutex <I>mutex</I> is re-acquired and <B>pthread_cond_timedwait</B> +returns the error <B>ETIMEDOUT</B>. The <I>abstime</I> parameter +specifies an absolute time, with the same origin as <A HREF="time.html"><B>time</B>(2)</A> +and <A HREF="gettimeofday.html"><B>gettimeofday</B>(2)</A>. +</P> +<P><B>pthread_cond_destroy</B> destroys a condition variable, freeing +the resources it might hold. No threads must be waiting on the +condition variable on entrance to <B>pthread_cond_destroy</B>.</P> +<H2><A HREF="#toc3" NAME="sect3">Cancellation</A></H2> +<P><B>pthread_cond_wait</B> and <B>pthread_cond_timedwait</B> are +cancellation points. If a thread is cancelled while suspended in one +of these functions, the thread immediately resumes execution, then +locks again the <I>mutex</I> argument to <B>pthread_cond_wait</B> and +<B>pthread_cond_timedwait</B>, and finally executes the cancellation. +Consequently, cleanup handlers are assured that <I>mutex</I> is +locked when they are called. +</P> +<H2><A HREF="#toc4" NAME="sect4">Async-signal Safety</A></H2> +<P>The condition functions are not async-signal safe, and should not +be called from a signal handler. In particular, calling +<B>pthread_cond_signal</B> or <B>pthread_cond_broadcast</B> from a +signal handler may deadlock the calling thread. +</P> +<H2><A HREF="#toc5" NAME="sect5">Return Value</A></H2> +<P>All condition variable functions return 0 on success and a +non-zero error code on error. +</P> +<H2><A HREF="#toc6" NAME="sect6">Errors</A></H2> +<P><B>pthread_cond_init</B>, <B>pthread_cond_signal</B>, +<B>pthread_cond_broadcast</B>, and <B>pthread_cond_wait</B> never +return an error code. +</P> +<P>The <B>pthread_cond_init</B> function returns the following error +codes on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + The <I>cond</I> argument is invalid. + </DD><DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + <B>ENOMEM</B> + </DT></DL> +</DL> +<BLOCKQUOTE STYLE="margin-left: 4cm"> +There was not enough memory to allocate the condition variable. +</BLOCKQUOTE> +<P>The <B>pthread_cond_signal</B> function returns the following +error codes on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + The <I>cond</I> argument is invalid. + </DD></DL> +</DL> +<P> +The <B>pthread_cond_broadcast</B> function returns the following +error codes on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + The <I>cond</I> argument is invalid. + </DD></DL> +</DL> +<P> +The <B>pthread_cond_wait</B> function returns the following error +codes on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + The <I>cond</I> argument is invalid. + </DD><DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + <B>ENOMEM</B> + </DT></DL> +</DL> +<BLOCKQUOTE STYLE="margin-left: 4cm"> +There was not enough memory to allocate the statically initialised +condition variable. Statically initialised condition variables are +dynamically allocated by the first thread to wait on them.</BLOCKQUOTE> +<P>The <B>pthread_cond_timedwait</B> function returns the following +error codes on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT></DL> +</DL> +<P STYLE="margin-left: 2cm"> +The <I>cond</I> argument is invalid. +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>ETIMEDOUT</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + The condition variable was not signalled before the timeout + specified by <I>abstime</I> + </DD><DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + <B>ENOMEM</B> + </DT></DL> +</DL> +<BLOCKQUOTE STYLE="margin-left: 4cm"> +There was not enough memory to allocate the statically initialised +condition variable. Statically initialised condition variables are +dynamically allocated by the first thread to wait on them. +</BLOCKQUOTE> +<P>The <B>pthread_cond_destroy</B> function returns the following +error code on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT></DL> +</DL> +<P STYLE="margin-left: 2cm; margin-right: 1cm"> +The <I>cond</I> argument is invalid. +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EBUSY</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + Some threads are currently waiting on <I>cond</I>. + </DD></DL> +</DL> +<H2> +<A HREF="#toc7" NAME="sect7">Author</A></H2> +<P>Xavier Leroy <Xavier.Leroy@inria.fr> +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<H2><A HREF="#toc8" NAME="sect8">See Also</A></H2> +<P><A HREF="pthread_condattr_init.html"><B>pthread_condattr_init</B>(3)</A> +, <A HREF="pthread_mutex_lock.html"><B>pthread_mutex_lock</B>(3)</A> +, <A HREF="pthread_mutex_unlock.html"><B>pthread_mutex_unlock</B>(3)</A> +, <A HREF="pthread_cancel.html"><B>pthread_cancel(3)</B></A>. +</P> +<H2><A HREF="#toc9" NAME="sect9">Example</A></H2> +<P>Consider two shared variables <I>x</I> and <I>y</I>, protected by +the mutex <I>mut</I>, and a condition variable <I>cond</I> that is to +be signaled whenever <I>x</I> becomes greater than <I>y</I>. +</P> +<PRE STYLE="margin-left: 1cm; margin-right: 1cm">int x,y; +pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER; +pthread_cond_t cond = PTHREAD_COND_INITIALIZER;</PRE><BLOCKQUOTE> +Waiting until <I>x</I> is greater than <I>y</I> is performed as +follows: +</BLOCKQUOTE> +<PRE STYLE="margin-left: 1.01cm">pthread_mutex_lock(&mut); +while (x <= y) { + pthread_cond_wait(&cond, &mut); +} +/* operate on x and y */ +pthread_mutex_unlock(&mut);</PRE><BLOCKQUOTE STYLE="margin-left: 3.01cm"> +Modifications on <I>x</I> and <I>y</I> that may cause <I>x</I> to +become greater than <I>y</I> should signal the condition if needed: +</BLOCKQUOTE> +<PRE STYLE="margin-left: 1.01cm">pthread_mutex_lock(&mut); +/* modify x and y */ +if (x > y) pthread_cond_broadcast(&cond); +pthread_mutex_unlock(&mut);</PRE><BLOCKQUOTE STYLE="margin-left: 3.01cm"> +If it can be proved that at most one waiting thread needs to be waken +up (for instance, if there are only two threads communicating through +<I>x</I> and <I>y</I>), <B>pthread_cond_signal</B> can be used as a +slightly more efficient alternative to <B>pthread_cond_broadcast</B>. +If in doubt, use <B>pthread_cond_broadcast</B>. +</BLOCKQUOTE> +<BLOCKQUOTE STYLE="margin-left: 3.01cm">To wait for <I>x</I> to +become greater than <I>y</I> with a timeout of 5 seconds, do: +</BLOCKQUOTE> +<PRE STYLE="margin-left: 1.01cm">struct timeval now; +struct timespec timeout; +int retcode; +pthread_mutex_lock(&mut); +gettimeofday(&now); +timeout.tv_sec = now.tv_sec + 5; +timeout.tv_nsec = now.tv_usec * 1000; +retcode = 0; +while (x <= y && retcode != ETIMEDOUT) { + retcode = pthread_cond_timedwait(&cond, &mut, &timeout); +} +if (retcode == ETIMEDOUT) { + /* timeout occurred */ +} else { + /* operate on x and y */ +} +pthread_mutex_unlock(&mut);</PRE> +<HR> +<BLOCKQUOTE STYLE="margin-left: 0cm; margin-right: 0cm"><A NAME="toc"></A> +<B>Table of Contents</B></BLOCKQUOTE> +<UL> + <LI><BLOCKQUOTE STYLE="margin-right: 0cm; margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 0cm; margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 0cm; margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 0cm; margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Cancellation</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 0cm; margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Async-signal + Safety</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 0cm; margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Return + Value</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 0cm; margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Errors</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 0cm; margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Author</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 0cm; margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">See + Also</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 0cm"><A HREF="#sect9" NAME="toc9">Example</A> + </BLOCKQUOTE> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_condattr_init.html b/manual/pthread_condattr_init.html new file mode 100644 index 0000000..8b8b2f2 --- /dev/null +++ b/manual/pthread_condattr_init.html @@ -0,0 +1,98 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_CONDATTR(3) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;16375600"> + <META NAME="CHANGED" CONTENT="20050504;16570300"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_condattr_init, pthread_condattr_destroy - condition +creation +</P> +<P>attributes +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>int pthread_condattr_init(pthread_condattr_t *</B><I>attr</I><B>);</B> +</P> +<P><B>int pthread_condattr_destroy(pthread_condattr_t *</B><I>attr</I><B>);</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>Condition attributes can be specified at condition creation time, +by passing a condition attribute object as second argument to +<A HREF="pthread_cond_init.html"><B>pthread_cond_init</B>(3)</A> . +Passing <B>NULL</B> is equivalent to passing a condition attribute +object with all attributes set to their default values. +</P> +<P><B>pthread_condattr_init</B> initializes the condition attribute +object <I>attr</I> and fills it with default values for the +attributes. <B>pthread_condattr_destroy</B> destroys a condition +attribute object, which must not be reused until it is reinitialized.</P> +<P><B>Pthreads-w32</B> defines _<B>POSIX_THREAD_PROCESS_SHARED</B> in +pthread.h as -1 to indicate that the attribute routines are +implemented but that the process shared attribute is not supported.</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>All condition variable functions return 0 on success and a +non-zero error code on error.</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>The <B>pthread_condattr_init</B> function returns the following +error code on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>ENOMEM</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + The was insufficient memory to create the attribute.<SPAN STYLE="font-weight: medium"> + </SPAN> + </DD></DL> +</DL> +<P> +The <B>pthread_condattr_destroy</B> function returns the following +error code on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + The <I>attr</I> argument is not valid.<SPAN STYLE="font-weight: medium"> + </SPAN> + </DD></DL> +</DL> +<H2> +<A HREF="#toc5" NAME="sect5">Author</A></H2> +<P>Xavier Leroy <Xavier.Leroy@inria.fr> +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<H2><A HREF="#toc6" NAME="sect6">See Also</A></H2> +<P><A HREF="pthread_cond_init.html"><B>pthread_cond_init</B>(3)</A> . +</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Author</A> + </P> + <LI><P><A HREF="#sect6" NAME="toc6">See Also</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_condattr_setpshared.html b/manual/pthread_condattr_setpshared.html new file mode 100644 index 0000000..eda357e --- /dev/null +++ b/manual/pthread_condattr_setpshared.html @@ -0,0 +1,153 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"PTHREAD_CONDATTR_GETPSHARED"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;17542300"> + <META NAME="CHANGED" CONTENT="20050505;18293100"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_condattr_getpshared, pthread_condattr_setpshared - get and +set the process-shared condition variable attributes +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h> </B> +</P> +<P><B>int pthread_condattr_getpshared(const pthread_condattr_t +*restrict</B> <I>attr</I><B>, int *restrict</B> <I>pshared</I><B>); +<BR>int pthread_condattr_setpshared(pthread_condattr_t *</B><I>attr</I><B>, +int</B> <I>pshared</I><B>); </B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>pthread_condattr_getpshared</B> function shall obtain the +value of the <I>process-shared</I> attribute from the attributes +object referenced by <I>attr</I>. The <B>pthread_condattr_setpshared</B> +function shall set the <I>process-shared</I> attribute in an +initialized attributes object referenced by <I>attr</I>. +</P> +<P>The <I>process-shared</I> attribute is set to +<B>PTHREAD_PROCESS_SHARED</B> to permit a condition variable to be +operated upon by any thread that has access to the memory where the +condition variable is allocated, even if the condition variable is +allocated in memory that is shared by multiple processes. If the +<I>process-shared</I> attribute is <B>PTHREAD_PROCESS_PRIVATE</B>, +the condition variable shall only be operated upon by threads created +within the same process as the thread that initialized the condition +variable; if threads of differing processes attempt to operate on +such a condition variable, the behavior is undefined. The default +value of the attribute is <B>PTHREAD_PROCESS_PRIVATE</B>. +</P> +<P><B>Pthreads-w32</B> defines _<B>POSIX_THREAD_PROCESS_SHARED</B> in +pthread.h as -1 to indicate that these routines are implemented but +that the process shared attribute is not supported.</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>If successful, the <B>pthread_condattr_setpshared</B> function +shall return zero; otherwise, an error number shall be returned to +indicate the error. +</P> +<P>If successful, the <B>pthread_condattr_getpshared</B> function +shall return zero and store the value of the <I>process-shared</I> +attribute of <I>attr</I> into the object referenced by the <I>pshared</I> +parameter. Otherwise, an error number shall be returned to indicate +the error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>The <B>pthread_condattr_getpshared</B> and +<B>pthread_condattr_setpshared</B> functions may fail if: +</P> +<DL> + <DT><B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The value specified by <I>attr</I> is invalid. + </DD></DL> +<P> +The <B>pthread_condattr_setpshared</B> function may fail if: +</P> +<DL> + <DT><B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The new value specified for the attribute is outside the range of + legal values for that attribute. + </DD><DT> + <B>ENOSYS</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The value specified by <I>attr</I> was <B>PTHREAD_PROCESS_SHARED</B> + (Pthreads-w32).</DD></DL> +<P> +These functions shall not return an error code of [EINTR]. +</P> +<P><I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P><B>Pthreads-w32</B> defines <B>_POSIX_THREAD_PROCESS_SHARED</B> in +pthread.h as -1 to indicate that these routines are implemented and +may be used, but do not support the process shared option.</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P><A HREF="pthread_create.html"><B>pthread_create</B>(3)</A> <B>,</B> +<A HREF="pthread_cond_init.html"><B>pthread_cond_destroy</B>(3)</A> <B>,</B> +<A HREF="pthread_condattr_init.html"><B>pthread_condattr_destroy</B>(3)</A> +<B>,</B> <A HREF="pthread_mutex_init.html"><B>pthread_mutex_destroy</B>(3)</A> +<B>,</B> the Base Definitions volume of IEEE Std 1003.1-2001, +<I><pthread.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_create.html b/manual/pthread_create.html new file mode 100644 index 0000000..d1ebbc3 --- /dev/null +++ b/manual/pthread_create.html @@ -0,0 +1,94 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_CREATE(3) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;19394700"> + <META NAME="CHANGED" CONTENT="20050504;20140200"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_create - create a new thread +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>int pthread_create(pthread_t * </B><I>thread</I><B>, +pthread_attr_t * </B><I>attr</I><B>, void * (*</B><I>start_routine</I><B>)(void +*), void * </B><I>arg</I><B>);</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P><B>pthread_create</B> creates a new thread of control that +executes concurrently with the calling thread. The new thread applies +the function <I>start_routine</I> passing it <I>arg</I> as first +argument. The new thread terminates either explicitly, by calling +<A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> , or +implicitly, by returning from the <I>start_routine</I> function. The +latter case is equivalent to calling <A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> +with the result returned by <I>start_routine</I> as exit code. +</P> +<P>The initial signal state of the new thread is inherited from it's +creating thread and there are no pending signals. <B>Pthreads-w32</B> +does not yet implement signals.</P> +<P>The <I>attr</I> argument specifies thread attributes to be applied +to the new thread. See <A HREF="pthread_attr_init.html"><B>pthread_attr_init</B>(3)</A> +for a complete list of thread attributes. The <I>attr</I> argument +can also be <B>NULL</B>, in which case default attributes are used: +the created thread is joinable (not detached) and has default (non +real-time) scheduling policy. +</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>On success, the identifier of the newly created thread is stored +in the location pointed by the <I>thread</I> argument, and a 0 is +returned. On error, a non-zero error code is returned. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<DL> + <DT><B>EAGAIN</B> + </DT><DL> + <DL> + <DT> + Not enough system resources to create a process for the new + thread, or<BR>more than <B>PTHREAD_THREADS_MAX</B> threads are + already active. + </DT></DL> + </DL> +</DL> +<H2> +<A HREF="#toc5" NAME="sect5">Author</A></H2> +<P>Xavier Leroy <Xavier.Leroy@inria.fr> +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<H2><A HREF="#toc6" NAME="sect6">See Also</A></H2> +<P><A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> , +<A HREF="pthread_join.html"><B>pthread_join</B>(3)</A> , +<A HREF="pthread_detach.html"><B>pthread_detach</B>(3)</A> , +<A HREF="pthread_attr_init.html"><B>pthread_attr_init</B>(3)</A> . +</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Author</A> + </P> + <LI><P><A HREF="#sect6" NAME="toc6">See Also</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_delay_np.html b/manual/pthread_delay_np.html new file mode 100644 index 0000000..ce533e2 --- /dev/null +++ b/manual/pthread_delay_np.html @@ -0,0 +1,71 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_DELAY_NP manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;322600"> + <META NAME="CHANGED" CONTENT="20050505;21371500"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P STYLE="font-weight: medium">pthread_delay_np – suspend the +thread for a specified period</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>int pthread_delay_np (const struct timespec *</B>interval<B>);</B></P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P><B>pthread_delay_np</B> causes a thread to delay execution for a +specific period of time. This period ends at the current time plus +the specified interval. The routine will not return before the end of +the period is reached, but may return an arbitrary amount of time +after the period has gone by. This can be due to system load, thread +priorities, and system timer granularity.</P> +<P>Specifying an interval of zero (0) seconds and zero (0) +nanoseconds is allowed and can be used to force the thread to give up +the processor or to deliver a pending cancellation request.</P> +<H2><A HREF="#toc3" NAME="sect3">Cancellation</A></H2> +<P><B>pthread_delay_np </B>is a cancellation point.</P> +<H2><A HREF="#toc4" NAME="sect4">Return Value</A></H2> +<P>If an error condition occurs, <B>pthread_delay_np</B> returns an +integer value indicating the type of error.</P> +<H2><A HREF="#toc5" NAME="sect5">Errors</A></H2> +<P>The <B>pthread_delay_np</B> function returns the following error +code on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT></DL> +</DL> +<P STYLE="margin-left: 2cm"> +The value specified by interval is invalid.</P> +<H2><A HREF="#toc6" NAME="sect6">Author</A></H2> +<P>Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Cancellation</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Errors</A> + </P> + <LI><P><A HREF="#sect6" NAME="toc6">Author</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_detach.html b/manual/pthread_detach.html new file mode 100644 index 0000000..265a467 --- /dev/null +++ b/manual/pthread_detach.html @@ -0,0 +1,86 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_DETACH(3) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;18010700"> + <META NAME="CHANGED" CONTENT="20050504;18032100"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_detach - put a running thread in the detached state +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>int pthread_detach(pthread_t </B><I>th</I><B>);</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P><B>pthread_detach</B> puts the thread <I>th</I> in the detached +state. This guarantees that the memory resources consumed by <I>th</I> +will be freed immediately when <I>th</I> terminates. However, this +prevents other threads from synchronizing on the termination of <I>th</I> +using <B>pthread_join</B>. +</P> +<P>A thread can be created initially in the detached state, using the +<B>detachstate</B> attribute to <A HREF="pthread_create.html"><B>pthread_create</B>(3)</A> +. In contrast, <B>pthread_detach</B> applies to threads created in +the joinable state, and which need to be put in the detached state +later. +</P> +<P>After <B>pthread_detach</B> completes, subsequent attempts to +perform <B>pthread_join</B> on <I>th</I> will fail. If another thread +is already joining the thread <I>th</I> at the time <B>pthread_detach</B> +is called, <B>pthread_detach</B> does nothing and leaves <I>th</I> in +the joinable state. +</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>On success, 0 is returned. On error, a non-zero error code is +returned. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<DL> + <DT><B>ESRCH</B> + </DT><DD> + No thread could be found corresponding to that specified by <I>th</I> + </DD><DT> + <B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + the thread <I>th</I> is already in the detached state + </DD></DL> +<H2> +<A HREF="#toc5" NAME="sect5">Author</A></H2> +<P>Xavier Leroy <Xavier.Leroy@inria.fr> +</P> +<H2><A HREF="#toc6" NAME="sect6">See Also</A></H2> +<P><A HREF="pthread_create.html"><B>pthread_create</B>(3)</A> , +<A HREF="pthread_join.html"><B>pthread_join</B>(3)</A> , +<A HREF="pthread_attr_setdetachstate.html"><B>pthread_attr_setdetachstate</B>(3)</A> +</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Author</A> + </P> + <LI><P><A HREF="#sect6" NAME="toc6">See Also</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_equal.html b/manual/pthread_equal.html new file mode 100644 index 0000000..6f61063 --- /dev/null +++ b/manual/pthread_equal.html @@ -0,0 +1,48 @@ +<!-- manual page source format generated by PolyglotMan v3.2, --> +<!-- available at http://polyglotman.sourceforge.net/ --> + +<html> +<head> +<title>PTHREAD_EQUAL(3) manual page</title> +</head> +<body bgcolor='white'> +<a href='#toc'>Table of Contents</a><p> + +<p> +<h2><a name='sect0' href='#toc0'>Name</a></h2> +pthread_equal - compare two thread identifiers +<p> +<h2><a name='sect1' href='#toc1'>Synopsis</a></h2> +<b>#include <pthread.h></b> + +<p> <b>int pthread_equal(pthread_t </b><i>thread1</i><b>, pthread_t </b><i>thread2</i><b>);</b> +<p> +<h2><a name='sect2' href='#toc2'>Description</a></h2> +<b>pthread_equal</b> +determines if two thread identifiers refer to the same thread. +<p> +<h2><a name='sect3' href='#toc3'>Return Value</a></h2> +A +non-zero value is returned if <i>thread1</i> and <i>thread2</i> refer to the same thread. +Otherwise, 0 is returned. +<p> +<h2><a name='sect4' href='#toc4'>Author</a></h2> +Xavier Leroy <Xavier.Leroy@inria.fr> +<p> +<h2><a name='sect5' href='#toc5'>See Also</a></h2> +<a href='file:pthread_self.html'><b>pthread_self</b>(3)</a> +. +<p> + +<hr><p> +<a name='toc'><b>Table of Contents</b></a><p> +<ul> +<li><a name='toc0' href='#sect0'>Name</a></li> +<li><a name='toc1' href='#sect1'>Synopsis</a></li> +<li><a name='toc2' href='#sect2'>Description</a></li> +<li><a name='toc3' href='#sect3'>Return Value</a></li> +<li><a name='toc4' href='#sect4'>Author</a></li> +<li><a name='toc5' href='#sect5'>See Also</a></li> +</ul> +</body> +</html> diff --git a/manual/pthread_exit.html b/manual/pthread_exit.html new file mode 100644 index 0000000..e97318f --- /dev/null +++ b/manual/pthread_exit.html @@ -0,0 +1,59 @@ +<!-- manual page source format generated by PolyglotMan v3.2, --> +<!-- available at http://polyglotman.sourceforge.net/ --> + +<html> +<head> +<title>PTHREAD_EXIT(3) manual page</title> +</head> +<body bgcolor='white'> +<a href='#toc'>Table of Contents</a><p> + +<p> +<h2><a name='sect0' href='#toc0'>Name</a></h2> +pthread_exit - terminate the calling thread +<p> +<h2><a name='sect1' href='#toc1'>Synopsis</a></h2> +<b>#include <pthread.h></b> + +<p> <b>void pthread_exit(void *</b><i>retval</i><b>);</b> +<p> +<h2><a name='sect2' href='#toc2'>Description</a></h2> +<b>pthread_exit</b> terminates the +execution of the calling thread. All cleanup handlers that have been set +for the calling thread with <a href='file:pthread_cleanup_push.html'><b>pthread_cleanup_push</b>(3)</a> + are executed in reverse +order (the most recently pushed handler is executed first). Finalization +functions for thread-specific data are then called for all keys that have +non- <b>NULL</b> values associated with them in the calling thread (see <a href='file:pthread_key_create.html'><b>pthread_key_create</b>(3)</a> +). +Finally, execution of the calling thread is stopped. +<p> The <i>retval</i> argument +is the return value of the thread. It can be consulted from another thread +using <a href='file:pthread_join.html'><b>pthread_join</b>(3)</a> +. +<p> +<h2><a name='sect3' href='#toc3'>Return Value</a></h2> +The <b>pthread_exit</b> function never returns. + +<p> +<h2><a name='sect4' href='#toc4'>Author</a></h2> +Xavier Leroy <Xavier.Leroy@inria.fr> +<p> +<h2><a name='sect5' href='#toc5'>See Also</a></h2> +<a href='file:pthread_create.html'><b>pthread_create</b>(3)</a> +, <a href='file:pthread_join.html'><b>pthread_join</b>(3)</a> +. +<p> + +<hr><p> +<a name='toc'><b>Table of Contents</b></a><p> +<ul> +<li><a name='toc0' href='#sect0'>Name</a></li> +<li><a name='toc1' href='#sect1'>Synopsis</a></li> +<li><a name='toc2' href='#sect2'>Description</a></li> +<li><a name='toc3' href='#sect3'>Return Value</a></li> +<li><a name='toc4' href='#sect4'>Author</a></li> +<li><a name='toc5' href='#sect5'>See Also</a></li> +</ul> +</body> +</html> diff --git a/manual/pthread_getw32threadhandle_np.html b/manual/pthread_getw32threadhandle_np.html new file mode 100644 index 0000000..7e8de64 --- /dev/null +++ b/manual/pthread_getw32threadhandle_np.html @@ -0,0 +1,57 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_GETW32THREADHANDLE_NP manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;322600"> + <META NAME="CHANGED" CONTENT="20050505;21523500"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P STYLE="font-weight: medium">pthread_getw32threadhandle_np – get +the Win32 thread handle associated with a thread</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>HANDLE pthread_getw32threadhandle_np(pthread_t</B> <I>thread</I><B>);</B></P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>Returns the Win32 native thread <B>HANDLE</B> that the POSIX +thread <I>thread</I> is running as.</P> +<P>Applications can use the Win32 handle to set Win32 specific +attributes of the thread.</P> +<H2><A HREF="#toc3" NAME="sect3">Cancellation</A></H2> +<P>None.</P> +<H2><A HREF="#toc4" NAME="sect4">Return Value</A></H2> +<P><B>pthread_getw32threadhandle_np</B> returns the Win32 native +thread <B>HANDLE</B> for the specified POSIX thread <I>thread</I>.</P> +<H2><A HREF="#toc5" NAME="sect5">Errors</A></H2> +<P>None.</P> +<H2><A HREF="#toc6" NAME="sect6">Author</A></H2> +<P>Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Cancellation</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Errors</A> + </P> + <LI><P><A HREF="#sect6" NAME="toc6">Author</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_join.html b/manual/pthread_join.html new file mode 100644 index 0000000..3e3f3b9 --- /dev/null +++ b/manual/pthread_join.html @@ -0,0 +1,118 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_JOIN(3) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;18232700"> + <META NAME="CHANGED" CONTENT="20050504;18421400"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_join - wait for termination of another thread +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>int pthread_join(pthread_t </B><I>th</I><B>, void +**</B><I>thread_return</I><B>);</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P><B>pthread_join</B> suspends the execution of the calling thread +until the thread identified by <I>th</I> terminates, either by +calling <A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> or by +being cancelled. +</P> +<P>If <I>thread_return</I> is not <B>NULL</B>, the return value of <I>th</I> +is stored in the location pointed to by <I>thread_return</I>. The +return value of <I>th</I> is either the argument it gave to +<A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> , or +<B>PTHREAD_CANCELED</B> if <I>th</I> was cancelled. +</P> +<P>The joined thread <B>th</B> must be in the joinable state: it must +not have been detached using <A HREF="pthread_detach.html"><B>pthread_detach</B>(3)</A> +or the <B>PTHREAD_CREATE_DETACHED</B> attribute to <A HREF="pthread_create.html"><B>pthread_create</B>(3)</A> +. +</P> +<P>When a joinable thread terminates, its memory resources (thread +descriptor and stack) are not deallocated until another thread +performs <B>pthread_join</B> on it. Therefore, <B>pthread_join</B> +must be called once for each joinable thread created to avoid memory +leaks. +</P> +<P>At most one thread can wait for the termination of a given thread. +Calling <B>pthread_join</B> on a thread <I>th</I> on which another +thread is already waiting for termination returns an error. +</P> +<H2><A HREF="#toc3" NAME="sect3">Cancellation</A></H2> +<P><B>pthread_join</B> is a cancellation point. If a thread is +cancelled while suspended in <B>pthread_join</B>, the thread +execution resumes immediately and the cancellation is executed +without waiting for the <I>th</I> thread to terminate. If +cancellation occurs during <B>pthread_join</B>, the <I>th</I> thread +remains not joined. +</P> +<H2><A HREF="#toc4" NAME="sect4">Return Value</A></H2> +<P>On success, the return value of <I>th</I> is stored in the +location pointed to by <I>thread_return</I>, and 0 is returned. On +error, a non-zero error code is returned. +</P> +<H2><A HREF="#toc5" NAME="sect5">Errors</A></H2> +<DL> + <DT><B>ESRCH</B> + </DT><DD> + No thread could be found corresponding to that specified by <I>th</I>. + </DD><DT> + <B>EINVAL</B> + </DT><DD> + The <I>th</I> thread has been detached. + </DD><DT> + <B>EINVAL</B> + </DT><DD> + Another thread is already waiting on termination of <I>th</I>. + </DD><DT> + <B>EDEADLK</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The <I>th</I> argument refers to the calling thread. + </DD></DL> +<H2> +<A HREF="#toc6" NAME="sect6">Author</A></H2> +<P>Xavier Leroy <Xavier.Leroy@inria.fr> +</P> +<H2><A HREF="#toc7" NAME="sect7">See Also</A></H2> +<P><A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> , +<A HREF="pthread_detach.html"><B>pthread_detach</B>(3)</A> , +<A HREF="pthread_create.html"><B>pthread_create</B>(3)</A> , +<A HREF="pthread_attr_setdetachstate.html"><B>pthread_attr_setdetachstate</B>(3)</A> +, <A HREF="pthread_cleanup_push.html"><B>pthread_cleanup_push</B>(3)</A> +, <A HREF="pthread_key_create.html"><B>pthread_key_create</B>(3)</A> +. +</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Cancellation</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Author</A> + </P> + <LI><P><A HREF="#sect7" NAME="toc7">See Also</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_key_create.html b/manual/pthread_key_create.html new file mode 100644 index 0000000..2d2a183 --- /dev/null +++ b/manual/pthread_key_create.html @@ -0,0 +1,197 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_SPECIFIC(3) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;18425400"> + <META NAME="CHANGED" CONTENT="20050505;18330000"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_key_create, pthread_key_delete, pthread_setspecific, +pthread_getspecific - management of thread-specific data +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>int pthread_key_create(pthread_key_t *</B><I>key</I><B>, void +(*</B><I>destr_function</I><B>) (void *));</B> +</P> +<P><B>int pthread_key_delete(pthread_key_t </B><I>key</I><B>);</B> +</P> +<P><B>int pthread_setspecific(pthread_key_t </B><I>key</I><B>, const +void *</B><I>pointer</I><B>);</B> +</P> +<P><B>void * pthread_getspecific(pthread_key_t </B><I>key</I><B>);</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>Programs often need global or static variables that have different +values in different threads. Since threads share one memory space, +this cannot be achieved with regular variables. Thread-specific data +is the POSIX threads answer to this need. +</P> +<P>Each thread possesses a private memory block, the thread-specific +data area, or TSD area for short. This area is indexed by TSD keys. +The TSD area associates values of type <B>void *</B> to TSD keys. TSD +keys are common to all threads, but the value associated with a given +TSD key can be different in each thread. +</P> +<P>For concreteness, the TSD areas can be viewed as arrays of <B>void +*</B> pointers, TSD keys as integer indices into these arrays, and +the value of a TSD key as the value of the corresponding array +element in the calling thread. +</P> +<P>When a thread is created, its TSD area initially associates <B>NULL</B> +with all keys. +</P> +<P><B>pthread_key_create</B> allocates a new TSD key. The key is +stored in the location pointed to by <I>key</I>. There is a limit of +<B>PTHREAD_KEYS_MAX</B> on the number of keys allocated at a given +time. The value initially associated with the returned key is <B>NULL</B> +in all currently executing threads. +</P> +<P>The <I>destr_function</I> argument, if not <B>NULL</B>, specifies +a destructor function associated with the key. When a thread +terminates via <B>pthread_exit</B> or by cancellation, <I>destr_function</I> +is called with arguments the value associated with the key in that +thread. The <I>destr_function</I> is not called if that value is +<B>NULL</B>. The order in which destructor functions are called at +thread termination time is unspecified. +</P> +<P>Before the destructor function is called, the <B>NULL</B> value is +associated with the key in the current thread. A destructor function +might, however, re-associate non- <B>NULL</B> values to that key or +some other key. To deal with this, if after all the destructors have +been called for all non- <B>NULL</B> values, there are still some +non- <B>NULL</B> values with associated destructors, then the process +is repeated. The LinuxThreads implementation stops the process after +<B>PTHREAD_DESTRUCTOR_ITERATIONS</B> iterations, even if some non- +<B>NULL</B> values with associated descriptors remain. Other +implementations may loop indefinitely. +</P> +<P><B>pthread_key_delete</B> deallocates a TSD key. It does not check +whether non- <B>NULL</B> values are associated with that key in the +currently executing threads, nor call the destructor function +associated with the key. +</P> +<P><B>pthread_setspecific</B> changes the value associated with <I>key</I> +in the calling thread, storing the given <I>pointer</I> instead. +</P> +<P><B>pthread_getspecific</B> returns the value currently associated +with <I>key</I> in the calling thread. +</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P><B>pthread_key_create</B>, <B>pthread_key_delete</B>, and +<B>pthread_setspecific</B> return 0 on success and a non-zero error +code on failure. If successful, <B>pthread_key_create</B> stores the +newly allocated key in the location pointed to by its <I>key</I> +argument. +</P> +<P><B>pthread_getspecific</B> returns the value associated with <I>key</I> +on success, and <B>NULL</B> on error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P><B>pthread_key_create</B> returns the following error code on +error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EAGAIN</B> + </DT></DL> +</DL> +<BLOCKQUOTE STYLE="margin-left: 3cm"> +<B>PTHREAD_KEYS_MAX</B> keys are already allocated +</BLOCKQUOTE> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>ENOMEM</B> + </DT></DL> +</DL> +<BLOCKQUOTE STYLE="margin-left: 3cm"> +Insufficient memory to allocate the key. +</BLOCKQUOTE> +<P><B>pthread_key_delete</B> and <B>pthread_setspecific</B> return +the following error code on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + <I>key</I> is not a valid, allocated TSD key + </DD></DL> +</DL> +<P> +<B>pthread_getspecific</B> returns <B>NULL</B> if <I>key</I> is not a +valid, allocated TSD key. +</P> +<H2><A HREF="#toc5" NAME="sect5">Author</A></H2> +<P>Xavier Leroy <Xavier.Leroy@inria.fr> +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<H2><A HREF="#toc6" NAME="sect6">See Also</A></H2> +<P><A HREF="pthread_create.html">pthread_create(3)</A> , +<A HREF="pthread_exit.html">pthread_exit(3)</A> , +<A HREF="pthread_cancel.html">pthread_testcancel(3)</A> . +</P> +<H2><A HREF="#toc7" NAME="sect7">Example</A></H2> +<P>The following code fragment allocates a thread-specific array of +100 characters, with automatic reclamation at thread exit: +</P> +<BLOCKQUOTE><BR><BR> +</BLOCKQUOTE> +<PRE STYLE="margin-left: 1cm; margin-right: 1cm">/* Key for the thread-specific buffer */ +static pthread_key_t buffer_key; +/* Once-only initialisation of the key */ +static pthread_once_t buffer_key_once = PTHREAD_ONCE_INIT; +/* Allocate the thread-specific buffer */ +void buffer_alloc(void) +{ + pthread_once(&buffer_key_once, buffer_key_alloc); + pthread_setspecific(buffer_key, malloc(100)); +} +/* Return the thread-specific buffer */ +char * get_buffer(void) +{ + return (char *) pthread_getspecific(buffer_key); +} +/* Allocate the key */ +static void buffer_key_alloc() +{ + pthread_key_create(&buffer_key, buffer_destroy); +} +/* Free the thread-specific buffer */ +static void buffer_destroy(void * buf) +{ + free(buf); +}</PRE> +<HR> +<BLOCKQUOTE STYLE="margin-left: 0cm"><A NAME="toc"></A><B>Table of +Contents</B></BLOCKQUOTE> +<UL> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Author</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">See + Also</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE><A HREF="#sect7" NAME="toc7">Example</A> + </BLOCKQUOTE> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_kill.html b/manual/pthread_kill.html new file mode 100644 index 0000000..33d61b2 --- /dev/null +++ b/manual/pthread_kill.html @@ -0,0 +1,152 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_SIGNAL(3) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;18500100"> + <META NAME="CHANGED" CONTENT="20050504;23005800"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_sigmask, pthread_kill, sigwait - handling of signals in +threads +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> <BR><B>#include <signal.h></B> +</P> +<P><B>int pthread_sigmask(int </B><I>how</I><B>, const sigset_t +*</B><I>newmask</I><B>, sigset_t *</B><I>oldmask</I><B>);</B> +</P> +<P><B>int pthread_kill(pthread_t </B><I>thread</I><B>, int </B><I>signo</I><B>);</B> +</P> +<P><B>int sigwait(const sigset_t *</B>set, <B>int</B> *sig);</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P><B>pthread_sigmask</B> changes the signal mask for the calling +thread as described by the <I>how</I> and <I>newmask</I> arguments. +If <I>oldmask</I> is not <B>NULL</B>, the previous signal mask is +stored in the location pointed to by <I>oldmask</I>. <B>Pthreads-w32</B> +implements this function but no other function uses the signal mask +yet.</P> +<P>The meaning of the <I>how</I> and <I>newmask</I> arguments is the +same as for <B><SPAN STYLE="font-style: normal">sigprocmask</SPAN></B>(2). +If <I>how</I> is <B>SIG_SETMASK</B>, the signal mask is set to +<I>newmask</I>. If <I>how</I> is <B>SIG_BLOCK</B>, the signals +specified to <I>newmask</I> are added to the current signal mask. If +<I>how</I> is <B>SIG_UNBLOCK</B>, the signals specified to <I>newmask</I> +are removed from the current signal mask. +</P> +<P>Recall that signal masks are set on a per-thread basis, but signal +actions and signal handlers, as set with <B>sigaction</B>(2), are +shared between all threads. +</P> +<P><B>pthread_kill</B> send signal number <I>signo</I> to the thread +<I>thread</I>. <B>Pthreads-w32</B> only supports signal number 0, +which does not send any signal but causes <B>pthread_kill</B> to +return an error if <I>thread</I> is not valid.</P> +<P><B>sigwait</B> suspends the calling thread until one of the +signals in <I>set</I> is delivered to the calling thread. It then +stores the number of the signal received in the location pointed to +by <I>sig</I> and returns. The signals in <I>set</I> must be blocked +and not ignored on entrance to <B>sigwait</B>. If the delivered +signal has a signal handler function attached, that function is <I>not</I> +called. <B>Pthreads-w32</B> implements this function as a +cancellation point only - it does not wait for any signals and does +not change the location pointed to by <I>sig</I>.</P> +<H2><A HREF="#toc3" NAME="sect3">Cancellation</A></H2> +<P><B>sigwait</B> is a cancellation point. +</P> +<H2><A HREF="#toc4" NAME="sect4">Return Value</A></H2> +<P>On success, 0 is returned. On failure, a non-zero error code is +returned. +</P> +<H2><A HREF="#toc5" NAME="sect5">Errors</A></H2> +<P>The <B>pthread_sigmask</B> function returns the following error +codes on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + <I>how</I> is not one of <B>SIG_SETMASK</B>, <B>SIG_BLOCK</B>, or + <B>SIG_UNBLOCK</B> + </DD></DL> +</DL> +<P> +The <B>pthread_kill</B> function returns the following error codes on +error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + <I>signo</I> is not a valid signal number or is unsupported.</DD><DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + <B>ESRCH</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the thread <I>thread</I> does not exist (e.g. it has already + terminated) + </DD></DL> +</DL> +<P> +The <B>sigwait</B> function never returns an error. +</P> +<H2><A HREF="#toc6" NAME="sect6">Author</A></H2> +<P>Xavier Leroy <Xavier.Leroy@inria.fr> +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<H2><A HREF="#toc7" NAME="sect7">See Also</A></H2> +<P> +</P> +<H2><A HREF="#toc8" NAME="sect8">Notes</A></H2> +<P>In any implementation, for <B>sigwait</B> to work reliably, the +signals being waited for must be blocked in all threads, not only in +the calling thread, since otherwise the POSIX semantics for signal +delivery do not guarantee that it’s the thread doing the <B>sigwait</B> +that will receive the signal. The best way to achieve this is to +block those signals before any threads are created, and never unblock +them in the program other than by calling <B>sigwait</B>. This works +because all threads inherit their initial sigmask from their creating +thread.</P> +<H2><A HREF="#toc9" NAME="sect9">Bugs</A></H2> +<P><B>Pthreads-w32</B> does not implement signals yet and so these +routines have almost no use except to prevent the compiler or linker +from complaining. <B>pthread_kill</B> is useful in determining if the +thread is a valid thread, but since many threads implementations +reuse thread IDs, the valid thread may no longer be the thread you +think it is, and so this method of determining thread validity is not +portable, and very risky. <B>Pthreads-w32</B> from version 1.0.0 +onwards implements pseudo-unique thread IDs, so applications that use +this technique (but really shouldn't) have some protection.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Cancellation</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Author</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">See + Also</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Notes</A> + </P> + <LI><P><A HREF="#sect9" NAME="toc9">Bugs</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_mutex_init.html b/manual/pthread_mutex_init.html new file mode 100644 index 0000000..f9982cf --- /dev/null +++ b/manual/pthread_mutex_init.html @@ -0,0 +1,277 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_MUTEX(3) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;5000"> + <META NAME="CHANGED" CONTENT="20050505;19000600"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_mutex_init, pthread_mutex_lock, pthread_mutex_trylock, +pthread_mutex_timedlock, pthread_mutex_unlock, pthread_mutex_destroy +- operations on mutexes +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>#include <time.h></B></P> +<P><B>pthread_mutex_t </B><I>fastmutex</I> <B>= +PTHREAD_MUTEX_INITIALIZER;</B> +</P> +<P><B>pthread_mutex_t </B><I>recmutex</I> <B>= +PTHREAD_RECURSIVE_MUTEX_INITIALIZER;</B> +</P> +<P><B>pthread_mutex_t </B><I>errchkmutex</I> <B>= +PTHREAD_ERRORCHECK_MUTEX_INITIALIZER;</B> +</P> +<P><B>pthread_mutex_t </B><I>recmutex</I> <B>= +PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;</B> +</P> +<P><B>pthread_mutex_t </B><I>errchkmutex</I> <B>= +PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;</B> +</P> +<P><B>int pthread_mutex_init(pthread_mutex_t *</B><I>mutex</I><B>, +const pthread_mutexattr_t *</B><I>mutexattr</I><B>);</B> +</P> +<P><B>int pthread_mutex_lock(pthread_mutex_t *</B><I>mutex</I><B>);</B> +</P> +<P><B>int pthread_mutex_trylock(pthread_mutex_t *</B><I>mutex</I><B>);</B> +</P> +<P><B>int pthread_mutex_timedlock(pthread_mutex_t *</B><I>mutex, +</I><B>const struct timespec *</B><I>abs_timeout</I><B>);</B> +</P> +<P><B>int pthread_mutex_unlock(pthread_mutex_t *</B><I>mutex</I><B>);</B> +</P> +<P><B>int pthread_mutex_destroy(pthread_mutex_t *</B><I>mutex</I><B>);</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>A mutex is a MUTual EXclusion device, and is useful for protecting +shared data structures from concurrent modifications, and +implementing critical sections and monitors. +</P> +<P>A mutex has two possible states: unlocked (not owned by any +thread), and locked (owned by one thread). A mutex can never be owned +by two different threads simultaneously. A thread attempting to lock +a mutex that is already locked by another thread is suspended until +the owning thread unlocks the mutex first. +</P> +<P><B>pthread_mutex_init</B> initializes the mutex object pointed to +by <I>mutex</I> according to the mutex attributes specified in +<I>mutexattr</I>. If <I>mutexattr</I> is <B>NULL</B>, default +attributes are used instead. +</P> +<P>The type of a mutex determines whether it can be locked again by a +thread that already owns it. The default type is “normal”. See +<A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_init</B>(3)</A> +for more information on mutex attributes. +</P> +<P>Variables of type <B>pthread_mutex_t</B> can also be initialized +statically, using the constants <B>PTHREAD_MUTEX_INITIALIZER</B> (for +normal “fast” mutexes), <B>PTHREAD_RECURSIVE_MUTEX_INITIALIZER</B> +(for recursive mutexes), and <B>PTHREAD_ERRORCHECK_MUTEX_INITIALIZER</B> +(for error checking mutexes). <SPAN STYLE="font-weight: medium"> In +the <B>Pthreads-w32</B> implementation, an application should still +call <B>pthread_mutex_destroy</B> at some point to ensure that any +resources consumed by the mutex are released.</SPAN></P> +<P><B>pthread_mutex_lock</B> locks the given mutex. If the mutex is +currently unlocked, it becomes locked and owned by the calling +thread, and <B>pthread_mutex_lock</B> returns immediately. If the +mutex is already locked by another thread, <B>pthread_mutex_lock</B> +suspends the calling thread until the mutex is unlocked. +</P> +<P>If the mutex is already locked by the calling thread, the behavior +of <B>pthread_mutex_lock</B> depends on the type of the mutex. If the +mutex is of the “normal” type, the calling thread is suspended +until the mutex is unlocked, thus effectively causing the calling +thread to deadlock. If the mutex is of the ‘‘error checking’’ +type, <B>pthread_mutex_lock</B> returns immediately with the error +code <B>EDEADLK</B>. If the mutex is of the ‘‘recursive’’ +type, <B>pthread_mutex_lock</B> succeeds and returns immediately, +recording the number of times the calling thread has locked the +mutex. An equal number of <B>pthread_mutex_unlock</B> operations must +be performed before the mutex returns to the unlocked state. +</P> +<P><B>pthread_mutex_trylock</B> behaves identically to +<B>pthread_mutex_lock</B>, except that it does not block the calling +thread if the mutex is already locked by another thread (or by the +calling thread in the case of a “normal” mutex). Instead, +<B>pthread_mutex_trylock</B> returns immediately with the error code +<B>EBUSY</B>. +</P> +<P><B>pthread_mutex_timedlock</B> behaves identically to +<B>pthread_mutex_lock</B>, except that if it cannot acquire the lock +before the <I>abs_timeout</I> time, the call returns with the error +code <B>ETIMEDOUT</B>. If the mutex can be locked immediately it is, +and the <B>abs_timeout</B> parameter is ignored.</P> +<P><B>pthread_mutex_unlock</B> unlocks the given mutex. The mutex is +assumed to be locked and owned by the calling thread on entrance to +<B>pthread_mutex_unlock</B>. If the mutex is of the “normal” +type, <B>pthread_mutex_unlock</B> always returns it to the unlocked +state. If it is of the ‘‘recursive’’ type, it decrements the +locking count of the mutex (number of <B>pthread_mutex_lock</B> +operations performed on it by the calling thread), and only when this +count reaches zero is the mutex actually unlocked. +</P> +<P>On ‘‘error checking’’ mutexes, <B>pthread_mutex_unlock</B> +actually checks at run-time that the mutex is locked on entrance, and +that it was locked by the same thread that is now calling +<B>pthread_mutex_unlock</B>. If these conditions are not met, an +error code is returned and the mutex remains unchanged. ‘‘Normal’’ +mutexes perform no such checks, thus allowing a locked mutex to be +unlocked by a thread other than its owner. This is non-portable +behavior and is not meant to be used as a feature.</P> +<P><B>pthread_mutex_destroy</B> destroys a mutex object, freeing the +resources it might hold. The mutex must be unlocked on entrance.</P> +<H2><A HREF="#toc3" NAME="sect3">Cancellation</A></H2> +<P>None of the mutex functions is a cancellation point, not even +<B>pthread_mutex_lock</B>, in spite of the fact that it can suspend a +thread for arbitrary durations. This way, the status of mutexes at +cancellation points is predictable, allowing cancellation handlers to +unlock precisely those mutexes that need to be unlocked before the +thread stops executing. Consequently, threads using deferred +cancellation should never hold a mutex for extended periods of time. +</P> +<H2><A HREF="#toc4" NAME="sect4">Async-signal Safety</A></H2> +<P>The mutex functions are not async-signal safe. What this means is +that they should not be called from a signal handler. In particular, +calling <B>pthread_mutex_lock</B> or <B>pthread_mutex_unlock</B> from +a signal handler may deadlock the calling thread. +</P> +<H2><A HREF="#toc5" NAME="sect5">Return Value</A></H2> +<P><B>pthread_mutex_init</B> always returns 0. The other mutex +functions return 0 on success and a non-zero error code on error. +</P> +<H2><A HREF="#toc6" NAME="sect6">Errors</A></H2> +<P>The <B>pthread_mutex_lock</B> function returns the following error +code on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the mutex has not been properly initialized. + </DD><DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + <B>EDEADLK</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the mutex is already locked by the calling thread (‘‘error + checking’’ mutexes only). + </DD></DL> +</DL> +<P> +The <B>pthread_mutex_trylock</B> function returns the following error +codes on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EBUSY</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the mutex could not be acquired because it was currently locked. + </DD><DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + <B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the mutex has not been properly initialized. + </DD></DL> +</DL> +<P> +The <B>pthread_mutex_timedlock</B> function returns the following +error codes on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>ETIMEDOUT</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the mutex could not be acquired before the <I>abs_timeout</I> time + arrived. + </DD><DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + <B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the mutex has not been properly initialized. + </DD></DL> +</DL> +<P> +The <B>pthread_mutex_unlock</B> function returns the following error +code on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the mutex has not been properly initialized. + </DD><DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + <B>EPERM</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the calling thread does not own the mutex (‘‘error checking’’ + mutexes only). + </DD></DL> +</DL> +<P> +The <B>pthread_mutex_destroy</B> function returns the following error +code on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EBUSY</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the mutex is currently locked. + </DD></DL> +</DL> +<H2> +<A HREF="#toc7" NAME="sect7">Author</A></H2> +<P>Xavier Leroy <Xavier.Leroy@inria.fr> +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<H2><A HREF="#toc8" NAME="sect8">See Also</A></H2> +<P><A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_init</B>(3)</A> +, <A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_settype</B>(3)</A> +, <A HREF="pthread_cancel.html"><B>pthread_cancel</B>(3)</A> . +</P> +<H2><A HREF="#toc9" NAME="sect9">Example</A></H2> +<P>A shared global variable <I>x</I> can be protected by a mutex as +follows: +</P> +<PRE STYLE="margin-left: 1cm; margin-right: 1cm">int x; +pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;</PRE><BLOCKQUOTE STYLE="margin-left: 0cm; margin-right: 0cm"> +All accesses and modifications to <I>x</I> should be bracketed by +calls to <B>pthread_mutex_lock</B> and <B>pthread_mutex_unlock</B> as +follows: +</BLOCKQUOTE> +<PRE STYLE="margin-left: 1.03cm; margin-right: 2cm">pthread_mutex_lock(&mut); +/* operate on x */ +pthread_mutex_unlock(&mut);</PRE> +<HR> +<BLOCKQUOTE STYLE="margin-right: 4cm"><A NAME="toc"></A><B>Table of +Contents</B></BLOCKQUOTE> +<UL> + <LI><BLOCKQUOTE STYLE="margin-right: 4cm; margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 4cm; margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 4cm; margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 4cm; margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Cancellation</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 4cm; margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Async-signal + Safety</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 4cm; margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Return + Value</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 4cm; margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Errors</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 4cm; margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Author</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 4cm; margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">See + Also</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-right: 4cm"><A HREF="#sect9" NAME="toc9">Example</A> + </BLOCKQUOTE> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_mutexattr_init.html b/manual/pthread_mutexattr_init.html new file mode 100644 index 0000000..f3df993 --- /dev/null +++ b/manual/pthread_mutexattr_init.html @@ -0,0 +1,157 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_MUTEXATTR(3) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;23040500"> + <META NAME="CHANGED" CONTENT="20050505;18370400"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_mutexattr_init, pthread_mutexattr_destroy, +pthread_mutexattr_settype, pthread_mutexattr_gettype - mutex creation +attributes +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>int pthread_mutexattr_init(pthread_mutexattr_t *</B><I>attr</I><B>);</B> +</P> +<P><B>int pthread_mutexattr_destroy(pthread_mutexattr_t *</B><I>attr</I><B>);</B> +</P> +<P><B>int pthread_mutexattr_settype(pthread_mutexattr_t *</B><I>attr</I><B>, +int </B><I>type</I><B>);</B> +</P> +<P><B>int pthread_mutexattr_gettype(const pthread_mutexattr_t *</B><I>attr</I><B>, +int *</B><I>type</I><B>);</B> +</P> +<P><B>int pthread_mutexattr_setkind_np(pthread_mutexattr_t *</B><I>attr</I><B>, +int </B><I>type</I><B>);</B> +</P> +<P><B>int pthread_mutexattr_getkind_np(const pthread_mutexattr_t +*</B><I>attr</I><B>, int *</B><I>type</I><B>);</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>Mutex attributes can be specified at mutex creation time, by +passing a mutex attribute object as second argument to +<A HREF="pthread_mutex_init.html"><B>pthread_mutex_init</B>(3)</A> . +Passing <B>NULL</B> is equivalent to passing a mutex attribute object +with all attributes set to their default values. +</P> +<P><B>pthread_mutexattr_init</B> initializes the mutex attribute +object <I>attr</I> and fills it with default values for the +attributes. +</P> +<P><B>pthread_mutexattr_destroy</B> destroys a mutex attribute +object, which must not be reused until it is reinitialized.</P> +<P>The following mutex types are supported:</P> +<P STYLE="margin-left: 2cm"><B>PTHREAD_MUTEX_NORMAL</B> - for +‘‘fast’’ mutexes.</P> +<P STYLE="margin-left: 2cm"><B>PTHREAD_MUTEX_RECURSIVE</B> - for +‘‘recursive’’ mutexes.</P> +<P STYLE="margin-left: 2cm"><B>PTHREAD_MUTEX_ERRORCHECK</B> - for +‘‘error checking’’ mutexes.</P> +<P>The mutex type determines what happens if a thread attempts to +lock a mutex it already owns with <A HREF="pthread_mutex_lock.html"><B>pthread_mutex_lock</B>(3)</A> +. If the mutex is of the “normal” or “fast” type, +<A HREF="pthread_mutex_lock.html"><B>pthread_mutex_lock</B>(3)</A> +simply suspends the calling thread forever. If the mutex is of the +‘‘error checking’’ type, <A HREF="pthread_mutex_lock.html"><B>pthread_mutex_lock</B>(3)</A> +returns immediately with the error code <B>EDEADLK</B>. If the mutex +is of the ‘‘recursive’’ type, the call to +<A HREF="pthread_mutex_lock.html"><B>pthread_mutex_lock</B>(3)</A> +returns immediately with a success return code. The number of times +the thread owning the mutex has locked it is recorded in the mutex. +The owning thread must call <A HREF="pthread_mutex_unlock.html"><B>pthread_mutex_unlock</B>(3)</A> +the same number of times before the mutex returns to the unlocked +state. +</P> +<P>The default mutex type is <B>PTHREAD_MUTEX_NORMAL</B></P> +<P><B>Pthreads-w32</B> also recognises the following equivalent types +that are used by Linux:</P> +<P STYLE="margin-left: 2cm; font-weight: medium"><B>PTHREAD_MUTEX_FAST_NP</B> +– equivalent to <B>PTHREAD_MUTEX_NORMAL</B></P> +<P STYLE="margin-left: 2cm"><B>PTHREAD_MUTEX_RECURSIVE_NP</B></P> +<P STYLE="margin-left: 2cm"><B>PTHREAD_MUTEX_ERRORCHECK_NP</B></P> +<P><B>pthread_mutexattr_settype</B> sets the mutex type attribute in +<I>attr</I> to the value specified by <I>type</I>. +</P> +<P><B>pthread_mutexattr_gettype</B> retrieves the current value of +the mutex kind attribute in <I>attr</I> and stores it in the location +pointed to by <I>type</I>. +</P> +<P><B>Pthreads-w32</B> also recognises the following equivalent +functions that are used in Linux:</P> +<P><B>pthread_mutexattr_setkind_np</B> is an alias for +<B>pthread_mutexattr_settype</B>. +</P> +<P STYLE="font-weight: medium"><B>pthread_mutexattr_getkind_np</B> is +an alias for <B>pthread_mutexattr_gettype</B>. +</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P><B>pthread_mutexattr_init</B>, <B>pthread_mutexattr_destroy</B> +and <B>pthread_mutexattr_gettype</B> always return 0. +</P> +<P><B>pthread_mutexattr_settype</B> returns 0 on success and a +non-zero error code on error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>On error, <B>pthread_mutexattr_settype</B> returns the following +error code: +</P> +<DL> + <DT><B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + <I>type</I> is none of:<BR><B>PTHREAD_MUTEX_NORMAL</B>, + <B>PTHREAD_MUTEX_FAST_NP</B>,<BR><B>PTHREAD_MUTEX_RECURSIVE</B>, + <B>PTHREAD_MUTEX_RECURSIVE_NP,<BR>PTHREAD_MUTEX_ERRORCHECK</B>, + <B>PTHREAD_MUTEX_ERRORCHECK_NP</B> + </DD></DL> +<H2> +<A HREF="#toc5" NAME="sect5">Author</A></H2> +<P>Xavier Leroy <Xavier.Leroy@inria.fr> +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<H2><A HREF="#toc6" NAME="sect6">See Also</A></H2> +<P><A HREF="pthread_mutex_init.html"><B>pthread_mutex_init</B>(3)</A> +, <A HREF="pthread_mutex_lock.html"><B>pthread_mutex_lock</B>(3)</A> +, <A HREF="pthread_mutex_unlock.html"><B>pthread_mutex_unlock</B>(3)</A> +. +</P> +<H2><A HREF="#toc7" NAME="sect7"><U><FONT COLOR="#000080">Notes</FONT></U></A></H2> +<P>For speed, <B>Pthreads-w32</B> never checks the thread ownership +of mutexes of type <B>PTHREAD_MUTEX_NORMAL</B> (or +<B>PTHREAD_MUTEX_FAST_NP</B>) when performing operations on the +mutex. It is therefore possible for one thread to lock such a mutex +and another to unlock it.</P> +<P><SPAN STYLE="font-weight: medium">When developing code, it is a +common precaution to substitute the error checking type, and drop in +the normal type for release if the extra performance is required.</SPAN></P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Author</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">See + Also</A></P> + <LI><P><A HREF="#sect7" NAME="toc7">Notes</A></P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_mutexattr_setpshared.html b/manual/pthread_mutexattr_setpshared.html new file mode 100644 index 0000000..25bf9f6 --- /dev/null +++ b/manual/pthread_mutexattr_setpshared.html @@ -0,0 +1,151 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"PTHREAD_MUTEXATTR_GETPSHARED"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;23480600"> + <META NAME="CHANGED" CONTENT="20050505;18381800"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_mutexattr_getpshared, pthread_mutexattr_setpshared - get +and set the process-shared attribute +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h> </B> +</P> +<P><B>int pthread_mutexattr_getpshared(const pthread_mutexattr_t * +restrict</B> <I>attr</I><B>, int *restrict</B> <I>pshared</I><B>); +<BR>int pthread_mutexattr_setpshared(pthread_mutexattr_t *</B><I>attr</I><B>, +int</B> <I>pshared</I><B>); </B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>pthread_mutexattr_getpshared</B> function shall obtain the +value of the <I>process-shared</I> attribute from the attributes +object referenced by <I>attr</I>. The <B>pthread_mutexattr_setpshared</B> +function shall set the <I>process-shared</I> attribute in an +initialized attributes object referenced by <I>attr</I>. +</P> +<P>The <I>process-shared</I> attribute is set to +<B>PTHREAD_PROCESS_SHARED</B> to permit a mutex to be operated upon +by any thread that has access to the memory where the mutex is +allocated, even if the mutex is allocated in memory that is shared by +multiple processes. If the <I>process-shared</I> attribute is +<B>PTHREAD_PROCESS_PRIVATE</B>, the mutex shall only be operated upon +by threads created within the same process as the thread that +initialized the mutex; if threads of differing processes attempt to +operate on such a mutex, the behavior is undefined. The default value +of the attribute shall be <B>PTHREAD_PROCESS_PRIVATE</B>. +</P> +<P><B>Pthreads-w32</B> defines <B>_POSIX_THREAD_PROCESS_SHARED</B> in +pthread.h as -1 to indicate that these routines are implemented but +the process shared option is not supported.</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>Upon successful completion, <B>pthread_mutexattr_setpshared</B> +shall return zero; otherwise, an error number shall be returned to +indicate the error. +</P> +<P>Upon successful completion, <B>pthread_mutexattr_getpshared</B> +shall return zero and store the value of the <I>process-shared</I> +attribute of <I>attr</I> into the object referenced by the <I>pshared</I> +parameter. Otherwise, an error number shall be returned to indicate +the error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>The <B>pthread_mutexattr_getpshared</B> and +<B>pthread_mutexattr_setpshared</B> functions may fail if: +</P> +<DL> + <DT><B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The value specified by <I>attr</I> is invalid. + </DD></DL> +<P> +The <B>pthread_mutexattr_setpshared</B> function may fail if: +</P> +<DL> + <DT><B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The new value specified for the attribute is outside the range of + legal values for that attribute. + </DD><DT> + <B>ENOTSUP</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The new value specified for the attribute is PTHREAD_PROCESS_SHARED. + </DD></DL> +<P> +These functions shall not return an error code of [EINTR]. +</P> +<P><I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P>None. +</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P><A HREF="pthread_cond_init.html"><B>pthread_cond_destroy</B>(3)</A> +<B>,</B> <A HREF="pthread_create.html"><B>pthread_create</B>(3)</A> <B>,</B> +<A HREF="pthread_mutex_init.html"><B>pthread_mutex_destroy</B>(3)</A> +<B>,</B> <A HREF="pthread_mutexattr_init.html"><B>pthread_mutexattr_destroy</B>(3)</A> +<B>,</B> the Base Definitions volume of IEEE Std 1003.1-2001, +<I><pthread.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_num_processors_np.html b/manual/pthread_num_processors_np.html new file mode 100644 index 0000000..0509410 --- /dev/null +++ b/manual/pthread_num_processors_np.html @@ -0,0 +1,57 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_NUM_PROCESSORS_NP manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;322600"> + <META NAME="CHANGED" CONTENT="20050505;21514100"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P STYLE="font-weight: medium">pthread_num_processors_np – get the +number of processors (CPUs) in use by the process</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>int pthread_num_processors_np(void);</B></P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P><B>pthread_num_processors_np </B>returns the number of processors +in the system. This implementation actually returns the number of +processors available to the process, which can be a lower number than +the system's number, depending on the process's affinity mask.</P> +<H2><A HREF="#toc3" NAME="sect3">Cancellation</A></H2> +<P>None.</P> +<H2><A HREF="#toc4" NAME="sect4"><FONT COLOR="#000080">Return Value</FONT></A></H2> +<P><B>pthread_num_processors_np</B> returns the number of processors +currently available to the process.</P> +<H2><A HREF="#toc5" NAME="sect5">Errors</A></H2> +<P>None.</P> +<H2><A HREF="#toc6" NAME="sect6">Author</A></H2> +<P>Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Cancellation</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Errors</A> + </P> + <LI><P><A HREF="#sect6" NAME="toc6">Author</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_once.html b/manual/pthread_once.html new file mode 100644 index 0000000..8caa864 --- /dev/null +++ b/manual/pthread_once.html @@ -0,0 +1,87 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_ONCE(3) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;322600"> + <META NAME="CHANGED" CONTENT="20050505;21140800"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_once - once-only initialization +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>pthread_once_t </B><I>once_control</I> <B>= PTHREAD_ONCE_INIT;</B> +</P> +<P><B>int pthread_once(pthread_once_t *</B><I>once_control</I><B>, +void (*</B><I>init_routine</I><B>) (void));</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The purpose of <B>pthread_once</B> is to ensure that a piece of +initialization code is executed at most once. The <I>once_control</I> +argument points to a static or extern variable statically initialized +to <B>PTHREAD_ONCE_INIT</B>. +</P> +<P>The first time <B>pthread_once</B> is called with a given +<I>once_control</I> argument, it calls <I>init_routine</I> with no +argument and changes the value of the <I>once_control</I> variable to +record that initialization has been performed. Subsequent calls to +<B>pthread_once</B> with the same <B>once_control</B> argument do +nothing. +</P> +<H2><A HREF="#toc3" NAME="sect3">Cancellation</A></H2> +<P>While <B>pthread_once</B> is not a cancellation point, +<I>init_routine</I> can be. The required effect on <I>once_control</I> +of a cancellation inside the <I>init_routine</I> is to leave it as if +<B>pthread_once</B> had not been called.</P> +<P><B>Pthreads-w32</B> handles <I>init_routine</I> cancellation by +making any threads, that may be waiting on <I>once_control</I>, +re-compete along with any newly arriving threads in the re-running of +<I>init_routine</I>.</P> +<H2><A HREF="#toc4" NAME="sect4">Return Value</A></H2> +<P STYLE="text-decoration: none"><FONT COLOR="#000000"><B>pthread_once</B> +returns 0 on success, or an error code on failure.</FONT></P> +<H2><A HREF="#toc5" NAME="sect5">Errors</A></H2> +<P>The <B>pthread_once</B> function returns the following error code +on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT></DL> +</DL> +<P STYLE="margin-left: 2cm"> +The once_control or init_routine parameter is NULL.</P> +<H2><A HREF="#toc6" NAME="sect6">Author</A></H2> +<P>Xavier Leroy <Xavier.Leroy@inria.fr> +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Cancellation</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Errors</A> + </P> + <LI><P><A HREF="#sect6" NAME="toc6">Author</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_rwlock_init.html b/manual/pthread_rwlock_init.html new file mode 100644 index 0000000..530df93 --- /dev/null +++ b/manual/pthread_rwlock_init.html @@ -0,0 +1,193 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"PTHREAD_RWLOCK_DESTROY"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;10211800"> + <META NAME="CHANGED" CONTENT="20050505;18563400"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_rwlock_destroy, pthread_rwlock_init - destroy and +initialize a read-write lock object +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h> </B> +</P> +<P><B>pthread_wrlock_t </B><I>rwlock</I> <B>= +PTHREAD_RWLOCK_INITIALIZER;</B></P> +<P><B>int pthread_rwlock_destroy(pthread_rwlock_t *</B><I>rwlock</I><B>); +<BR>int pthread_rwlock_init(pthread_rwlock_t *restrict</B> <I>rwlock</I><B>, +const pthread_rwlockattr_t *restrict</B> <I>attr</I><B>); </B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>pthread_rwlock_destroy</B> function shall destroy the +read-write lock object referenced by <I>rwlock</I> and release any +resources used by the lock. The effect of subsequent use of the lock +is undefined until the lock is reinitialized by another call to +<B>pthread_rwlock_init</B>. An implementation may cause +<B>pthread_rwlock_destroy</B> to set the object referenced by <I>rwlock</I> +to an invalid value. Results are undefined if <B>pthread_rwlock_destroy</B> +is called when any thread holds <I>rwlock</I>. Attempting to destroy +an uninitialized read-write lock results in undefined behavior. +</P> +<P>The <B>pthread_rwlock_init</B> function shall allocate any +resources required to use the read-write lock referenced by <I>rwlock</I> +and initializes the lock to an unlocked state with attributes +referenced by <I>attr</I>. If <I>attr</I> is NULL, the default +read-write lock attributes shall be used; the effect is the same as +passing the address of a default read-write lock attributes object. +Once initialized, the lock can be used any number of times without +being reinitialized. Results are undefined if <B>pthread_rwlock_init</B> +is called specifying an already initialized read-write lock. Results +are undefined if a read-write lock is used without first being +initialized. +</P> +<P>If the <B>pthread_rwlock_init</B> function fails, <I>rwlock</I> +shall not be initialized and the contents of <I>rwlock</I> are +undefined. +</P> +<P><B>Pthreads-w32</B> supports statically initialized <I>rwlock</I> +objects using <B>PTHREAD_RWLOCK_INITIALIZER</B>. <SPAN STYLE="font-weight: medium"> +An application should still call <B>pthread_rwlock_destroy</B> at +some point to ensure that any resources consumed by the read/write +lock are released.</SPAN></P> +<P>Only the object referenced by <I>rwlock</I> may be used for +performing synchronization. The result of referring to copies of that +object in calls to <B>pthread_rwlock_destroy</B> , +<B>pthread_rwlock_rdlock</B> , <B>pthread_rwlock_timedrdlock</B> , +<B>pthread_rwlock_timedwrlock</B> , <B>pthread_rwlock_tryrdlock</B> , +<B>pthread_rwlock_trywrlock</B> , <B>pthread_rwlock_unlock</B> , or +<B>pthread_rwlock_wrlock</B> is undefined. +</P> +<P><B>Pthreads-w32</B> defines <B>_POSIX_READER_WRITER_LOCKS</B> in +pthread.h as 200112L to indicate that the reader/writer routines are +implemented and may be used.</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>If successful, the <B>pthread_rwlock_destroy</B> and +<B>pthread_rwlock_init</B> functions shall return zero; otherwise, an +error number shall be returned to indicate the error. +</P> +<P>The [EBUSY] and [EINVAL] error checks, if implemented, act as if +they were performed immediately at the beginning of processing for +the function and caused an error return prior to modifying the state +of the read-write lock specified by <I>rwlock</I>. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>The <B>pthread_rwlock_destroy</B> function may fail if: +</P> +<DL> + <DT><B>EBUSY</B> + </DT><DD> + The implementation has detected an attempt to destroy the object + referenced by <I>rwlock</I> while it is locked. + </DD><DT> + <B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The value specified by <I>rwlock</I> is invalid. + </DD></DL> +<P> +The <B>pthread_rwlock_init</B> function shall fail if: +</P> +<DL> + <DT><B>EAGAIN</B> + </DT><DD> + The system lacked the necessary resources (other than memory) to + initialize another read-write lock. + </DD><DT> + <B>ENOMEM</B> + </DT><DD> + Insufficient memory exists to initialize the read-write lock. + </DD><DD STYLE="margin-left: 0cm; margin-bottom: 0.5cm"> + <BR><BR> + </DD></DL> +<P> +The <B>pthread_rwlock_init</B> function may fail if: +</P> +<DL> + <DT><B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The value specified by <I>attr</I> is invalid. + </DD></DL> +<P> +These functions shall not return an error code of [EINTR]. +</P> +<P><I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P>Applications using these and related read-write lock functions may +be subject to priority inversion, as discussed in the Base +Definitions volume of IEEE Std 1003.1-2001, Section 3.285, +Priority Inversion. +</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P><A HREF="pthread_rwlock_rdlock.html"><B>pthread_rwlock_rdlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_timedrdlock.html"><B>pthread_rwlock_timedrdlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_timedwrlock.html"><B>pthread_rwlock_timedwrlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_rdlock.html"><B>pthread_rwlock_tryrdlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_wrlock.html"><B>pthread_rwlock_trywrlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_unlock.html"><B>pthread_rwlock_unlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_wrlock.html"><B>pthread_rwlock_wrlock</B>(3)</A> +<B>,</B> the Base Definitions volume of IEEE Std 1003.1-2001, +<I><pthread.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_rwlock_rdlock.html b/manual/pthread_rwlock_rdlock.html new file mode 100644 index 0000000..3b63f25 --- /dev/null +++ b/manual/pthread_rwlock_rdlock.html @@ -0,0 +1,168 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"PTHREAD_RWLOCK_RDLOCK"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;10352600"> + <META NAME="CHANGED" CONTENT="20050505;12554200"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_rwlock_rdlock, pthread_rwlock_tryrdlock - lock a +read-write lock object for reading +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h> </B> +</P> +<P><B>int pthread_rwlock_rdlock(pthread_rwlock_t <I>*</I></B><I>rwlock</I><B>); +<BR></B>i<B>nt pthread_rwlock_tryrdlock(pthread_rwlock_t <I>*</I></B><I>rwlock</I><B>); +</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>pthread_rwlock_rdlock</B> function shall apply a read lock +to the read-write lock referenced by <I>rwlock</I>. The calling +thread acquires the read lock if a writer does not hold the lock and +there are no writers blocked on the lock. +</P> +<P><B>Pthreads-win32</B> does not prefer either writers or readers in +acquiring the lock – all threads enter a single prioritised FIFO +queue. While this may not be optimally efficient for some +applications, it does ensure that one type does not starve the other.</P> +<P>A thread may hold multiple concurrent read locks on <I>rwlock</I> +(that is, successfully call the <B>pthread_rwlock_rdlock</B> function +<I>n</I> times). If so, the application shall ensure that the thread +performs matching unlocks (that is, it calls the +<A HREF="pthread_rwlock_unlock.html"><B>pthread_rwlock_unlock</B>(3)</A> +function <I>n</I> times). +</P> +<P>The <B>pthread_rwlock_tryrdlock</B> function shall apply a read +lock as in the <B>pthread_rwlock_rdlock</B> function, with the +exception that the function shall fail if the equivalent +<B>pthread_rwlock_rdlock</B> call would have blocked the calling +thread. In no case shall the <B>pthread_rwlock_tryrdlock</B> function +ever block; it always either acquires the lock or fails and returns +immediately. +</P> +<P>Results are undefined if any of these functions are called with an +uninitialized read-write lock. +</P> +<P><B>Pthreads-w32</B> does not detect deadlock if the thread already +owns the lock for writing.</P> +<P><B>Pthreads-w32</B> defines <B>_POSIX_READER_WRITER_LOCKS</B> in +pthread.h as 200112L to indicate that the reader/writer routines are +implemented and may be used.</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>If successful, the <B>pthread_rwlock_rdlock</B> function shall +return zero; otherwise, an error number shall be returned to indicate +the error. +</P> +<P>The <B>pthread_rwlock_tryrdlock</B> function shall return zero if +the lock for reading on the read-write lock object referenced by +<I>rwlock</I> is acquired. Otherwise, an error number shall be +returned to indicate the error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>The <B>pthread_rwlock_tryrdlock</B> function shall fail if: +</P> +<DL> + <DT><B>EBUSY</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The read-write lock could not be acquired for reading because a + writer holds the lock or a writer with the appropriate priority was + blocked on it. + </DD></DL> +<P> +The <B>pthread_rwlock_rdlock</B> and <B>pthread_rwlock_tryrdlock</B> +functions may fail if: +</P> +<DL> + <DT><B>EINVAL</B> + </DT><DD> + The value specified by <I>rwlock</I> does not refer to an + initialized read-write lock object. + </DD><DT> + <B>EAGAIN</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The read lock could not be acquired because the maximum number of + read locks for <I>rwlock</I> has been exceeded. + </DD></DL> +<P> +These functions shall not return an error code of [EINTR]. +</P> +<P><I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P>Applications using these functions may be subject to priority +inversion, as discussed in the Base Definitions volume of +IEEE Std 1003.1-2001, Section 3.285, Priority Inversion. +</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P><A HREF="pthread_rwlock_init.html"><B>pthread_rwlock_destroy</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_timedrdlock.html"><B>pthread_rwlock_timedrdlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_timedwrlock.html"><B>pthread_rwlock_timedwrlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_wrlock.html"><B>pthread_rwlock_trywrlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_unlock.html"><B>pthread_rwlock_unlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_wrlock.html"><B>pthread_rwlock_wrlock</B>(3)</A> +<B>,</B> the Base Definitions volume of IEEE Std 1003.1-2001, +<I><pthread.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_rwlock_timedrdlock.html b/manual/pthread_rwlock_timedrdlock.html new file mode 100644 index 0000000..1b9ca63 --- /dev/null +++ b/manual/pthread_rwlock_timedrdlock.html @@ -0,0 +1,156 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"PTHREAD_RWLOCK_TIMEDRDLOCK"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;11101700"> + <META NAME="CHANGED" CONTENT="20050505;12560000"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_rwlock_timedrdlock - lock a read-write lock for reading +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h> <BR></B>#include <time.h> +</P> +<P><B>int pthread_rwlock_timedrdlock(pthread_rwlock_t *restrict</B> +<I>rwlock</I><B>, const struct timespec *restrict</B> <I>abs_timeout</I><B>); +</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>pthread_rwlock_timedrdlock</B> function shall apply a read +lock to the read-write lock referenced by <I>rwlock</I> as in the +<A HREF="pthread_rwlock_rdlock.html"><B>pthread_rwlock_rdlock</B>(3)</A> +function. However, if the lock cannot be acquired without waiting for +other threads to unlock the lock, this wait shall be terminated when +the specified timeout expires. The timeout shall expire when the +absolute time specified by <I>abs_timeout</I> passes, as measured by +the clock on which timeouts are based (that is, when the value of +that clock equals or exceeds <I>abs_timeout</I>), or if the absolute +time specified by <I>abs_timeout</I> has already been passed at the +time of the call. +</P> +<P>The <B>timespec</B> data type is defined in the <I><time.h></I> +header. Under no circumstances shall the function fail with a timeout +if the lock can be acquired immediately. The validity of the +<I>abs_timeout</I> parameter need not be checked if the lock can be +immediately acquired. +</P> +<P>The calling thread may deadlock if at the time the call is made it +holds a write lock on <I>rwlock</I>. The results are undefined if +this function is called with an uninitialized read-write lock. +</P> +<P><B>Pthreads-w32</B> defines <B>_POSIX_READER_WRITER_LOCKS</B> in +pthread.h as 200112L to indicate that the reader/writer routines are +implemented and may be used.</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>The <B>pthread_rwlock_timedrdlock</B> function shall return zero +if the lock for reading on the read-write lock object referenced by +<I>rwlock</I> is acquired. Otherwise, an error number shall be +returned to indicate the error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>The <B>pthread_rwlock_timedrdlock</B> function shall fail if: +</P> +<DL> + <DT><B>ETIMEDOUT</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The lock could not be acquired before the specified timeout expired. + </DD></DL> +<P> +The <B>pthread_rwlock_timedrdlock</B> function may fail if: +</P> +<DL> + <DT><B>EAGAIN</B> + </DT><DD> + The read lock could not be acquired because the maximum number of + read locks for lock would be exceeded. + </DD><DT> + <B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The value specified by <I>rwlock</I> does not refer to an + initialized read-write lock object, or the <I>abs_timeout</I> + nanosecond value is less than zero or greater than or equal to 1000 + million. + </DD></DL> +<P> +This function shall not return an error code of [EINTR]. +</P> +<P><I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P>Applications using this function may be subject to priority +inversion, as discussed in the Base Definitions volume of +IEEE Std 1003.1-2001, Section 3.285, Priority Inversion. +</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P><A HREF="pthread_rwlock_init.html"><B>pthread_rwlock_destroy</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_rdlock.html"><B>pthread_rwlock_rdlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_timedwrlock.html"><B>pthread_rwlock_timedwrlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_rdlock.html"><B>pthread_rwlock_tryrdlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_wrlock.html"><B>pthread_rwlock_trywrlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_unlock.html"><B>pthread_rwlock_unlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_wrlock.html"><B>pthread_rwlock_wrlock</B>(3)</A> +<B>,</B> the Base Definitions volume of IEEE Std 1003.1-2001, +<I><pthread.h></I>, <I><time.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_rwlock_timedwrlock.html b/manual/pthread_rwlock_timedwrlock.html new file mode 100644 index 0000000..0213bab --- /dev/null +++ b/manual/pthread_rwlock_timedwrlock.html @@ -0,0 +1,150 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"PTHREAD_RWLOCK_TIMEDWRLOCK"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;11172800"> + <META NAME="CHANGED" CONTENT="20050505;12561600"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_rwlock_timedwrlock - lock a read-write lock for writing +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h> <BR></B>#include <time.h> +</P> +<P><B>int pthread_rwlock_timedwrlock(pthread_rwlock_t *restrict</B> +<I>rwlock</I><B>, const struct timespec *restrict</B> <I>abs_timeout</I><B>); +</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>pthread_rwlock_timedwrlock</B> function shall apply a write +lock to the read-write lock referenced by <I>rwlock</I> as in the +<A HREF="pthread_rwlock_wrlock.html"><B>pthread_rwlock_wrlock</B>(3)</A> +function. However, if the lock cannot be acquired without waiting for +other threads to unlock the lock, this wait shall be terminated when +the specified timeout expires. The timeout shall expire when the +absolute time specified by <I>abs_timeout</I> passes, as measured by +the clock on which timeouts are based (that is, when the value of +that clock equals or exceeds <I>abs_timeout</I>), or if the absolute +time specified by <I>abs_timeout</I> has already been passed at the +time of the call. +</P> +<P>The <B>timespec</B> data type is defined in the <I><time.h></I> +header. Under no circumstances shall the function fail with a timeout +if the lock can be acquired immediately. The validity of the +<I>abs_timeout</I> parameter need not be checked if the lock can be +immediately acquired. +</P> +<P>The calling thread may deadlock if at the time the call is made it +holds the read-write lock. The results are undefined if this function +is called with an uninitialized read-write lock. +</P> +<P><B>Pthreads-w32</B> defines <B>_POSIX_READER_WRITER_LOCKS</B> in +pthread.h as 200112L to indicate that the reader/writer routines are +implemented and may be used.</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>The <B>pthread_rwlock_timedwrlock</B> function shall return zero +if the lock for writing on the read-write lock object referenced by +<I>rwlock</I> is acquired. Otherwise, an error number shall be +returned to indicate the error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>The <B>pthread_rwlock_timedwrlock</B> function shall fail if: +</P> +<DL> + <DT><B>ETIMEDOUT</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The lock could not be acquired before the specified timeout expired. + </DD></DL> +<P> +The <B>pthread_rwlock_timedwrlock</B> function may fail if: +</P> +<DL> + <DT><B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The value specified by rwlock does not refer to an initialized + read-write lock object, or the <I>abs_timeout</I> nanosecond value + is less than zero or greater than or equal to 1000 million. + </DD></DL> +<P> +This function shall not return an error code of [EINTR]. +</P> +<P><I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P>Applications using this function may be subject to priority +inversion, as discussed in the Base Definitions volume of +IEEE Std 1003.1-2001, Section 3.285, Priority Inversion. +</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P><A HREF="pthread_rwlock_init.html"><B>pthread_rwlock_destroy</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_rdlock.html"><B>pthread_rwlock_rdlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_timedrdlock.html"><B>pthread_rwlock_timedrdlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_rdlock.html"><B>pthread_rwlock_tryrdlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_wrlock.html"><B>pthread_rwlock_trywrlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_unlock.html"><B>pthread_rwlock_unlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_wrlock.html"><B>pthread_rwlock_wrlock</B>(3)</A> +<B>,</B> the Base Definitions volume of IEEE Std 1003.1-2001, +<I><pthread.h></I>, <I><time.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_rwlock_unlock.html b/manual/pthread_rwlock_unlock.html new file mode 100644 index 0000000..09725cc --- /dev/null +++ b/manual/pthread_rwlock_unlock.html @@ -0,0 +1,141 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"PTHREAD_RWLOCK_UNLOCK"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;11291100"> + <META NAME="CHANGED" CONTENT="20050505;12562700"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_rwlock_unlock - unlock a read-write lock object +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h> </B> +</P> +<P>in<B>t pthread_rwlock_unlock(pthread_rwlock_t <I>*</I></B><I>rwlock</I><B>); +</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>pthread_rwlock_unlock</B> function shall release a lock +held on the read-write lock object referenced by <I>rwlock</I>. +Results are undefined if the read-write lock <I>rwlock</I> is not +held by the calling thread. +</P> +<P>If this function is called to release a read lock from the +read-write lock object and there are other read locks currently held +on this read-write lock object, the read-write lock object remains in +the read locked state. If this function releases the last read lock +for this read-write lock object, the read-write lock object shall be +put in the unlocked state with no owners. +</P> +<P>If this function is called to release a write lock for this +read-write lock object, the read-write lock object shall be put in +the unlocked state. +</P> +<P><B>Pthreads-win32</B> does not prefer either writers or readers in +acquiring the lock – all threads enter a single prioritised FIFO +queue. While this may not be optimally efficient for some +applications, it does ensure that one type does not starve the other.</P> +<P>Results are undefined if any of these functions are called with an +uninitialized read-write lock. +</P> +<P><B>Pthreads-w32</B> defines <B>_POSIX_READER_WRITER_LOCKS</B> in +pthread.h as 200112L to indicate that the reader/writer routines are +implemented and may be used.</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>If successful, the <B>pthread_rwlock_unlock</B> function shall +return zero; otherwise, an error number shall be returned to indicate +the error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>The <B>pthread_rwlock_unlock</B> function may fail if: +</P> +<DL> + <DT><B>EINVAL</B> + </DT><DD> + The value specified by <I>rwlock</I> does not refer to an + initialized read-write lock object. + </DD><DD STYLE="margin-left: 0cm; margin-bottom: 0.5cm"> + <BR><BR> + </DD></DL> +<P> +The <B>pthread_rwlock_unlock</B> function shall not return an error +code of [EINTR]. +</P> +<P><I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P>None. +</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P><A HREF="pthread_rwlock_init.html"><B>pthread_rwlock_destroy</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_rdlock.html"><B>pthread_rwlock_rdlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_timedrdlock.html"><B>pthread_rwlock_timedrdlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_timedwrlock.html"><B>pthread_rwlock_timedwrlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_rdlock.html"><B>pthread_rwlock_tryrdlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_wrlock.html"><B>pthread_rwlock_trywrlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_wrlock.html"><B>pthread_rwlock_wrlock</B>(3)</A> +, the Base Definitions volume of IEEE Std 1003.1-2001, +<I><pthread.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_rwlock_wrlock.html b/manual/pthread_rwlock_wrlock.html new file mode 100644 index 0000000..02b3a19 --- /dev/null +++ b/manual/pthread_rwlock_wrlock.html @@ -0,0 +1,153 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"PTHREAD_RWLOCK_TRYWRLOCK"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;11221900"> + <META NAME="CHANGED" CONTENT="20050505;12563800"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_rwlock_trywrlock, pthread_rwlock_wrlock - lock a +read-write lock object for writing +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h> </B> +</P> +<P><B>int pthread_rwlock_trywrlock(pthread_rwlock_t <I>*</I></B><I>rwlock</I><B>); +<BR>int pthread_rwlock_wrlock(pthread_rwlock_t <I>*</I></B><I>rwlock</I><B>); +</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>pthread_rwlock_trywrlock</B> function shall apply a write +lock like the <B>pthread_rwlock_wrlock</B> function, with the +exception that the function shall fail if any thread currently holds +<I>rwlock</I> (for reading or writing). +</P> +<P>The <B>pthread_rwlock_wrlock</B> function shall apply a write lock +to the read-write lock referenced by <I>rwlock</I>. The calling +thread acquires the write lock if no other thread (reader or writer) +holds the read-write lock <I>rwlock</I>. Otherwise, the thread shall +block until it can acquire the lock. The calling thread may deadlock +if at the time the call is made it holds the read-write lock (whether +a read or write lock). +</P> +<P><B>Pthreads-win32</B> does not prefer either writers or readers in +acquiring the lock – all threads enter a single prioritised FIFO +queue. While this may not be optimally efficient for some +applications, it does ensure that one type does not starve the other.</P> +<P>Results are undefined if any of these functions are called with an +uninitialized read-write lock. +</P> +<P><B>Pthreads-w32</B> defines <B>_POSIX_READER_WRITER_LOCKS</B> in +pthread.h as 200112L to indicate that the reader/writer routines are +implemented and may be used.</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>The <B>pthread_rwlock_trywrlock</B> function shall return zero if +the lock for writing on the read-write lock object referenced by +<I>rwlock</I> is acquired. Otherwise, an error number shall be +returned to indicate the error. +</P> +<P>If successful, the <B>pthread_rwlock_wrlock</B> function shall +return zero; otherwise, an error number shall be returned to indicate +the error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>The <B>pthread_rwlock_trywrlock</B> function shall fail if: +</P> +<DL> + <DT><B>EBUSY</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The read-write lock could not be acquired for writing because it was + already locked for reading or writing. + </DD></DL> +<P> +The <B>pthread_rwlock_trywrlock</B> and <B>pthread_rwlock_wrlock</B> +functions may fail if: +</P> +<DL> + <DT><B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The value specified by <I>rwlock</I> does not refer to an + initialized read-write lock object. + </DD></DL> +<P> +These functions shall not return an error code of [EINTR]. +</P> +<P><I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P>Applications using these functions may be subject to priority +inversion, as discussed in the Base Definitions volume of +IEEE Std 1003.1-2001, Section 3.285, Priority Inversion. +</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P><A HREF="pthread_rwlock_init.html"><B>pthread_rwlock_destroy</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_rdlock.html"><B>pthread_rwlock_rdlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_timedrdlock.html"><B>pthread_rwlock_timedrdlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_timedwrlock.html"><B>pthread_rwlock_timedwrlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_rdlock.html"><B>pthread_rwlock_tryrdlock</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlock_unlock.html"><B>pthread_rwlock_unlock</B>(3)</A> +<B>,</B> the Base Definitions volume of IEEE Std 1003.1-2001, +<I><pthread.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_rwlockattr_init.html b/manual/pthread_rwlockattr_init.html new file mode 100644 index 0000000..67da876 --- /dev/null +++ b/manual/pthread_rwlockattr_init.html @@ -0,0 +1,141 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"PTHREAD_RWLOCKATTR_DESTROY"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;504000"> + <META NAME="CHANGED" CONTENT="20050505;18474200"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_rwlockattr_destroy, pthread_rwlockattr_init - destroy and +initialize the read-write lock attributes object +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h> </B> +</P> +<P><B>int pthread_rwlockattr_destroy(pthread_rwlockattr_t <I>*</I></B><I>attr</I><B>); +<BR>int pthread_rwlockattr_init(pthread_rwlockattr_t <I>*</I></B><I>attr</I><B>); +</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>pthread_rwlockattr_destroy</B> function shall destroy a +read-write lock attributes object. A destroyed <I>attr</I> attributes +object can be reinitialized using <B>pthread_rwlockattr_init</B> ; +the results of otherwise referencing the object after it has been +destroyed are undefined. An implementation may cause +<B>pthread_rwlockattr_destroy</B> to set the object referenced by +<I>attr</I> to an invalid value. +</P> +<P>The <B>pthread_rwlockattr_init</B> function shall initialize a +read-write lock attributes object <I>attr</I> with the default value +for all of the attributes defined by the implementation. +</P> +<P>Results are undefined if <B>pthread_rwlockattr_init</B> is called +specifying an already initialized <I>attr</I> attributes object. +</P> +<P>After a read-write lock attributes object has been used to +initialize one or more read-write locks, any function affecting the +attributes object (including destruction) shall not affect any +previously initialized read-write locks. +</P> +<P><B>Pthreads-w32</B> defines <B>_POSIX_READER_WRITER_LOCKS</B> in +pthread.h as 200112L to indicate that the reader/writer routines are +implemented and may be used.</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>If successful, the <B>pthread_rwlockattr_destroy</B> and +<B>pthread_rwlockattr_init</B> functions shall return zero; +otherwise, an error number shall be returned to indicate the error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>The <B>pthread_rwlockattr_destroy</B> function may fail if: +</P> +<DL> + <DT><B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The value specified by <I>attr</I> is invalid. + </DD></DL> +<P> +The <B>pthread_rwlockattr_init</B> function shall fail if: +</P> +<DL> + <DT><B>ENOMEM</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + Insufficient memory exists to initialize the read-write lock + attributes object. + </DD></DL> +<P> +These functions shall not return an error code of [EINTR]. +</P> +<P><I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P>None. +</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P><A HREF="pthread_rwlock_init.html"><B>pthread_rwlock_destroy</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlockattr_setpshared.html"><B>pthread_rwlockattr_getpshared</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlockattr_setpshared.html"><B>pthread_rwlockattr_setpshared</B>(3)</A> +<B>,</B> the Base Definitions volume of IEEE Std 1003.1-2001, +<I><pthread.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_rwlockattr_setpshared.html b/manual/pthread_rwlockattr_setpshared.html new file mode 100644 index 0000000..9db6f4c --- /dev/null +++ b/manual/pthread_rwlockattr_setpshared.html @@ -0,0 +1,160 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"PTHREAD_RWLOCKATTR_GETPSHARED"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;10124400"> + <META NAME="CHANGED" CONTENT="20050505;12572100"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_rwlockattr_getpshared, pthread_rwlockattr_setpshared - get +and set the process-shared attribute of the read-write lock +attributes object +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h> </B> +</P> +<P><B>int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t * +restrict </B><I>attr</I><B>, int *restrict</B> <I>pshared</I><B>); +<BR>int pthread_rwlockattr_setpshared(pthread_rwlockattr_t <I>*</I></B><I>attr</I><B>, +int</B> <I>pshared</I><B>); </B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>pthread_rwlockattr_getpshared</B> function shall obtain the +value of the <I>process-shared</I> attribute from the initialized +attributes object referenced by <I>attr</I>. The +<B>pthread_rwlockattr_setpshared</B> function shall set the +<I>process-shared</I> attribute in an initialized attributes object +referenced by <I>attr</I>. +</P> +<P>The <I>process-shared</I> attribute shall be set to +<B>PTHREAD_PROCESS_SHARED</B> to permit a read-write lock to be +operated upon by any thread that has access to the memory where the +read-write lock is allocated, even if the read-write lock is +allocated in memory that is shared by multiple processes. If the +<I>process-shared</I> attribute is <B>PTHREAD_PROCESS_PRIVATE</B>, +the read-write lock shall only be operated upon by threads created +within the same process as the thread that initialized the read-write +lock; if threads of differing processes attempt to operate on such a +read-write lock, the behavior is undefined. The default value of the +<I>process-shared</I> attribute shall be <B>PTHREAD_PROCESS_PRIVATE</B>. +</P> +<P><B>Pthreads-w32</B> defines <B>_POSIX_THREAD_PROCESS_SHARED</B> in +pthread.h as -1 to indicate that these routines are implemented but +they do not support the process shared option.</P> +<P>Additional attributes, their default values, and the names of the +associated functions to get and set those attribute values are +implementation-defined. +</P> +<P><B>Pthreads-w32</B> defines <B>_POSIX_READER_WRITER_LOCKS</B> in +pthread.h as 200112L to indicate that the reader/writer routines are +implemented and may be used.</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>Upon successful completion, the <B>pthread_rwlockattr_getpshared</B> +function shall return zero and store the value of the <I>process-shared</I> +attribute of <I>attr</I> into the object referenced by the <I>pshared</I> +parameter. Otherwise, an error number shall be returned to indicate +the error. +</P> +<P>If successful, the <B>pthread_rwlockattr_setpshared</B> function +shall return zero; otherwise, an error number shall be returned to +indicate the error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>The <B>pthread_rwlockattr_getpshared</B> and +<B>pthread_rwlockattr_setpshared</B> functions may fail if: +</P> +<DL> + <DT><B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The value specified by <I>attr</I> is invalid. + </DD></DL> +<P> +The <B>pthread_rwlockattr_setpshared</B> function may fail if: +</P> +<DL> + <DT><B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The new value specified for the attribute is outside the range of + legal values for that attribute. + </DD><DT> + <B>ENOTSUP</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The new value specified for the attribute is <B>PTHREAD_PROCESS_SHARED</B>. + </DD></DL> +<P> +These functions shall not return an error code of [EINTR]. +</P> +<P><I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P>None. +</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P><A HREF="pthread_rwlock_init.html"><B>pthread_rwlock_destroy</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlockattr_init.html"><B>pthread_rwlockattr_destroy</B>(3)</A> +<B>,</B> <A HREF="pthread_rwlockattr_init.html"><B>pthread_rwlockattr_init</B>(3)</A> +<B>,</B> the Base Definitions volume of IEEE Std 1003.1-2001, +<I><pthread.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_self.html b/manual/pthread_self.html new file mode 100644 index 0000000..82e16ea --- /dev/null +++ b/manual/pthread_self.html @@ -0,0 +1,70 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_SELF(3) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;11361600"> + <META NAME="CHANGED" CONTENT="20050505;11575700"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_self - return identifier of current thread +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>pthread_t pthread_self(void);</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P><B>pthread_self</B> return the thread identifier for the calling +thread. +</P> +<P><B>Pthreads-w32</B> also provides support for <B>Win32</B> native +threads to interact with POSIX threads through the pthreads API. +Whereas all threads created via a call to pthread_create have a POSIX +thread ID and thread state, the library ensures that any Win32 native +threads that interact through the Pthreads API also generate a POSIX +thread ID and thread state when and if necessary. This provides full +<SPAN LANG="en-GB">reciprocity</SPAN> between Win32 and POSIX +threads. Win32 native threads that generate a POSIX thread ID and +state are treated by the library as having been created with the +<B>PTHREAD_CREATE_DETACHED</B> attribute.</P> +<P>Any Win32 native thread may call <B>pthread_self</B> directly to +return it's POSIX thread identifier. The ID and state will be +generated if it does not already exist. Win32 native threads do not +need to call <B>pthread_self</B> before calling Pthreads-w32 routines +unless that routine requires a pthread_t parameter.</P> +<H2><A HREF="#toc3" NAME="sect3">Author</A></H2> +<P>Xavier Leroy <Xavier.Leroy@inria.fr> +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<H2><A HREF="#toc4" NAME="sect4">See Also</A></H2> +<P><A HREF="pthread_equal.html"><B>pthread_equal</B>(3)</A> , +<A HREF="pthread_join.html"><B>pthread_join</B>(3)</A> , +<A HREF="pthread_detach.html"><B>pthread_detach</B>(3)</A> , +<A HREF="pthread_setschedparam.html"><B>pthread_setschedparam</B>(3)</A> +, <A HREF="pthread_setschedparam.html"><B>pthread_getschedparam</B>(3)</A> +. +</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Author</A> + </P> + <LI><P><A HREF="#sect4" NAME="toc4">See Also</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_setcancelstate.html b/manual/pthread_setcancelstate.html new file mode 100644 index 0000000..3ce65c4 --- /dev/null +++ b/manual/pthread_setcancelstate.html @@ -0,0 +1,207 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_CANCEL(3) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;12090500"> + <META NAME="CHANGED" CONTENT="20050504;16361300"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_cancel, pthread_setcancelstate, pthread_setcanceltype, +pthread_testcancel - thread cancellation +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>int pthread_cancel(pthread_t </B><I>thread</I><B>);</B> +</P> +<P><B>int pthread_setcancelstate(int </B><I>state</I><B>, int +*</B><I>oldstate</I><B>);</B> +</P> +<P><B>int pthread_setcanceltype(int </B><I>type</I><B>, int +*</B><I>oldtype</I><B>);</B> +</P> +<P><B>void pthread_testcancel(void);</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>Cancellation is the mechanism by which a thread can terminate the +execution of another thread. More precisely, a thread can send a +cancellation request to another thread. Depending on its settings, +the target thread can then either ignore the request, honor it +immediately, or defer it until it reaches a cancellation point. +</P> +<P>When a thread eventually honors a cancellation request, it +performs as if <B>pthread_exit(PTHREAD_CANCELED)</B> has been called +at that point: all cleanup handlers are executed in reverse order, +destructor functions for thread-specific data are called, and finally +the thread stops executing with the return value <B>PTHREAD_CANCELED</B>. +See <A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> for more +information. +</P> +<P><B>pthread_cancel</B> sends a cancellation request to the thread +denoted by the <I>thread</I> argument. +</P> +<P><B>pthread_setcancelstate</B> changes the cancellation state for +the calling thread -- that is, whether cancellation requests are +ignored or not. The <I>state</I> argument is the new cancellation +state: either <B>PTHREAD_CANCEL_ENABLE</B> to enable cancellation, or +<B>PTHREAD_CANCEL_DISABLE</B> to disable cancellation (cancellation +requests are ignored). If <I>oldstate</I> is not <B>NULL</B>, the +previous cancellation state is stored in the location pointed to by +<I>oldstate</I>, and can thus be restored later by another call to +<B>pthread_setcancelstate</B>. +</P> +<P><B>pthread_setcanceltype</B> changes the type of responses to +cancellation requests for the calling thread: asynchronous +(immediate) or deferred. The <I>type</I> argument is the new +cancellation type: either <B>PTHREAD_CANCEL_ASYNCHRONOUS</B> to +cancel the calling thread as soon as the cancellation request is +received, or <B>PTHREAD_CANCEL_DEFERRED</B> to keep the cancellation +request pending until the next cancellation point. If <I>oldtype</I> +is not <B>NULL</B>, the previous cancellation state is stored in the +location pointed to by <I>oldtype</I>, and can thus be restored later +by another call to <B>pthread_setcanceltype</B>. +</P> +<P><B>Pthreads-w32</B> provides two levels of support for +<B>PTHREAD_CANCEL_ASYNCHRONOUS</B>: full and partial. Full support +requires an additional DLL and driver be installed on the Windows +system (see the See Also section below) that allows blocked threads +to be cancelled immediately. Partial support means that the target +thread will not cancel until it resumes execution naturally. Partial +support is provided if either the DLL or the driver are not +automatically detected by the pthreads-w32 library at run-time.</P> +<P>Threads are always created by <A HREF="pthread_create.html"><B>pthread_create</B>(3)</A> +with cancellation enabled and deferred. That is, the initial +cancellation state is <B>PTHREAD_CANCEL_ENABLE</B> and the initial +type is <B>PTHREAD_CANCEL_DEFERRED</B>. +</P> +<P>Cancellation points are those points in the program execution +where a test for pending cancellation requests is performed and +cancellation is executed if positive. The following POSIX threads +functions are cancellation points: +</P> +<P><A HREF="pthread_join.html"><B>pthread_join</B>(3)</A> +<BR><A HREF="pthread_cond_wait.html"><B>pthread_cond_wait</B>(3)</A> +<BR><A HREF="pthread_cond_timedwait.html"><B>pthread_cond_timedwait</B>(3)</A> +<BR><A HREF="pthread_testcancel.html"><B>pthread_testcancel</B>(3)</A> +<BR><A HREF="sem_wait.html"><B>sem_wait</B>(3)</A> <BR><A HREF="sem_timedwait.html"><B>sem_timedwait</B>(3)</A> +<BR><A HREF="sigwait.html"><B>sigwait</B>(3)</A> (not supported under +<B>Pthreads-w32</B>)</P> +<P><B>Pthreads-w32</B> provides two functions to enable additional +cancellation points to be created in user functions that block on +Win32 HANDLEs:</P> +<P><A HREF="pthreadCancelableWait.html">pthreadCancelableWait()</A> +<BR><A HREF="pthreadCancelableTimedWait.html">pthreadCancelableTimedWait()</A></P> +<P>All other POSIX threads functions are guaranteed not to be +cancellation points. That is, they never perform cancellation in +deferred cancellation mode. +</P> +<P><B>pthread_testcancel</B> does nothing except testing for pending +cancellation and executing it. Its purpose is to introduce explicit +checks for cancellation in long sequences of code that do not call +cancellation point functions otherwise. +</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P><B>pthread_cancel</B>, <B>pthread_setcancelstate</B> and +<B>pthread_setcanceltype</B> return 0 on success and a non-zero error +code on error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P><B>pthread_cancel</B> returns the following error code on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>ESRCH</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + no thread could be found corresponding to that specified by the + <I>thread</I> ID. + </DD></DL> +</DL> +<P> +<B>pthread_setcancelstate</B> returns the following error code on +error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the <I>state</I> argument is not + </DD></DL> +</DL> +<BLOCKQUOTE> +<B>PTHREAD_CANCEL_ENABLE</B> nor <B>PTHREAD_CANCEL_DISABLE</B> +</BLOCKQUOTE> +<P><B>pthread_setcanceltype</B> returns the following error code on +error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the <I>type</I> argument is not + </DD></DL> +</DL> +<BLOCKQUOTE> +<B>PTHREAD_CANCEL_DEFERRED</B> nor <B>PTHREAD_CANCEL_ASYNCHRONOUS</B> +</BLOCKQUOTE> +<H2><A HREF="#toc5" NAME="sect5">Author</A></H2> +<P>Xavier Leroy <Xavier.Leroy@inria.fr> +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<H2><A HREF="#toc6" NAME="sect6">See Also</A></H2> +<P><A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> , +<A HREF="pthread_cleanup_push.html"><B>pthread_cleanup_push</B>(3)</A> +, <A HREF="pthread_cleanup_pop.html"><B>pthread_cleanup_pop</B>(3)</A> +, Pthreads-w32 package README file 'Prerequisites' section. +</P> +<H2><A HREF="#toc7" NAME="sect7">Bugs</A></H2> +<P>POSIX specifies that a number of system calls (basically, all +system calls that may block, such as <A HREF="read.html"><B>read</B>(2)</A> +, <A HREF="write.html"><B>write</B>(2)</A> , <A HREF="wait.html"><B>wait</B>(2)</A> +, etc.) and library functions that may call these system calls (e.g. +<A HREF="fprintf.html"><B>fprintf</B>(3)</A> ) are cancellation +points. <B>Pthreads-win32</B> is not integrated enough with the C +library to implement this, and thus none of the C library functions +is a cancellation point. +</P> +<P>A workaround for these calls is to temporarily switch to +asynchronous cancellation (assuming full asynchronous cancellation +support is installed). So, checking for cancellation during a <B>read</B> +system call, for instance, can be achieved as follows: +</P> +<BLOCKQUOTE><BR><BR> +</BLOCKQUOTE> +<PRE STYLE="margin-left: 1cm; margin-right: 1cm">pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldCancelType); +read(fd, buffer, length); +pthread_setcanceltype(oldCancelType, NULL);</PRE> +<HR> +<BLOCKQUOTE><A NAME="toc"></A><B>Table of Contents</B></BLOCKQUOTE> +<UL> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Author</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">See + Also</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE><A HREF="#sect7" NAME="toc7">Bugs</A> + </BLOCKQUOTE> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_setcanceltype.html b/manual/pthread_setcanceltype.html new file mode 100644 index 0000000..935ed82 --- /dev/null +++ b/manual/pthread_setcanceltype.html @@ -0,0 +1,207 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_CANCEL(3) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;12090500"> + <META NAME="CHANGED" CONTENT="20050504;16362800"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_cancel, pthread_setcancelstate, pthread_setcanceltype, +pthread_testcancel - thread cancellation +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>int pthread_cancel(pthread_t </B><I>thread</I><B>);</B> +</P> +<P><B>int pthread_setcancelstate(int </B><I>state</I><B>, int +*</B><I>oldstate</I><B>);</B> +</P> +<P><B>int pthread_setcanceltype(int </B><I>type</I><B>, int +*</B><I>oldtype</I><B>);</B> +</P> +<P><B>void pthread_testcancel(void);</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>Cancellation is the mechanism by which a thread can terminate the +execution of another thread. More precisely, a thread can send a +cancellation request to another thread. Depending on its settings, +the target thread can then either ignore the request, honor it +immediately, or defer it until it reaches a cancellation point. +</P> +<P>When a thread eventually honors a cancellation request, it +performs as if <B>pthread_exit(PTHREAD_CANCELED)</B> has been called +at that point: all cleanup handlers are executed in reverse order, +destructor functions for thread-specific data are called, and finally +the thread stops executing with the return value <B>PTHREAD_CANCELED</B>. +See <A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> for more +information. +</P> +<P><B>pthread_cancel</B> sends a cancellation request to the thread +denoted by the <I>thread</I> argument. +</P> +<P><B>pthread_setcancelstate</B> changes the cancellation state for +the calling thread -- that is, whether cancellation requests are +ignored or not. The <I>state</I> argument is the new cancellation +state: either <B>PTHREAD_CANCEL_ENABLE</B> to enable cancellation, or +<B>PTHREAD_CANCEL_DISABLE</B> to disable cancellation (cancellation +requests are ignored). If <I>oldstate</I> is not <B>NULL</B>, the +previous cancellation state is stored in the location pointed to by +<I>oldstate</I>, and can thus be restored later by another call to +<B>pthread_setcancelstate</B>. +</P> +<P><B>pthread_setcanceltype</B> changes the type of responses to +cancellation requests for the calling thread: asynchronous +(immediate) or deferred. The <I>type</I> argument is the new +cancellation type: either <B>PTHREAD_CANCEL_ASYNCHRONOUS</B> to +cancel the calling thread as soon as the cancellation request is +received, or <B>PTHREAD_CANCEL_DEFERRED</B> to keep the cancellation +request pending until the next cancellation point. If <I>oldtype</I> +is not <B>NULL</B>, the previous cancellation state is stored in the +location pointed to by <I>oldtype</I>, and can thus be restored later +by another call to <B>pthread_setcanceltype</B>. +</P> +<P><B>Pthreads-w32</B> provides two levels of support for +<B>PTHREAD_CANCEL_ASYNCHRONOUS</B>: full and partial. Full support +requires an additional DLL and driver be installed on the Windows +system (see the See Also section below) that allows blocked threads +to be cancelled immediately. Partial support means that the target +thread will not cancel until it resumes execution naturally. Partial +support is provided if either the DLL or the driver are not +automatically detected by the pthreads-w32 library at run-time.</P> +<P>Threads are always created by <A HREF="pthread_create.html"><B>pthread_create</B>(3)</A> +with cancellation enabled and deferred. That is, the initial +cancellation state is <B>PTHREAD_CANCEL_ENABLE</B> and the initial +type is <B>PTHREAD_CANCEL_DEFERRED</B>. +</P> +<P>Cancellation points are those points in the program execution +where a test for pending cancellation requests is performed and +cancellation is executed if positive. The following POSIX threads +functions are cancellation points: +</P> +<P><A HREF="pthread_join.html"><B>pthread_join</B>(3)</A> +<BR><A HREF="pthread_cond_wait.html"><B>pthread_cond_wait</B>(3)</A> +<BR><A HREF="pthread_cond_timedwait.html"><B>pthread_cond_timedwait</B>(3)</A> +<BR><A HREF="pthread_testcancel.html"><B>pthread_testcancel</B>(3)</A> +<BR><A HREF="sem_wait.html"><B>sem_wait</B>(3)</A> <BR><A HREF="sem_timedwait.html"><B>sem_timedwait</B>(3)</A> +<BR><A HREF="sigwait.html"><B>sigwait</B>(3)</A> (not supported under +<B>Pthreads-w32</B>)</P> +<P><B>Pthreads-w32</B> provides two functions to enable additional +cancellation points to be created in user functions that block on +Win32 HANDLEs:</P> +<P><A HREF="pthreadCancelableWait.html">pthreadCancelableWait()</A> +<BR><A HREF="pthreadCancelableTimedWait.html">pthreadCancelableTimedWait()</A></P> +<P>All other POSIX threads functions are guaranteed not to be +cancellation points. That is, they never perform cancellation in +deferred cancellation mode. +</P> +<P><B>pthread_testcancel</B> does nothing except testing for pending +cancellation and executing it. Its purpose is to introduce explicit +checks for cancellation in long sequences of code that do not call +cancellation point functions otherwise. +</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P><B>pthread_cancel</B>, <B>pthread_setcancelstate</B> and +<B>pthread_setcanceltype</B> return 0 on success and a non-zero error +code on error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P><B>pthread_cancel</B> returns the following error code on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>ESRCH</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + no thread could be found corresponding to that specified by the + <I>thread</I> ID. + </DD></DL> +</DL> +<P> +<B>pthread_setcancelstate</B> returns the following error code on +error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the <I>state</I> argument is not + </DD></DL> +</DL> +<BLOCKQUOTE> +<B>PTHREAD_CANCEL_ENABLE</B> nor <B>PTHREAD_CANCEL_DISABLE</B> +</BLOCKQUOTE> +<P><B>pthread_setcanceltype</B> returns the following error code on +error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the <I>type</I> argument is not + </DD></DL> +</DL> +<BLOCKQUOTE> +<B>PTHREAD_CANCEL_DEFERRED</B> nor <B>PTHREAD_CANCEL_ASYNCHRONOUS</B> +</BLOCKQUOTE> +<H2><A HREF="#toc5" NAME="sect5">Author</A></H2> +<P>Xavier Leroy <Xavier.Leroy@inria.fr> +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<H2><A HREF="#toc6" NAME="sect6">See Also</A></H2> +<P><A HREF="pthread_exit.html"><B>pthread_exit</B>(3)</A> , +<A HREF="pthread_cleanup_push.html"><B>pthread_cleanup_push</B>(3)</A> +, <A HREF="pthread_cleanup_pop.html"><B>pthread_cleanup_pop</B>(3)</A> +, Pthreads-w32 package README file 'Prerequisites' section. +</P> +<H2><A HREF="#toc7" NAME="sect7">Bugs</A></H2> +<P>POSIX specifies that a number of system calls (basically, all +system calls that may block, such as <A HREF="read.html"><B>read</B>(2)</A> +, <A HREF="write.html"><B>write</B>(2)</A> , <A HREF="wait.html"><B>wait</B>(2)</A> +, etc.) and library functions that may call these system calls (e.g. +<A HREF="fprintf.html"><B>fprintf</B>(3)</A> ) are cancellation +points. <B>Pthreads-win32</B> is not integrated enough with the C +library to implement this, and thus none of the C library functions +is a cancellation point. +</P> +<P>A workaround for these calls is to temporarily switch to +asynchronous cancellation (assuming full asynchronous cancellation +support is installed). So, checking for cancellation during a <B>read</B> +system call, for instance, can be achieved as follows: +</P> +<BLOCKQUOTE><BR><BR> +</BLOCKQUOTE> +<PRE STYLE="margin-left: 1cm; margin-right: 1cm">pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldCancelType); +read(fd, buffer, length); +pthread_setcanceltype(oldCancelType, NULL);</PRE> +<HR> +<BLOCKQUOTE><A NAME="toc"></A><B>Table of Contents</B></BLOCKQUOTE> +<UL> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Author</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">See + Also</A> + </BLOCKQUOTE> + <LI><BLOCKQUOTE><A HREF="#sect7" NAME="toc7">Bugs</A> + </BLOCKQUOTE> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_setconcurrency.html b/manual/pthread_setconcurrency.html new file mode 100644 index 0000000..cdd4f58 --- /dev/null +++ b/manual/pthread_setconcurrency.html @@ -0,0 +1,155 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"PTHREAD_GETCONCURRENCY"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;19162600"> + <META NAME="CHANGED" CONTENT="20050505;19223800"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_getconcurrency, pthread_setconcurrency - get and set the +level of concurrency +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h> </B> +</P> +<P><B>int pthread_getconcurrency(void);</B> <BR><B>int +pthread_setconcurrency(int</B> <I>new_level</I><B>); </B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>Unbound threads in a process may or may not be required to be +simultaneously active. By default, the threads implementation ensures +that a sufficient number of threads are active so that the process +can continue to make progress. While this conserves system resources, +it may not produce the most effective level of concurrency. +</P> +<P>The <B>pthread_setconcurrency</B> function allows an application +to inform the threads implementation of its desired concurrency +level, <I>new_level</I>. The actual level of concurrency provided by +the implementation as a result of this function call is unspecified. +</P> +<P>If <I>new_level</I> is zero, it causes the implementation to +maintain the concurrency level at its discretion as if +<B>pthread_setconcurrency</B> had never been called. +</P> +<P>The <B>pthread_getconcurrency</B> function shall return the value +set by a previous call to the <B>pthread_setconcurrency</B> function. +If the <B>pthread_setconcurrency</B> function was not previously +called, this function shall return zero to indicate that the +implementation is maintaining the concurrency level. +</P> +<P>A call to <B>pthread_setconcurrency</B> shall inform the +implementation of its desired concurrency level. The implementation +shall use this as a hint, not a requirement. +</P> +<P>If an implementation does not support multiplexing of user threads +on top of several kernel-scheduled entities, the +<B>pthread_setconcurrency</B> and <B>pthread_getconcurrency</B> +functions are provided for source code compatibility but they shall +have no effect when called. To maintain the function semantics, the +<I>new_level</I> parameter is saved when <B>pthread_setconcurrency</B> +is called so that a subsequent call to <B>pthread_getconcurrency</B> +shall return the same value. +</P> +<P><B>Pthreads-w32</B> provides these routines for source code +compatibility only, as described in the previous paragraph.</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>If successful, the <B>pthread_setconcurrency</B> function shall +return zero; otherwise, an error number shall be returned to indicate +the error. +</P> +<P>The <B>pthread_getconcurrency</B> function shall always return the +concurrency level set by a previous call to <B>pthread_setconcurrency</B> +. If the <B>pthread_setconcurrency</B> function has never been +called, <B>pthread_getconcurrency</B> shall return zero. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>The <B>pthread_setconcurrency</B> function shall fail if: +</P> +<DL> + <DT><B>EINVAL</B> + </DT><DD> + The value specified by <I>new_level</I> is negative. + </DD><DT> + <B>EAGAIN</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The value specific by <I>new_level</I> would cause a system resource + to be exceeded. + </DD></DL> +<P> +These functions shall not return an error code of [EINTR]. +</P> +<P><I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P>Use of these functions changes the state of the underlying +concurrency upon which the application depends. Library developers +are advised to not use the <B>pthread_getconcurrency</B> and +<B>pthread_setconcurrency</B> functions since their use may conflict +with an applications use of these functions. +</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P>The Base Definitions volume of IEEE Std 1003.1-2001, +<I><pthread.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_setschedparam.html b/manual/pthread_setschedparam.html new file mode 100644 index 0000000..510ddf9 --- /dev/null +++ b/manual/pthread_setschedparam.html @@ -0,0 +1,115 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_SETSCHEDPARAM(3) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050504;18110100"> + <META NAME="CHANGED" CONTENT="20050504;18212800"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_setschedparam, pthread_getschedparam - control thread +scheduling +</P> +<P>parameters +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>int pthread_setschedparam(pthread_t </B><I>target_thread</I><B>, +int </B><I>policy</I><B>, const struct sched_param *</B><I>param</I><B>);</B> +</P> +<P><B>int pthread_getschedparam(pthread_t </B><I>target_thread</I><B>, +int *</B><I>policy</I><B>, struct sched_param *</B><I>param</I><B>);</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P><B>pthread_setschedparam</B> sets the scheduling parameters for +the thread <I>target_thread</I> as indicated by <I>policy</I> and +<I>param</I>. <I>policy</I> can be either <B>SCHED_OTHER</B> +(regular, non-real-time scheduling), <B>SCHED_RR</B> (real-time, +round-robin) or <B>SCHED_FIFO</B> (real-time, first-in first-out). +<I>param</I> specifies the scheduling priority for the two real-time +policies. See <A HREF="sched_setpolicy.html"><B>sched_setpolicy</B>(2)</A> +for more information on scheduling policies. +</P> +<P><B>Pthreads-w32</B> only supports SCHED_OTHER and does not support +the real-time scheduling policies <B>SCHED_RR</B> and <B>SCHED_FIFO.</B> +</P> +<P><B>pthread_getschedparam</B> retrieves the scheduling policy and +scheduling parameters for the thread <I>target_thread</I> and stores +them in the locations pointed to by <I>policy</I> and <I>param</I>, +respectively. +</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P><B>pthread_setschedparam</B> and <B>pthread_getschedparam</B> +return 0 on success and a non-zero error code on error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>On error, <B>pthread_setschedparam</B> returns the following error +codes: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>ENOTSUP</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + <I>policy</I> is not <B>SCHED_OTHER.</B></DD><DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + <B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + One of the arguments is invalid, or the priority value specified by + <I>param</I> is not valid for the specified policy.</DD><DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + <B>ESRCH</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + The <I>target_thread</I> is invalid or has already terminated + </DD></DL> +</DL> +<P> +On error, <B>pthread_getschedparam</B> returns the following error +codes: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>ESRCH</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + the <I>target_thread</I> is invalid or has already terminated + </DD></DL> +</DL> +<H2> +<A HREF="#toc5" NAME="sect5">Author</A></H2> +<P>Xavier Leroy <Xavier.Leroy@inria.fr> +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<H2><A HREF="#toc6" NAME="sect6">See Also</A></H2> +<P><A HREF="sched_setscheduler.html"><B>sched_setscheduler</B>(2)</A> +, <A HREF="sched_getscheduler.html"><B>sched_getscheduler</B>(2)</A> +, <A HREF="sched_getparam.html"><B>sched_getparam</B>(2)</A> , +<A HREF="pthread_attr_setschedpolicy.html"><B>pthread_attr_setschedpolicy</B>(3)</A> +, <A HREF="pthread_attr_setschedparam.html"><B>pthread_attr_setschedparam</B>(3)</A> +. +</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Author</A> + </P> + <LI><P><A HREF="#sect6" NAME="toc6">See Also</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_spin_init.html b/manual/pthread_spin_init.html new file mode 100644 index 0000000..35e657b --- /dev/null +++ b/manual/pthread_spin_init.html @@ -0,0 +1,176 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"PTHREAD_SPIN_DESTROY"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;12074100"> + <META NAME="CHANGED" CONTENT="20050505;19014200"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_spin_destroy, pthread_spin_init - destroy or initialize a +spin lock object (<B>ADVANCED REALTIME THREADS</B>) +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h> </B> +</P> +<P><B>pthread_spinlock_t</B> <I>lock</I> <B>= +PTHREAD_SPINLOCK_INITIALIZER;</B></P> +<P><B>int pthread_spin_destroy(pthread_spinlock_t *</B><I>lock</I><B>); +<BR>int pthread_spin_init(pthread_spinlock_t *</B><I>lock</I><B>, int</B> +<I>pshared</I><B>); </B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>pthread_spin_destroy</B> function shall destroy the spin +lock referenced by <I>lock</I> and release any resources used by the +lock. The effect of subsequent use of the lock is undefined until the +lock is reinitialized by another call to <B>pthread_spin_init</B> . +The results are undefined if <B>pthread_spin_destroy</B> is called +when a thread holds the lock, or if this function is called with an +uninitialized thread spin lock. +</P> +<P>The <B>pthread_spin_init</B> function shall allocate any resources +required to use the spin lock referenced by <I>lock</I> and +initialize the lock to an unlocked state. +</P> +<P><B>Pthreads-w32</B> supports single and multiple processor systems +as well as process CPU affinity masking by checking the mask when the +spin lock is initialized. If the process is using only a single +processor at the time <B>pthread_spin_init</B> is called then the +spin lock is initialized as a PTHREAD_MUTEX_NORMAL mutex object. A +thread that calls <A HREF="pthread_spin_lock.html"><B>pthread_spin_lock(3)</B></A> +will block rather than spin in this case. If the process CPU affinity +mask is altered after the spin lock has been initialised, the spin +lock is not modified, and may no longer be optimal for the number of +CPUs available.</P> +<P><B>Pthreads-w32</B> defines <B>_POSIX_THREAD_PROCESS_SHARED</B> in +pthread.h as -1 to indicate that these routines do not support the +<B>PTHREAD_PROCESS_SHARED</B> attribute. <B>pthread_spin_init</B> +will return the error <B>ENOTSUP</B> if the value of <I>pshared</I> +is not <B>PTHREAD_PROCESS_PRIVATE</B>.</P> +<P>The results are undefined if <B>pthread_spin_init</B> is called +specifying an already initialized spin lock. The results are +undefined if a spin lock is used without first being initialized. +</P> +<P>If the <B>pthread_spin_init</B> function fails, the lock is not +initialized and the contents of <I>lock</I> are undefined. +</P> +<P>Only the object referenced by <I>lock</I> may be used for +performing synchronization. +</P> +<P>The result of referring to copies of that object in calls to +<B>pthread_spin_destroy</B> , <A HREF="pthread_spin_lock.html"><B>pthread_spin_lock</B>(3)</A> +, <A HREF="pthread_spin_lock.html"><B>pthread_spin_trylock</B>(3)</A>, +or <A HREF="pthread_spin_unlock.html"><B>pthread_spin_unlock</B>(3)</A> +is undefined. +</P> +<P><B>Pthreads-w32</B> supports statically initialized spin locks +using <B>PTHREAD_SPINLOCK_INITIALIZER</B>. An application should +still call <B>pthread_spin_destroy</B> at some point to ensure that +any resources consumed by the spin lock are released.</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>Upon successful completion, these functions shall return zero; +otherwise, an error number shall be returned to indicate the error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>These functions may fail if: +</P> +<DL> + <DT><B>EBUSY</B> + </DT><DD> + The implementation has detected an attempt to initialize or destroy + a spin lock while it is in use (for example, while being used in a + <A HREF="pthread_spin_lock.html"><B>pthread_spin_lock</B>(3)</A> + call) by another thread. + </DD><DT> + <B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The value specified by <I>lock</I> is invalid. + </DD></DL> +<P> +The <B>pthread_spin_init</B> function shall fail if: +</P> +<DL> + <DT><B>ENOTSUP</B> + </DT><DD> + The value of <I>pshared</I> is not <B>PTHREAD_PROCESS_PRIVATE</B>.</DD><DT> + <B>ENOMEM</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + Insufficient memory exists to initialize the lock. + </DD></DL> +<P> +These functions shall not return an error code of [EINTR]. +</P> +<P><I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P>The <B>pthread_spin_destroy</B> and <B>pthread_spin_init</B> +functions are part of the Spin Locks option and need not be provided +on all implementations. +</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P><A HREF="pthread_spin_lock.html"><B>pthread_spin_lock</B>(3)</A> <B>,</B> +<A HREF="pthread_spin_unlock.html"><B>pthread_spin_unlock</B>(3)</A> +<B>,</B> the Base Definitions volume of IEEE Std 1003.1-2001, +<I><pthread.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_spin_lock.html b/manual/pthread_spin_lock.html new file mode 100644 index 0000000..dd180ae --- /dev/null +++ b/manual/pthread_spin_lock.html @@ -0,0 +1,141 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"PTHREAD_SPIN_LOCK"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;12202300"> + <META NAME="CHANGED" CONTENT="20050505;19302300"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_spin_lock, pthread_spin_trylock - lock a spin lock object +(<B>ADVANCED REALTIME THREADS</B>) +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h> </B> +</P> +<P><B>int pthread_spin_lock(pthread_spinlock_t *</B><I>lock</I><B>); +<BR>int pthread_spin_trylock(pthread_spinlock_t *</B><I>lock</I><B>); +</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>pthread_spin_lock</B> function shall lock the spin lock +referenced by <I>lock</I>. The calling thread shall acquire the lock +if it is not held by another thread. Otherwise, the thread shall spin +(that is, shall not return from the <B>pthread_spin_lock</B> call) +until the lock becomes available. The results are undefined if the +calling thread holds the lock at the time the call is made.</P> +<P><B>Pthreads-w32</B> supports single and multiple processor systems +as well as process CPU affinity masking by checking the mask when the +spin lock is initialized. If the process is using only a single +processor at the time <A HREF="pthread_spin_init.html"><B>pthread_spin_init</B>(3)</A> +is called then the spin lock is initialized as a PTHREAD_MUTEX_NORMAL +mutex object. A thread that calls <B>pthread_spin_lock</B> will block +rather than spin in this case. If the process CPU affinity mask is +altered after the spin lock has been initialised, the spin lock is +not modified, and may no longer be optimal for the number of CPUs +available.</P> +<P>The <B>pthread_spin_trylock</B> function shall lock the spin lock +referenced by <I>lock</I> if it is not held by any thread. Otherwise, +the function shall fail. +</P> +<P>The results are undefined if any of these functions is called with +an uninitialized spin lock. +</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>Upon successful completion, these functions shall return zero; +otherwise, an error number shall be returned to indicate the error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>These functions may fail if: +</P> +<DL> + <DT><B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The value specified by <I>lock</I> does not refer to an initialized + spin lock object. + </DD></DL> +<P> +The <B>pthread_spin_trylock</B> function shall fail if: +</P> +<DL> + <DT><B>EBUSY</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + A thread currently holds the lock. + </DD></DL> +<P> +These functions shall not return an error code of [EINTR]. +</P> +<P><I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P>Applications using this function may be subject to priority +inversion, as discussed in the Base Definitions volume of +IEEE Std 1003.1-2001, Section 3.285, Priority Inversion. +</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P><A HREF="pthread_spin_init.html"><B>pthread_spin_destroy</B>(3)</A> +<B>,</B> <A HREF="pthread_spin_unlock.html"><B>pthread_spin_unlock</B>(3)</A> +<B>,</B> the Base Definitions volume of IEEE Std 1003.1-2001, +<I><pthread.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_spin_unlock.html b/manual/pthread_spin_unlock.html new file mode 100644 index 0000000..2215700 --- /dev/null +++ b/manual/pthread_spin_unlock.html @@ -0,0 +1,124 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"PTHREAD_SPIN_UNLOCK"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;12401400"> + <META NAME="CHANGED" CONTENT="20050505;12462400"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>pthread_spin_unlock - unlock a spin lock object (<B>ADVANCED +REALTIME THREADS</B>) +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h> </B> +</P> +<P><B>int pthread_spin_unlock(pthread_spinlock_t *</B><I>lock</I><B>); +</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>pthread_spin_unlock</B> function shall release the spin +lock referenced by <I>lock</I> which was locked via the +<A HREF="pthread_spin_lock.html"><B>pthread_spin_lock</B>(3)</A> or +<A HREF="pthread_spin_lock.html"><B>pthread_spin_trylock</B>(3)</A> +functions. If there are threads spinning on the lock when +<B>pthread_spin_unlock</B> is called, the lock becomes available and +an unspecified spinning thread shall acquire the lock. +</P> +<P><B>Pthreads-w32</B> does not check ownership of the lock and it is +therefore possible for a thread other than the locker to unlock the +spin lock. This is not a feature that should be exploited.</P> +<P>The results are undefined if this function is called with an +uninitialized thread spin lock. +</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>Upon successful completion, the <B>pthread_spin_unlock</B> +function shall return zero; otherwise, an error number shall be +returned to indicate the error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>The <B>pthread_spin_unlock</B> function may fail if: +</P> +<DL> + <DT><B>EINVAL</B> + </DT><DD> + An invalid argument was specified. + </DD><DD STYLE="margin-left: -2cm"> + <BR> + </DD></DL> +<P> +This function shall not return an error code of [EINTR]. +</P> +<P><I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P><B>Pthreads-w32</B> does not check ownership of the lock and it is +therefore possible for a thread other than the locker to unlock the +spin lock. This is not a feature that should be exploited.</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P><A HREF="pthread_spin_init.html"><B>pthread_spin_destroy</B>(3)</A> +<B>,</B> <A HREF="pthread_spin_lock.html"><B>pthread_spin_lock</B>(3)</A> +<B>,</B> the Base Definitions volume of IEEE Std 1003.1-2001, +<I><pthread.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_timechange_handler_np.html b/manual/pthread_timechange_handler_np.html new file mode 100644 index 0000000..54226da --- /dev/null +++ b/manual/pthread_timechange_handler_np.html @@ -0,0 +1,76 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_TIMECHANGE_HANDLER_NP manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;322600"> + <META NAME="CHANGED" CONTENT="20050505;22110600"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P STYLE="font-weight: medium">pthread_timechange_handler_np – +alert timed waiting condition variables to system time changes.</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>void * pthread_timechange_handler_np(void * </B><I>dummy</I><B>);</B></P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>To improve tolerance against operator or time service initiated +system clock changes.</P> +<P><B>pthread_timechange_handler_np </B>can be called by an +application when it receives a WM_TIMECHANGE message from the system. +At present it broadcasts all condition variables so that waiting +threads can wake up and re-evaluate their conditions and restart +their timed waits if required.</P> +<P><B>pthread_timechange_handler_np </B>has the same return type and +argument type as a thread routine so that it may be called directly +through pthread_create(), i.e. as a separate thread. If run as a +thread, the return code must be retrieved through <A HREF="pthread_join.html"><B>pthread_join</B>()</A>.</P> +<P>Although the <I>dummy</I> parameter is required it is not used and +any value including NULL can be given.</P> +<H2><A HREF="#toc3" NAME="sect3">Cancellation</A></H2> +<P>None.</P> +<H2><A HREF="#toc4" NAME="sect4"><FONT COLOR="#000080">Return Value</FONT></A></H2> +<P><B>pthread_timechange_handler_np</B> returns 0 on success, or an +error code.</P> +<H2><A HREF="#toc5" NAME="sect5">Errors</A></H2> +<P>The <B>pthread_timechange_handler_np</B> function returns the +following error code on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EAGAIN</B> + </DT></DL> +</DL> +<P STYLE="margin-left: 2cm; margin-bottom: 0cm"> +To indicate that not all condition variables were signalled for some +reason.</P> +<H2><A HREF="#toc6" NAME="sect6">Author</A></H2> +<P>Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Cancellation</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Errors</A> + </P> + <LI><P><A HREF="#sect6" NAME="toc6">Author</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_win32_attach_detach_np.html b/manual/pthread_win32_attach_detach_np.html new file mode 100644 index 0000000..57f0339 --- /dev/null +++ b/manual/pthread_win32_attach_detach_np.html @@ -0,0 +1,74 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_WIN32_ATTACH_DETACH_NP manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;322600"> + <META NAME="CHANGED" CONTENT="20050505;22415600"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P STYLE="font-weight: medium">pthread_win32_process_attach_np, +pthread_win32_process_detach_np, pthread_win32_thread_attach_np, +pthread_win32_thread_detach_np – exposed versions of the +pthreads-w32 DLL dllMain() switch functionality for use when +statically linking the library.</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>BOOL pthread_win32_process_attach_np (void);</B></P> +<P><B>BOOL pthread_win32_process_detach_np (void);</B></P> +<P><B>BOOL pthread_win32_thread_attach_np (void);</B></P> +<P><B>BOOL pthread_win32_thread_detach_np (void);</B></P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>These functions contain the code normally run via <B>dllMain</B> +when the library is used as a dll but which need to be called +explicitly by an application when the library is statically linked.</P> +<P>You will need to call <B>pthread_win32_process_attach_np</B> +before you can call any pthread routines when statically linking. You +should call <B>pthread_win32_process_detach_np</B> before exiting +your application to clean up.</P> +<P><B>pthread_win32_thread_attach_np</B> is currently a no-op, but +<B>pthread_win32_thread_detach_np</B> is needed to clean up the +implicit pthread handle that is allocated to a Win32 thread if it +calls certain pthreads routines. Call this routine when the Win32 +thread exits.</P> +<P>These functions invariably return TRUE except for +<B>pthread_win32_process_attach_np</B> which will return FALSE if +pthreads-w32 initialisation fails.</P> +<H2><A HREF="#toc3" NAME="sect3">Cancellation</A></H2> +<P>None.</P> +<H2><A HREF="#toc4" NAME="sect4"><FONT COLOR="#000080">Return Value</FONT></A></H2> +<P>These routines return TRUE (non-zero) on success, or FALSE (0) if +they fail.</P> +<H2><A HREF="#toc5" NAME="sect5">Errors</A></H2> +<P>None.</P> +<H2><A HREF="#toc6" NAME="sect6">Author</A></H2> +<P>Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Cancellation</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Errors</A> + </P> + <LI><P><A HREF="#sect6" NAME="toc6">Author</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/pthread_win32_test_features_np.html b/manual/pthread_win32_test_features_np.html new file mode 100644 index 0000000..908bb77 --- /dev/null +++ b/manual/pthread_win32_test_features_np.html @@ -0,0 +1,72 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>PTHREAD_WIN32_TEST_FEATURES_NP manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;322600"> + <META NAME="CHANGED" CONTENT="20050505;22310200"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P STYLE="font-weight: medium">pthread_win32_test_features_np – +find out what features were detected at process attach time.</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <pthread.h></B> +</P> +<P><B>BOOL pthread_win32_test_features_np(int</B> <I>mask</I><B>);</B></P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P><B>pthread_win32_test_features_np</B> allows an application to +check which run-time auto-detected features are available within the +library.</P> +<P>The possible features are:</P> +<P><B>PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE</B></P> +<P STYLE="margin-left: 2cm">Return TRUE if the Win32 version of +InterlockedCompareExchange() is being used. On IA32 systems the +library can use optimised and inlinable assembler versions of +InterlockedExchange() and InterlockedCompareExchange().</P> +<P><B>PTW32_ALERTABLE_ASYNC_CANCEL</B></P> +<P STYLE="margin-left: 2cm">Return TRUE if the QueueUserAPCEx package +QUSEREX.DLL and the AlertDrv.sys driver was detected. This package +provides alertable (pre-emptive) asynchronous threads cancellation. +If this feature returns FALSE then the default async cancel scheme +is in use, which cannot cancel blocked threads.</P> +<P>Features may be OR'ed into the mask parameter, in which case the +routine returns TRUE if any of the OR'ed features would +return TRUE. At this stage it doesn't make sense to OR features but +it may some day.</P> +<H2><A HREF="#toc3" NAME="sect3">Cancellation</A></H2> +<P>None.</P> +<H2><A HREF="#toc4" NAME="sect4"><FONT COLOR="#000080">Return Value</FONT></A></H2> +<P><B>pthread_win32_test_features_np</B> returns TRUE (non-zero) if +any of the specified features is present, and FALSE (0) otherwise.</P> +<H2><A HREF="#toc5" NAME="sect5">Errors</A></H2> +<P>None.</P> +<H2><A HREF="#toc6" NAME="sect6">Author</A></H2> +<P>Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Cancellation</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Errors</A> + </P> + <LI><P><A HREF="#sect6" NAME="toc6">Author</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/sched_get_priority_max.html b/manual/sched_get_priority_max.html new file mode 100644 index 0000000..30e00eb --- /dev/null +++ b/manual/sched_get_priority_max.html @@ -0,0 +1,118 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"SCHED_GET_PRIORITY_MAX"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;12575100"> + <META NAME="CHANGED" CONTENT="20050505;13005500"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>sched_get_priority_max, sched_get_priority_min - get priority +limits (<B>REALTIME</B>) +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <sched.h> </B> +</P> +<P><B>int sched_get_priority_max(int</B> <I>policy</I><B>); <BR>int +sched_get_priority_min(int</B> <I>policy</I><B>); </B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>sched_get_priority_max</B> and <B>sched_get_priority_min</B> +functions shall return the appropriate maximum or minimum, +respectively, for the scheduling policy specified by <I>policy</I>. +</P> +<P>The value of <I>policy</I> shall be one of the scheduling policy +values defined in <I><sched.h></I>. +</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>If successful, the <B>sched_get_priority_max</B> and +<B>sched_get_priority_min</B> functions shall return the appropriate +maximum or minimum values, respectively. If unsuccessful, they shall +return a value of -1 and set <I>errno</I> to indicate the error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>The <B>sched_get_priority_max</B> and <B>sched_get_priority_min</B> +functions shall fail if: +</P> +<DL> + <DT><B>EINVAL</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + The value of the <I>policy</I> parameter does not represent a + defined scheduling policy. + </DD></DL> +<P> +<I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P>None. +</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P><A HREF="sched_getparam.html"><B>sched_getparam</B>(3)</A> <B>,</B> +<A HREF="sched_setparam.html"><B>sched_setparam</B>(3)</A> <B>,</B> +<A HREF="sched_getscheduler.html"><B>sched_getscheduler</B>(3)</A> <B>,</B> +<A HREF="sched_rr_get_interval.html"><B>sched_rr_get_interval</B>(3)</A> +<B>,</B> <A HREF="sched_setscheduler.html"><B>sched_setscheduler</B>(3)</A> +<B>,</B> the Base Definitions volume of IEEE Std 1003.1-2001, +<I><sched.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/sched_getscheduler.html b/manual/sched_getscheduler.html new file mode 100644 index 0000000..0089e24 --- /dev/null +++ b/manual/sched_getscheduler.html @@ -0,0 +1,127 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"SCHED_GETSCHEDULER"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;13153500"> + <META NAME="CHANGED" CONTENT="20050505;13202000"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>sched_getscheduler - get scheduling policy (<B>REALTIME</B>) +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <sched.h> </B> +</P> +<P><B>int sched_getscheduler(pid_t</B> <I>pid</I><B>); </B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>sched_getscheduler</B> function shall return the scheduling +policy of the process specified by <I>pid</I>. If the value of <I>pid</I> +is negative, the behavior of the <B>sched_getscheduler</B> function +is unspecified. +</P> +<P>The values that can be returned by <B>sched_getscheduler</B> are +defined in the <I><sched.h></I> header. +</P> +<P><B>Pthreads-w32</B> only supports the <B>SCHED_OTHER</B> policy, +which is the only value that can be returned. However, checks on <I>pid</I> +and permissions are performed first so that the other useful side +effects of this routine are retained.</P> +<P>If a process specified by <I>pid</I> exists, and if the calling +process has permission, the scheduling policy shall be returned for +the process whose process ID is equal to <I>pid</I>. +</P> +<P>If <I>pid</I> is zero, the scheduling policy shall be returned for +the calling process. +</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>Upon successful completion, the <B>sched_getscheduler</B> function +shall return the scheduling policy of the specified process. If +unsuccessful, the function shall return -1 and set <I>errno</I> to +indicate the error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>The <B>sched_getscheduler</B> function shall fail if: +</P> +<DL> + <DT><B>EPERM</B> + </DT><DD> + The requesting process does not have permission to determine the + scheduling policy of the specified process. + </DD><DT> + <B>ESRCH</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + No process can be found corresponding to that specified by <I>pid</I>. + </DD></DL> +<P> +<I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P>None. +</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P><A HREF="sched_setscheduler.html"><B>sched_setscheduler</B>(3)</A> +, the Base Definitions volume of IEEE Std 1003.1-2001, +<I><sched.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/sched_setscheduler.html b/manual/sched_setscheduler.html new file mode 100644 index 0000000..c6e62ae --- /dev/null +++ b/manual/sched_setscheduler.html @@ -0,0 +1,181 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"SCHED_SETSCHEDULER"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;13012200"> + <META NAME="CHANGED" CONTENT="20050505;13193700"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>sched_setscheduler - set scheduling policy and parameters +(<B>REALTIME</B>) +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <sched.h> </B> +</P> +<P><B>int sched_setscheduler(pid_t</B> <I>pid</I><B>, int</B> <I>policy</I><B>, +const struct sched_param *</B><I>param</I><B>); </B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>sched_setscheduler</B> function shall set the scheduling +policy and scheduling parameters of the process specified by <I>pid</I> +to <I>policy</I> and the parameters specified in the <B>sched_param</B> +structure pointed to by <I>param</I>, respectively. The value of the +<I>sched_priority</I> member in the <B>sched_param</B> structure +shall be any integer within the inclusive priority range for the +scheduling policy specified by <I>policy</I>. If the value of <I>pid</I> +is negative, the behavior of the <B>sched_setscheduler</B> function +is unspecified. +</P> +<P>The possible values for the <I>policy</I> parameter are defined in +the <I><sched.h></I> header. +</P> +<P><B>Pthreads-w32</B> only supports the <B>SCHED_OTHER</B> policy. +Any other value for <I>policy</I> will return failure with errno set +to <B>ENOSYS</B>. However, checks on <I>pid</I> and permissions are +performed first so that the other useful side effects of this routine +are retained.</P> +<P>If a process specified by <I>pid</I> exists, and if the calling +process has permission, the scheduling policy and scheduling +parameters shall be set for the process whose process ID is equal to +<I>pid</I>. +</P> +<P>If <I>pid</I> is zero, the scheduling policy and scheduling +parameters shall be set for the calling process. +</P> +<P>Implementations may require that the requesting process have +permission to set its own scheduling parameters or those of another +process. Additionally, implementation-defined restrictions may apply +as to the appropriate privileges required to set a process’ own +scheduling policy, or another process’ scheduling policy, to a +particular value. +</P> +<P>The <B>sched_setscheduler</B> function shall be considered +successful if it succeeds in setting the scheduling policy and +scheduling parameters of the process specified by <I>pid</I> to the +values specified by <I>policy</I> and the structure pointed to by +<I>param</I>, respectively. +</P> +<P>The effect of this function on individual threads is dependent on +the scheduling contention scope of the threads: +</P> +<DL> + <DT>* + </DT><DD STYLE="margin-bottom: 0.5cm"> + For threads with system scheduling contention scope, these functions + shall have no effect on their scheduling. + </DD><DT> + * + </DT><DD STYLE="margin-bottom: 0.5cm"> + For threads with process scheduling contention scope, the threads’ + scheduling policy and associated parameters shall not be affected. + However, the scheduling of these threads with respect to threads in + other processes may be dependent on the scheduling parameters of + their process, which are governed using these functions. + </DD></DL> +<P> +This function is not atomic with respect to other threads in the +process. Threads may continue to execute while this function call is +in the process of changing the scheduling policy and associated +scheduling parameters for the underlying kernel-scheduled entities +used by the process contention scope threads. +</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>Upon successful completion, the function shall return the former +scheduling policy of the specified process. If the <B>sched_setscheduler</B> +function fails to complete successfully, the policy and scheduling +parameters shall remain unchanged, and the function shall return a +value of -1 and set <I>errno</I> to indicate the error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>The <B>sched_setscheduler</B> function shall fail if: +</P> +<DL> + <DT><B>EINVAL</B> + </DT><DD> + The value of the <I>policy</I> parameter is invalid, or one or more + of the parameters contained in <I>param</I> is outside the valid + range for the specified scheduling policy. + </DD><DT> + <B>EPERM</B> + </DT><DD> + The requesting process does not have permission to set either or + both of the scheduling parameters or the scheduling policy of the + specified process. + </DD><DT> + <B>ESRCH</B> + </DT><DD STYLE="margin-bottom: 0.5cm"> + No process can be found corresponding to that specified by <I>pid</I>. + </DD></DL> +<P> +<I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P>None. +</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P><A HREF="sched_getscheduler.html"><B>sched_getscheduler</B>(3)</A> +<B>,</B> the Base Definitions volume of IEEE Std 1003.1-2001, +<I><sched.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/sched_yield.html b/manual/sched_yield.html new file mode 100644 index 0000000..fa5ed04 --- /dev/null +++ b/manual/sched_yield.html @@ -0,0 +1,98 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>"SCHED_YIELD"(P) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;14034600"> + <META NAME="CHANGED" CONTENT="20050505;14050300"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>sched_yield - yield the processor +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <sched.h> </B> +</P> +<P><B>int sched_yield(void);</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>The <B>sched_yield</B> function shall force the running thread to +relinquish the processor until it again becomes the head of its +thread list. It takes no arguments. +</P> +<H2><A HREF="#toc3" NAME="sect3">Return Value</A></H2> +<P>The <B>sched_yield</B> function shall return 0 if it completes +successfully; otherwise, it shall return a value of -1 and set <I>errno</I> +to indicate the error. +</P> +<H2><A HREF="#toc4" NAME="sect4">Errors</A></H2> +<P>No errors are defined. +</P> +<P><I>The following sections are informative.</I> +</P> +<H2><A HREF="#toc5" NAME="sect5">Examples</A></H2> +<P>None. +</P> +<H2><A HREF="#toc6" NAME="sect6">Application Usage</A></H2> +<P>None. +</P> +<H2><A HREF="#toc7" NAME="sect7">Rationale</A></H2> +<P>None. +</P> +<H2><A HREF="#toc8" NAME="sect8">Future Directions</A></H2> +<P>None. +</P> +<H2><A HREF="#toc9" NAME="sect9">See Also</A></H2> +<P>The Base Definitions volume of IEEE Std 1003.1-2001, +<I><sched.h></I> +</P> +<H2><A HREF="#toc10" NAME="sect10">Copyright</A></H2> +<P>Portions of this text are reprinted and reproduced in electronic +form from IEEE Std 1003.1, 2003 Edition, Standard for Information +Technology -- Portable Operating System Interface (POSIX), The Open +Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the +Institute of Electrical and Electronics Engineers, Inc and The Open +Group. In the event of any discrepancy between this version and the +original IEEE and The Open Group Standard, the original IEEE and The +Open Group Standard is the referee document. The original Standard +can be obtained online at <A HREF="http://www.opengroup.org/unix/online.html">http://www.opengroup.org/unix/online.html</A> +. +</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Examples</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Application + Usage</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Rationale</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect8" NAME="toc8">Future + Directions</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect9" NAME="toc9">See + Also</A> + </P> + <LI><P><A HREF="#sect10" NAME="toc10">Copyright</A> + </P> +</UL> +</BODY> +</HTML> diff --git a/manual/sem_init.html b/manual/sem_init.html new file mode 100644 index 0000000..5509859 --- /dev/null +++ b/manual/sem_init.html @@ -0,0 +1,202 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<HTML> +<HEAD> + <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8"> + <TITLE>SEMAPHORES(3) manual page</TITLE> + <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1.3 (Linux)"> + <META NAME="CREATED" CONTENT="20050505;14061900"> + <META NAME="CHANGED" CONTENT="20050505;16344500"> + <!-- manual page source format generated by PolyglotMan v3.2, --> + <!-- available at http://polyglotman.sourceforge.net/ --> +</HEAD> +<BODY LANG="en-GB" BGCOLOR="#ffffff" DIR="LTR"> +<H4>POSIX Threads for Windows – REFERENCE - <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A></H4> +<P><A HREF="index.html">Reference Index</A></P> +<P><A HREF="#toc">Table of Contents</A></P> +<H2><A HREF="#toc0" NAME="sect0">Name</A></H2> +<P>sem_init, sem_wait, sem_trywait, sem_post, sem_getvalue, +sem_destroy - operations on semaphores +</P> +<H2><A HREF="#toc1" NAME="sect1">Synopsis</A></H2> +<P><B>#include <semaphore.h></B> +</P> +<P><B>int sem_init(sem_t *</B><I>sem</I><B>, int </B><I>pshared</I><B>, +unsigned int </B><I>value</I><B>);</B> +</P> +<P><B>int sem_wait(sem_t * </B><I>sem</I><B>);</B> +</P> +<P><B>int sem_timedwait(sem_t * </B><I>sem</I><SPAN STYLE="font-style: normal">, +<B>const struct timespec *</B></SPAN><I>abstime</I><B>);</B> +</P> +<P><B>int sem_trywait(sem_t * </B><I>sem</I><B>);</B> +</P> +<P><B>int sem_post(sem_t * </B><I>sem</I><B>);</B> +</P> +<P><B>int sem_post_multiple(sem_t * </B><I>sem, </I><SPAN STYLE="font-style: normal"><B>int</B> +</SPAN><I>number</I><B>);</B> +</P> +<P><B>int sem_getvalue(sem_t * </B><I>sem</I><B>, int * </B><I>sval</I><B>);</B> +</P> +<P><B>int sem_destroy(sem_t * </B><I>sem</I><B>);</B> +</P> +<H2><A HREF="#toc2" NAME="sect2">Description</A></H2> +<P>Semaphores are counters for resources shared between threads. The +basic operations on semaphores are: increment the counter atomically, +and wait until the counter is non-null and decrement it atomically. +</P> +<P><B>sem_init</B> initializes the semaphore object pointed to by +<I>sem</I>. The count associated with the semaphore is set initially +to <I>value</I>. The <I>pshared</I> argument indicates whether the +semaphore is local to the current process ( <I>pshared</I> is zero) +or is to be shared between several processes ( <I>pshared</I> is not +zero).</P> +<P><B>Pthreads-w32</B> currently does not support process-shared +semaphores, thus <B>sem_init</B> always returns with error <B>EPERM</B> +if <I>pshared</I> is not zero. +</P> +<P><B>sem_wait</B> atomically decrements <I>sem</I>'s count if it is +greater than 0 and returns immediately or it suspends the calling +thread until it can resume following a call to <B>sem_post</B><SPAN STYLE="font-weight: medium"> +or </SPAN><B>sem_post_multiple</B>.</P> +<P><B>sem_timedwait</B> atomically decrements <I>sem</I>'s count if +it is greater than 0 and returns immediately, or it suspends the +calling thread. If <I>abstime</I> time arrives before the thread can +resume following a call to <B>sem_post</B> or <B>sem_post_multiple</B>, +then <B>sem_timedwait</B> returns with a return code of -1 after +having set <B>errno</B> to <B>ETIMEDOUT</B>. If the call can return +without suspending then <I>abstime</I> is not checked.</P> +<P><B>sem_trywait</B><SPAN STYLE="font-weight: medium"> atomically +decrements <I>sem</I>'s count if it is greater than 0 and returns +immediately, or it returns immediately with a return code of -1 after +having set <B>errno</B> to <B>EAGAIN</B></SPAN>. <B>sem_trywait</B><SPAN STYLE="font-weight: medium"> +never blocks.</SPAN></P> +<P><B>sem_post</B> either releases one thread if there are any +waiting on <I>sem</I>, or it atomically increments <I>sem</I>'s +count.</P> +<P><B>sem_post_multiple</B> either releases multiple threads if there +are any waiting on <I>sem</I><SPAN STYLE="font-style: normal"> and/or +it </SPAN>atomically increases <I>sem</I>'s count. If there are +currently <I>n</I> waiters, where <I>n</I> the largest number less +than or equal to <I>number</I>, then <I>n</I> waiters are released +and <I>sem</I>'s count is incremented by <I>number</I> minus <I>n</I>.</P> +<P><B>sem_getvalue</B> stores in the location pointed to by <I>sval</I> +the current count of the semaphore <I>sem</I>. In the <B>Pthreads-w32</B> +implementation: if the value returned in <I>sval</I> is greater than +or equal to 0 it was the <I>sem</I>'s count at some point during the +call to <B>sem_getvalue</B>. <SPAN STYLE="font-weight: medium">If the +value returned in <I>sval</I> is less than 0 then it's absolute value +represents the number of threads waiting on <I>sem</I> at some point +during the call to </SPAN><B>sem_getvalue. </B><SPAN STYLE="font-weight: medium">POSIX +does not require an implementation of </SPAN><B>sem_getvalue</B><SPAN STYLE="font-weight: medium"> +to return a value in <I>sval</I> that is less than 0, but if it does +then it's absolute value must represent the number of waiters.</SPAN></P> +<P><B>sem_destroy</B> destroys a semaphore object, freeing the +resources it might hold. No threads should be waiting on the +semaphore at the time <B>sem_destroy</B> is called.</P> +<H2><A HREF="#toc3" NAME="sect3">Cancellation</A></H2> +<P><B>sem_wait</B> and <B>sem_timedwait</B> are cancellation points. +</P> +<H2><A HREF="#toc4" NAME="sect4">Async-signal Safety</A></H2> +<P>These routines are not async-cancel safe.</P> +<H2><A HREF="#toc5" NAME="sect5">Return Value</A></H2> +<P>All semaphore functions return 0 on success, or -1 on error in +which case they write an error code in <B>errno</B>. +</P> +<H2><A HREF="#toc6" NAME="sect6">Errors</A></H2> +<P>The <B>sem_init</B> function sets <B>errno</B> to the following +codes on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EINVAL</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + <I>value</I> exceeds the maximal counter value <B>_POSIX_SEM_VALUE_MAX</B> + </DD><DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + <B>ENOSYS</B> + </DT></DL> +</DL> +<BLOCKQUOTE STYLE="margin-left: 2cm"> +<I>pshared</I> is not zero +</BLOCKQUOTE> +<P>The <B>sem_timedwait</B> function sets <B>errno</B> to the +following error code on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>ETIMEDOUT</B> + </DT></DL> +</DL> +<BLOCKQUOTE STYLE="margin-left: 2cm"> +if <I>abstime</I> arrives before the waiting thread can resume +following a call to <B>sem_post</B> or <B>sem_post_multiple</B>. +</BLOCKQUOTE> +<P>The <B>sem_trywait</B> function sets <B>errno</B> to the following +error code on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EAGAIN</B> + </DT></DL> +</DL> +<BLOCKQUOTE STYLE="margin-left: 2cm"> +if the semaphore count is currently 0 +</BLOCKQUOTE> +<P>The <B>sem_post</B> and <B>sem_post_multiple</B> functions set +<B>errno</B> to the following error code on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>ERANGE</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + if after incrementing, the semaphore count would exceed + <B>_POSIX_SEM_VALUE_MAX</B> (the semaphore count is left unchanged + in this case) + </DD></DL> +</DL> +<P> +The <B>sem_destroy</B> function sets <B>errno</B> to the following +error code on error: +</P> +<DL> + <DL> + <DT STYLE="margin-right: 1cm; margin-bottom: 0.5cm"><B>EBUSY</B> + </DT><DD STYLE="margin-right: 1cm; margin-bottom: 0.5cm"> + if some threads are currently blocked waiting on the semaphore. + </DD></DL> +</DL> +<H2> +<A HREF="#toc7" NAME="sect7">Author</A></H2> +<P>Xavier Leroy <Xavier.Leroy@inria.fr> +</P> +<P>Modified by Ross Johnson for use with <A HREF="http://sources.redhat.com/pthreads-win32">Pthreads-w32</A>.</P> +<H2><A HREF="#toc8" NAME="sect8">See Also</A></H2> +<P><A HREF="pthread_mutex_init.html"><B>pthread_mutex_init</B>(3)</A> +, <A HREF="pthread_cond_init.html"><B>pthread_cond_init</B>(3)</A> , +<A HREF="pthread_cancel.html"><B>pthread_cancel</B>(3)</A> . +</P> +<HR> +<P><A NAME="toc"></A><B>Table of Contents</B></P> +<UL> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect0" NAME="toc0">Name</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect1" NAME="toc1">Synopsis</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect2" NAME="toc2">Description</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect3" NAME="toc3">Cancellation</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect4" NAME="toc4">Async-signal + Safety</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect5" NAME="toc5">Return + Value</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect6" NAME="toc6">Errors</A> + </P> + <LI><P STYLE="margin-bottom: 0cm"><A HREF="#sect7" NAME="toc7">Author</A> + </P> + <LI><P><A HREF="#sect8" NAME="toc8">See Also</A> + </P> +</UL> +</BODY> +</HTML> @@ -37,8 +37,8 @@ * See the README file for an explanation of the pthreads-win32 version * numbering scheme and how the DLL is named etc. */ -#define PTW32_VERSION 1,8,0,0 -#define PTW32_VERSION_STRING "1, 8, 0, 0\0" +#define PTW32_VERSION 1,9,0,0 +#define PTW32_VERSION_STRING "1, 9, 0, 0\0" /* There are three implementations of cancel cleanup. * Note that pthread.h is included in both application diff --git a/pthread_key_create.c b/pthread_key_create.c index b5b00ce..5e278c2 100644 --- a/pthread_key_create.c +++ b/pthread_key_create.c @@ -98,7 +98,7 @@ pthread_key_create (pthread_key_t * key, void (*destructor) (void *)) * * The mutex will only be created when it is first locked. */ - newkey->threadsLock = PTHREAD_MUTEX_INITIALIZER; + newkey->keyLock = PTHREAD_MUTEX_INITIALIZER; newkey->destructor = destructor; } diff --git a/pthread_key_delete.c b/pthread_key_delete.c index eacab03..99b00b9 100644 --- a/pthread_key_delete.c +++ b/pthread_key_delete.c @@ -44,7 +44,7 @@ pthread_key_delete (pthread_key_t key) * ------------------------------------------------------ * DOCPUBLIC * This function deletes a thread-specific data key. This - * does not change the value of the thread spcific data key + * does not change the value of the thread specific data key * for any thread and does not run the key's destructor * in any thread so it should be used with caution. * @@ -55,7 +55,7 @@ pthread_key_delete (pthread_key_t key) * * DESCRIPTION * This function deletes a thread-specific data key. This - * does not change the value of the thread spcific data key + * does not change the value of the thread specific data key * for any thread and does not run the key's destructor * in any thread so it should be used with caution. * @@ -72,7 +72,7 @@ pthread_key_delete (pthread_key_t key) { if (key->threads != NULL && key->destructor != NULL && - pthread_mutex_lock (&(key->threadsLock)) == 0) + pthread_mutex_lock (&(key->keyLock)) == 0) { /* * Run through all Thread<-->Key associations @@ -93,28 +93,31 @@ pthread_key_delete (pthread_key_t key) while (assoc != NULL) { - if (pthread_mutex_lock (&(assoc->lock)) == 0) - { - ThreadKeyAssoc *next; + ThreadKeyAssoc *next; + ptw32_thread_t * thread = assoc->thread; - assoc->key = NULL; + if (thread != NULL + && pthread_mutex_lock (&(thread->threadLock)) == 0) + { + next = assoc->nextThread; + ptw32_tkAssocDestroy (assoc); + (void) pthread_mutex_unlock (&(thread->threadLock)); + } + else + { + /* Thread or lock is no longer valid */ next = assoc->nextThread; - assoc->nextThread = NULL; - - pthread_mutex_unlock (&(assoc->lock)); - ptw32_tkAssocDestroy (assoc); - - assoc = next; } + assoc = next; } - pthread_mutex_unlock (&(key->threadsLock)); + pthread_mutex_unlock (&(key->keyLock)); } TlsFree (key->key); if (key->destructor != NULL) { - pthread_mutex_destroy (&(key->threadsLock)); + pthread_mutex_destroy (&(key->keyLock)); } #if defined( _DEBUG ) diff --git a/pthread_setspecific.c b/pthread_setspecific.c index 7ac1d73..3c630cf 100644 --- a/pthread_setspecific.c +++ b/pthread_setspecific.c @@ -87,9 +87,8 @@ pthread_setspecific (pthread_key_t key, const void *value) * Resolve catch-22 of registering thread with selfThread * key */ - ptw32_thread_t * sp; + ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); - sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); if (sp == NULL) { if (value == NULL) @@ -108,12 +107,8 @@ pthread_setspecific (pthread_key_t key, const void *value) if (key != NULL) { - ThreadKeyAssoc *assoc; - if (self.p != NULL && key->destructor != NULL && value != NULL) { - ptw32_thread_t * sp = (ptw32_thread_t *) self.p; - /* * Only require associations if we have to * call user destroy routine. @@ -123,38 +118,50 @@ pthread_setspecific (pthread_key_t key, const void *value) * on the association; setting assoc to NULL short * circuits the search. */ - assoc = (ThreadKeyAssoc *) sp->keys; - /* - * Locate existing association - */ - while (assoc != NULL) + ThreadKeyAssoc *assoc; + + if (pthread_mutex_lock(&(key->keyLock)) == 0) { - if (assoc->key == key) + ptw32_thread_t * sp = (ptw32_thread_t *) self.p; + + (void) pthread_mutex_lock(&(sp->threadLock)); + + assoc = (ThreadKeyAssoc *) sp->keys; + /* + * Locate existing association + */ + while (assoc != NULL) { - /* - * Association already exists - */ - break; + if (assoc->key == key) + { + /* + * Association already exists + */ + break; + } + assoc = assoc->nextKey; } - assoc = assoc->nextKey; - } - /* - * create an association if not found - */ - if (assoc == NULL) - { - result = ptw32_tkAssocCreate (&assoc, self, key); - } - } + /* + * create an association if not found + */ + if (assoc == NULL) + { + result = ptw32_tkAssocCreate (&assoc, sp, key); + } - if (result == 0) - { - if (!TlsSetValue (key->key, (LPVOID) value)) - { - result = EAGAIN; + (void) pthread_mutex_unlock(&(sp->threadLock)); } + (void) pthread_mutex_unlock(&(key->keyLock)); } + + if (result == 0) + { + if (!TlsSetValue (key->key, (LPVOID) value)) + { + result = EAGAIN; + } + } } return (result); diff --git a/ptw32_callUserDestroyRoutines.c b/ptw32_callUserDestroyRoutines.c index 87e1dc4..7edce08 100644 --- a/ptw32_callUserDestroyRoutines.c +++ b/ptw32_callUserDestroyRoutines.c @@ -64,102 +64,85 @@ ptw32_callUserDestroyRoutines (pthread_t thread) * ------------------------------------------------------------------- */ { - ThreadKeyAssoc ** - nextP; - ThreadKeyAssoc * - assoc; + ThreadKeyAssoc * next; + ThreadKeyAssoc * assoc; if (thread.p != NULL) { + ptw32_thread_t * sp = (ptw32_thread_t *) thread.p; + /* * Run through all Thread<-->Key associations * for the current thread. - * If the pthread_key_t still exits (ie the assoc->key - * is not NULL) then call the user's TSD destroy routine. - * Notes: - * If assoc->key is NULL, then the user previously called - * PThreadKeyDestroy. The association is now only referenced - * by the current thread and must be released; otherwise - * the assoc will be destroyed when the key is destroyed. */ - nextP = (ThreadKeyAssoc **) &((ptw32_thread_t *)thread.p)->keys; - assoc = *nextP; + assoc = next = (ThreadKeyAssoc *) sp->keys; while (assoc != NULL) { + pthread_key_t k; - if (pthread_mutex_lock (&(assoc->lock)) == 0) + if ((k = assoc->key) != NULL + && pthread_mutex_lock(&(k->keyLock)) == 0) { - pthread_key_t k; - pthread_t nil = {NULL, 0}; + /* + * Key still active; pthread_key_delete + * will block on this same mutex before + * it can release actual key; therefore, + * key is valid and we can call the destroy + * routine; + */ + void * value = NULL; - if ((k = assoc->key) != NULL) + value = pthread_getspecific (k); + if (value != NULL && k->destructor != NULL) { - /* - * Key still active; pthread_key_delete - * will block on this same mutex before - * it can release actual key; therefore, - * key is valid and we can call the destroy - * routine; - */ - void * value = NULL; - - value = pthread_getspecific (k); - if (value != NULL && k->destructor != NULL) - { #ifdef __cplusplus - try - { - /* - * Run the caller's cleanup routine. - */ - (*(k->destructor)) (value); - } - catch (...) - { - /* - * A system unexpected exception has occurred - * running the user's destructor. - * We get control back within this block in case - * the application has set up it's own terminate - * handler. Since we are leaving the thread we - * should not get any internal pthreads - * exceptions. - */ - terminate (); - } - -#else /* __cplusplus */ - + try + { /* * Run the caller's cleanup routine. */ (*(k->destructor)) (value); + } + catch (...) + { + /* + * A system unexpected exception has occurred + * running the user's destructor. + * We get control back within this block in case + * the application has set up it's own terminate + * handler. Since we are leaving the thread we + * should not get any internal pthreads + * exceptions. + */ + (void) pthread_mutex_unlock(&(k->keyLock)); + terminate (); + } + +#else /* __cplusplus */ + + /* + * Run the caller's cleanup routine. + */ + (*(k->destructor)) (value); #endif /* __cplusplus */ - } } /* - * mark assoc->thread as NULL to indicate the - * thread no longer references this association + * Remove association from both the key and thread chains */ - assoc->thread = nil; - - /* - * Remove association from the pthread_t chain - */ - *nextP = assoc->nextKey; - - pthread_mutex_unlock (&(assoc->lock)); - + (void) pthread_mutex_lock(&(sp->threadLock)); + next = assoc->nextKey; ptw32_tkAssocDestroy (assoc); + (void) pthread_mutex_unlock(&(sp->threadLock)); + + assoc = next; - assoc = *nextP; + (void) pthread_mutex_unlock(&(k->keyLock)); } } } - } /* ptw32_callUserDestroyRoutines */ diff --git a/ptw32_tkAssocCreate.c b/ptw32_tkAssocCreate.c index f159408..10d6527 100644 --- a/ptw32_tkAssocCreate.c +++ b/ptw32_tkAssocCreate.c @@ -41,7 +41,7 @@ int ptw32_tkAssocCreate (ThreadKeyAssoc ** assocP, - pthread_t thread, pthread_key_t key) + ptw32_thread_t * sp, pthread_key_t key) /* * ------------------------------------------------------------------- * This routine creates an association that @@ -57,16 +57,14 @@ ptw32_tkAssocCreate (ThreadKeyAssoc ** assocP, * 1) New associations are pushed to the beginning of the * chain so that the internal ptw32_selfThreadKey association * is always last, thus allowing selfThreadExit to - * be implicitly called by pthread_exit last. + * be implicitly called last by pthread_exit. + * 2) * * Parameters: * assocP * address into which the association is returned. * thread - * current running thread. If NULL, then association - * is only added to the key. A NULL thread indicates - * that the user called pthread_setspecific prior - * to starting a thread. That's ok. + * current running thread. * key * key on which to create an association. * Returns: @@ -77,65 +75,49 @@ ptw32_tkAssocCreate (ThreadKeyAssoc ** assocP, * ------------------------------------------------------------------- */ { - int result; ThreadKeyAssoc *assoc; /* * Have to create an association and add it * to both the key and the thread. + * + * Both key->keyLock and thread->threadLock are locked on + * entry to this routine. */ assoc = (ThreadKeyAssoc *) calloc (1, sizeof (*assoc)); if (assoc == NULL) { - result = ENOMEM; - goto FAIL0; + return ENOMEM; } - /* - * Initialise only when used for the first time. - */ - assoc->lock = PTHREAD_MUTEX_INITIALIZER; - assoc->thread = thread; + assoc->thread = sp; assoc->key = key; /* * Register assoc with key */ - if ((result = pthread_mutex_lock (&(key->threadsLock))) != 0) + if (key->threads != NULL) { - goto FAIL2; + ((ThreadKeyAssoc *)key->threads)->prevThread = assoc; } - assoc->nextThread = (ThreadKeyAssoc *) key->threads; + assoc->prevThread = NULL; key->threads = (void *) assoc; - pthread_mutex_unlock (&(key->threadsLock)); - - if (thread.p != NULL) + /* + * Register assoc with thread + */ + if (sp->keys != NULL) { - /* - * Register assoc with thread - */ - assoc->nextKey = (ThreadKeyAssoc *) ((ptw32_thread_t *)thread.p)->keys; - ((ptw32_thread_t *)thread.p)->keys = (void *) assoc; + ((ThreadKeyAssoc *)sp->keys)->prevKey = assoc; } + assoc->nextKey = (ThreadKeyAssoc *) sp->keys; + assoc->prevKey = NULL; + sp->keys = (void *) assoc; *assocP = assoc; - return (result); - - /* - * ------------- - * Failure Code - * ------------- - */ -FAIL2: - pthread_mutex_destroy (&(assoc->lock)); - free (assoc); - -FAIL0: - - return (result); + return (0); } /* ptw32_tkAssocCreate */ diff --git a/ptw32_tkAssocDestroy.c b/ptw32_tkAssocDestroy.c index d80cd3f..f529e3c 100644 --- a/ptw32_tkAssocDestroy.c +++ b/ptw32_tkAssocDestroy.c @@ -56,10 +56,47 @@ ptw32_tkAssocDestroy (ThreadKeyAssoc * assoc) */ { - if ((assoc != NULL) && (assoc->key == NULL && assoc->thread.p == NULL)) + /* + * Both key->keyLock and thread->threadLock are locked on + * entry to this routine. + */ + if (assoc != NULL) { + ThreadKeyAssoc * prev, * next; - pthread_mutex_destroy (&(assoc->lock)); + prev = assoc->prevKey; + next = assoc->nextKey; + if (prev != NULL) + { + prev->nextKey = next; + } + if (next != NULL) + { + next->prevKey = prev; + } + + if (assoc->key->threads == assoc) + { + /* We're at the head of the threads chain */ + assoc->key->threads = next; + } + + prev = assoc->prevThread; + next = assoc->nextThread; + if (prev != NULL) + { + prev->nextThread = next; + } + if (next != NULL) + { + next->prevThread = prev; + } + + if (assoc->thread->keys == assoc) + { + /* We're at the head of the keys chain */ + assoc->thread->keys = next; + } free (assoc); } @@ -72,7 +72,8 @@ sem_init (sem_t * sem, int pshared, unsigned int value) * 0 successfully created semaphore, * -1 failed, error in errno * ERRNO - * EINVAL 'sem' is not a valid semaphore, + * EINVAL 'sem' is not a valid semaphore, or + * 'value' >= _POSIX_SEM_VALUE_MAX * ENOMEM out of memory, * ENOSPC a required resource has been exhausted, * ENOSYS semaphores are not supported, @@ -92,6 +93,10 @@ sem_init (sem_t * sem, int pshared, unsigned int value) */ result = EPERM; } + else if (value > (unsigned int)_POSIX_SEM_VALUE_MAX) + { + result = EINVAL; + } else { s = (sem_t) calloc (1, sizeof (*s)); @@ -68,6 +68,7 @@ sem_post (sem_t * sem) * ERRNO * EINVAL 'sem' is not a valid semaphore, * ENOSYS semaphores are not supported, + * ERANGE semaphore count is too big * * ------------------------------------------------------ */ @@ -81,23 +82,29 @@ sem_post (sem_t * sem) } else if ((result = pthread_mutex_lock (&s->lock)) == 0) { -#ifdef NEED_SEM - - if (++s->value <= 0) + if (s->value < _POSIX_SEM_VALUE_MAX) { - if (!SetEvent(s->sem)) +#ifdef NEED_SEM + if (++s->value <= 0 + && !SetEvent(s->sem)) { + s->value--; result = EINVAL; } - } #else - if (++s->value <= 0 - && !ReleaseSemaphore (s->sem, 1, NULL)) + if (++s->value <= 0 + && !ReleaseSemaphore (s->sem, 1, NULL)) + { + s->value--; + result = EINVAL; + } +#endif /* NEED_SEM */ + } + else { - result = EINVAL; + result = ERANGE; } -#endif /* NEED_SEM */ - + (void) pthread_mutex_unlock (&s->lock); } diff --git a/sem_post_multiple.c b/sem_post_multiple.c index 9dab861..42ea2f4 100644 --- a/sem_post_multiple.c +++ b/sem_post_multiple.c @@ -71,6 +71,7 @@ sem_post_multiple (sem_t * sem, int count) * ERRNO * EINVAL 'sem' is not a valid semaphore * or count is less than or equal to zero. + * ERANGE semaphore count is too big * * ------------------------------------------------------ */ @@ -85,28 +86,39 @@ sem_post_multiple (sem_t * sem, int count) } else if ((result = pthread_mutex_lock (&s->lock)) == 0) { - waiters = -s->value; - s->value += count; - if (waiters > 0) - { -#ifdef NEED_SEM - if (SetEvent(s->sem)) + if (s->value <= (_POSIX_SEM_VALUE_MAX - count)) + { + waiters = -s->value; + s->value += count; + if (waiters > 0) { - waiters--; - s->leftToUnblock += count - 1; - if (s->leftToUnblock > waiters) +#ifdef NEED_SEM + if (SetEvent(s->sem)) { - s->leftToUnblock = waiters; + waiters--; + s->leftToUnblock += count - 1; + if (s->leftToUnblock > waiters) + { + s->leftToUnblock = waiters; + } } - } - else #else - if (!ReleaseSemaphore (s->sem, (waiters<=count)?waiters:count, 0)) + if (ReleaseSemaphore (s->sem, (waiters<=count)?waiters:count, 0)) + { + /* No action */ + } #endif - { - result = EINVAL; - } - } + else + { + s->value -= count; + result = EINVAL; + } + } + } + else + { + result = ERANGE; + } (void) pthread_mutex_unlock (&s->lock); } @@ -167,6 +167,8 @@ pthread_sigmask (int how, sigset_t const *set, sigset_t * oset) int sigwait (const sigset_t * set, int *sig) { + /* This routine is a cancellation point */ + pthread_test_cancel(); } int diff --git a/tests/Bmakefile b/tests/Bmakefile index 285239a..60b0a75 100644 --- a/tests/Bmakefile +++ b/tests/Bmakefile @@ -91,11 +91,12 @@ PASSES= loadfree.pass \ mutex6s.pass mutex6es.pass mutex6rs.pass \ mutex7.pass mutex7n.pass mutex7e.pass mutex7r.pass \ mutex8.pass mutex8n.pass mutex8e.pass mutex8r.pass \ - count1.pass once1.pass once2.pass once3.pass once4.pass tsd1.pass \ + count1.pass once1.pass once2.pass once3.pass once4.pass \ self2.pass \ cancel1.pass cancel2.pass \ semaphore4.pass semaphore4t.pass \ - delay1.pass delay2.pass eyal1.pass \ + barrier1.pass barrier2.pass barrier3.pass barrier4.pass barrier5.pass \ + tsd1.pass delay1.pass delay2.pass eyal1.pass \ condvar3.pass condvar3_1.pass condvar3_2.pass condvar3_3.pass \ condvar4.pass condvar5.pass condvar6.pass \ condvar7.pass condvar8.pass condvar9.pass \ @@ -108,9 +109,8 @@ PASSES= loadfree.pass \ cleanup0.pass cleanup1.pass cleanup2.pass cleanup3.pass \ priority1.pass priority2.pass inherit1.pass \ spin1.pass spin2.pass spin3.pass spin4.pass \ - barrier1.pass barrier2.pass barrier3.pass barrier4.pass barrier5.pass \ exception1.pass exception2.pass exception3.pass \ - cancel9.pass create3.pass + cancel9.pass create3.pass stress1.pass BENCHRESULTS = \ benchtest1.bench benchtest2.bench benchtest3.bench benchtest4.bench benchtest5.bench @@ -220,7 +220,7 @@ benchtest2.bench: benchtest3.bench: benchtest4.bench: benchtest5.bench: -barrier1.pass: +barrier1.pass: semaphore4.pass barrier2.pass: barrier1.pass barrier3.pass: barrier2.pass barrier4.pass: barrier3.pass @@ -234,6 +234,7 @@ cancel6a.pass: cancel3.pass cancel6d.pass: cancel3.pass cancel7.pass: kill1.pass cancel8.pass: cancel7.pass +cancel9.pass: cancel8.pass cleanup0.pass: cancel5.pass cleanup1.pass: cleanup0.pass cleanup2.pass: cleanup1.pass @@ -339,7 +340,7 @@ spin1.pass: spin2.pass: spin1.pass spin3.pass: spin2.pass spin4.pass: spin3.pass -tsd1.pass: join1.pass +stress1.pass: barrier5.pass +tsd1.pass: barrier5.pass join1.pass valid1.pass: join1.pass valid2.pass: valid1.pass -cancel9.pass: cancel8.pass diff --git a/tests/GNUmakefile b/tests/GNUmakefile index a789e19..641164d 100644 --- a/tests/GNUmakefile +++ b/tests/GNUmakefile @@ -86,10 +86,11 @@ TESTS = sizes loadfree \ mutex4 mutex6 mutex6n mutex6e mutex6r \ mutex6s mutex6es mutex6rs \ mutex7 mutex7n mutex7e mutex7r mutex8 mutex8n mutex8e mutex8r \ - count1 once1 once2 once3 once4 tsd1 self2 \ + count1 once1 once2 once3 once4 self2 \ cancel1 cancel2 \ semaphore4 semaphore4t \ - delay1 delay2 eyal1 \ + barrier1 barrier2 barrier3 barrier4 barrier5 \ + tsd1 delay1 delay2 eyal1 \ condvar3 condvar3_1 condvar3_2 condvar3_3 \ condvar4 condvar5 condvar6 condvar7 condvar8 condvar9 \ errno1 \ @@ -100,10 +101,12 @@ TESTS = sizes loadfree \ cleanup0 cleanup1 cleanup2 cleanup3 \ priority1 priority2 inherit1 \ spin1 spin2 spin3 spin4 \ - barrier1 barrier2 barrier3 barrier4 barrier5 \ exception1 exception2 exception3 \ cancel9 create3 +STRESSTESTS = \ + stress1 + BENCHTESTS = \ benchtest1 benchtest2 benchtest3 benchtest4 benchtest5 @@ -112,6 +115,7 @@ STATICTESTS = \ PASSES = $(TESTS:%=%.pass) BENCHRESULTS = $(BENCHTESTS:%=%.bench) +STRESSRESULTS = $(STRESSTESTS:%=%.pass) STATICRESULTS = $(STATICTESTS:%=%.pass) help: @@ -121,6 +125,8 @@ help: @ $(ECHO) "make clean GCE (to test using GCE dll with C++ (EH) applications)" @ $(ECHO) "make clean GC-bench (to benchtest using GNU C dll with C cleanup code)" @ $(ECHO) "make clean GCE-bench (to benchtest using GNU C dll with C++ exception handling)" + @ $(ECHO) "make clean GC-stress (to stresstest using GNU C dll with C cleanup code)" + @ $(ECHO) "make clean GCE-stress (to stresstest using GNU C dll with C++ exception handling)" @ $(ECHO) "make clean GC-static (to test using GC static lib with C (no EH) applications)" all: @@ -146,12 +152,24 @@ GCE-bench: GC-static: $(MAKE) TEST=GC CC=gcc XXCFLAGS="-D__CLEANUP_C -DPTW32_STATIC_LIB" DLL="" all-static +GC-stress: + $(ECHO) Stress tests can take a long time since they are trying to + $(ECHO) expose weaknesses that may be intermittant or statistically rare. + $(ECHO) A pass does not prove correctness, but may give greater confidence. + $(MAKE) TEST=GC CC=gcc XXCFLAGS="-D__CLEANUP_C" all-stress + +GCE-stress: + $(MAKE) TEST=GCE CC=g++ XXCFLAGS="-mthreads -D__CLEANUP_CXX" all-stress + all-pass: $(PASSES) @ $(ECHO) ALL TESTS PASSED! Congratulations! all-bench: $(BENCHRESULTS) @ $(ECHO) BENCH TESTS COMPLETED. +all-stress: $(STRESSRESULTS) + @ $(ECHO) STRESS TESTS COMPLETED. + all-static: $(STATICRESULTS) @ $(ECHO) ALL STATIC TESTS PASSED! Congratulations! @ $(ECHO) Build and test the DLL to run all tests. @@ -163,7 +181,9 @@ benchtest3.bench: benchtest4.bench: benchtest5.bench: -barrier1.pass: +stress1.pass: + +barrier1.pass: semaphore4.pass barrier2.pass: barrier1.pass barrier3.pass: barrier2.pass barrier4.pass: barrier3.pass @@ -178,6 +198,7 @@ cancel6a.pass: cancel3.pass cancel6d.pass: cancel3.pass cancel7.pass: kill1.pass cancel8.pass: cancel7.pass +cancel9.pass: cancel8.pass cleanup0.pass: cancel5.pass cleanup1.pass: cleanup0.pass cleanup2.pass: cleanup1.pass @@ -283,10 +304,9 @@ spin1.pass: spin2.pass: spin1.pass spin3.pass: spin2.pass spin4.pass: spin3.pass -tsd1.pass: join1.pass +tsd1.pass: barrier5.pass join1.pass valid1.pass: join1.pass valid2.pass: valid1.pass -cancel9.pass: cancel8.pass sizes.pass: sizes.exe @ $(ECHO) Running $* diff --git a/tests/Makefile b/tests/Makefile index 5c73009..8fa72b4 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -95,11 +95,12 @@ PASSES= sizes.pass loadfree.pass \ mutex6s.pass mutex6es.pass mutex6rs.pass \ mutex7.pass mutex7n.pass mutex7e.pass mutex7r.pass \ mutex8.pass mutex8n.pass mutex8e.pass mutex8r.pass \ - count1.pass once1.pass once2.pass once3.pass once4.pass tsd1.pass \ + count1.pass once1.pass once2.pass once3.pass once4.pass \ self2.pass \ cancel1.pass cancel2.pass \ semaphore4.pass semaphore4t.pass \ - delay1.pass delay2.pass eyal1.pass \ + barrier1.pass barrier2.pass barrier3.pass barrier4.pass barrier5.pass \ + tsd1.pass delay1.pass delay2.pass eyal1.pass \ condvar3.pass condvar3_1.pass condvar3_2.pass condvar3_3.pass \ condvar4.pass condvar5.pass condvar6.pass \ condvar7.pass condvar8.pass condvar9.pass \ @@ -113,27 +114,33 @@ PASSES= sizes.pass loadfree.pass \ cleanup0.pass cleanup1.pass cleanup2.pass cleanup3.pass \ priority1.pass priority2.pass inherit1.pass \ spin1.pass spin2.pass spin3.pass spin4.pass \ - barrier1.pass barrier2.pass barrier3.pass barrier4.pass barrier5.pass \ exception1.pass exception2.pass exception3.pass \ - cancel9.pass create3.pass + cancel9.pass create3.pass BENCHRESULTS = \ benchtest1.bench benchtest2.bench benchtest3.bench benchtest4.bench benchtest5.bench +STRESSRESULTS = \ + stress1.pass + STATICRESULTS = \ self1.pass help: @ $(ECHO) Run one of the following command lines: - @ $(ECHO) nmake clean VC (to test using VC dll with VC (no EH) applications) - @ $(ECHO) nmake clean VCX (to test using VC dll with VC++ (EH) applications) - @ $(ECHO) nmake clean VCE (to test using the VCE dll with VC++ EH applications) - @ $(ECHO) nmake clean VSE (to test using VSE dll with VC (SEH) applications) - @ $(ECHO) nmake clean VC-bench (to benchtest using VC dll with C bench app) - @ $(ECHO) nmake clean VCX-bench (to benchtest using VC dll with C++ bench app) - @ $(ECHO) nmake clean VCE-bench (to benchtest using VCE dll with C++ bench app) - @ $(ECHO) nmake clean VSE-bench (to benchtest using VSE dll with SEH bench app) - @ $(ECHO) nmake clean VC-static (to test using VC static lib with VC (no EH) applications) + @ $(ECHO) nmake clean VC (to test using VC dll with VC (no EH) apps) + @ $(ECHO) nmake clean VC-bench (to benchtest using VC dll with C bench apps) + @ $(ECHO) nmake clean VC-stress (to stresstest using VC dll with C stress apps) + @ $(ECHO) nmake clean VC-static (to test using VC static lib with VC (no EH) apps) + @ $(ECHO) nmake clean VCX (to test using VC dll with VC++ (EH) applications) + @ $(ECHO) nmake clean VCX-bench (to benchtest using VC dll with C++ bench apps) + @ $(ECHO) nmake clean VCX-stress (to stresstest using VC dll with C++ stress apps) + @ $(ECHO) nmake clean VCE (to test using the VCE dll with VC++ EH applications) + @ $(ECHO) nmake clean VCE-bench (to benchtest using VCE dll with C++ bench apps) + @ $(ECHO) nmake clean VCE-stress (to stresstest using VCE dll with C++ stress apps) + @ $(ECHO) nmake clean VSE (to test using VSE dll with VC (SEH) apps) + @ $(ECHO) nmake clean VSE-bench (to benchtest using VSE dll with SEH bench apps) + @ $(ECHO) nmake clean VSE-stress (to stresstest using VSE dll with SEH stress apps) all: @ nmake clean VC @@ -141,6 +148,7 @@ all: @ nmake clean VCE @ nmake clean VSE @ nmake clean VC-bench + @ nmake clean VC-stress # This allows an individual test application to be made using the default lib. # e.g. nmake clean test cancel3.exe @@ -152,6 +160,9 @@ tests: $(CPLIB) $(CPDLL) $(CPHDR) $(QAPC) $(PASSES) benchtests: $(CPLIB) $(CPDLL) $(CPHDR) $(XXLIBS) $(BENCHRESULTS) @ $(ECHO) ALL BENCH TESTS DONE. +stresstests: $(CPLIB) $(CPDLL) $(CPHDR) $(STRESSRESULTS) + @ $(ECHO) ALL STRESS TESTS DONE. + statictests: $(CPLIB) $(CPDLL) $(CPHDR) $(STATICRESULTS) @ $(ECHO) ALL STATIC TESTS DONE. @ $(ECHO) Build and test the DLL to run all tests. @@ -176,30 +187,48 @@ $(BENCHRESULTS): $*.exe @ $(ECHO) ...... Done @ $(TOUCH) $*.bench +$(STRESSRESULTS): $*.exe + @ $(ECHO) ... Running $(TEST) stresstest: $*.exe + @ .\$*.exe + @ $(ECHO) ...... Done + @ $(TOUCH) $*.pass + +VC: + @ nmake TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCFLAGS)" tests + VCE: @ nmake TEST="$@" CPLIB="$(VCELIB)" CPDLL="$(VCEDLL)" EHFLAGS="$(VCEFLAGS)" tests VSE: @ nmake TEST="$@" CPLIB="$(VSELIB)" CPDLL="$(VSEDLL)" EHFLAGS="$(VSEFLAGS)" tests -VC: - @ nmake TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCFLAGS)" tests - VCX: @ nmake TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCXFLAGS)" tests +VC-bench: + @ nmake TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCFLAGS)" XXLIBS="benchlib.o" benchtests + VCE-bench: @ nmake TEST="$@" CPLIB="$(VCELIB)" CPDLL="$(VCEDLL)" EHFLAGS="$(VCEFLAGS)" XXLIBS="benchlib.o" benchtests VSE-bench: @ nmake TEST="$@" CPLIB="$(VSELIB)" CPDLL="$(VSEDLL)" EHFLAGS="$(VSEFLAGS)" XXLIBS="benchlib.o" benchtests -VC-bench: - @ nmake TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCFLAGS)" XXLIBS="benchlib.o" benchtests - VCX-bench: @ nmake TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCXFLAGS)" XXLIBS="benchlib.o" benchtests +VC-stress: + @ nmake TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCFLAGS)" stresstests + +VCE-stress: + @ nmake TEST="$@" CPLIB="$(VCELIB)" CPDLL="$(VCEDLL)" EHFLAGS="$(VCEFLAGS)" stresstests + +VSE-stress: + @ nmake TEST="$@" CPLIB="$(VSELIB)" CPDLL="$(VSEDLL)" EHFLAGS="$(VSEFLAGS)" stresstests + +VCX-stress: + @ nmake TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCXFLAGS)" stresstests + VC-static: @ nmake TEST="$@" CPLIB="$(VCLIB)" CPDLL="" EHFLAGS="$(VCFLAGS) /DPTW32_STATIC_LIB" statictests @@ -244,7 +273,10 @@ benchtest2.bench: benchtest3.bench: benchtest4.bench: benchtest5.bench: -barrier1.pass: + +stress1.pass: + +barrier1.pass: semaphore4.pass barrier2.pass: barrier1.pass barrier3.pass: barrier2.pass barrier4.pass: barrier3.pass @@ -258,6 +290,7 @@ cancel6a.pass: cancel3.pass cancel6d.pass: cancel3.pass cancel7.pass: kill1.pass cancel8.pass: cancel7.pass +cancel9.pass: cancel8.pass cleanup0.pass: cancel5.pass cleanup1.pass: cleanup0.pass cleanup2.pass: cleanup1.pass @@ -363,7 +396,6 @@ spin1.pass: spin2.pass: spin1.pass spin3.pass: spin2.pass spin4.pass: spin3.pass -tsd1.pass: join1.pass +tsd1.pass: barrier5.pass join1.pass valid1.pass: join1.pass valid2.pass: valid1.pass -cancel9.pass: cancel8.pass diff --git a/tests/cancel4.c b/tests/cancel4.c index 1561ea6..6d6d3dc 100644 --- a/tests/cancel4.c +++ b/tests/cancel4.c @@ -112,10 +112,10 @@ mythread(void * arg) assert(pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) == 0); /* - * We wait up to 10 seconds, waking every 0.1 seconds, + * We wait up to 2 seconds, waking every 0.1 seconds, * for a cancelation to be applied to us. */ - for (bag->count = 0; bag->count < 100; bag->count++) + for (bag->count = 0; bag->count < 20; bag->count++) Sleep(100); return (void *) result; diff --git a/tests/condvar2.c b/tests/condvar2.c index cfc68af..33f1d3f 100644 --- a/tests/condvar2.c +++ b/tests/condvar2.c @@ -102,7 +102,7 @@ main() abstime.tv_sec = currSysTime.time; abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; - abstime.tv_sec += 5; + abstime.tv_sec += 1; assert(pthread_cond_timedwait(&cv, &mutex, &abstime) == ETIMEDOUT); diff --git a/tests/semaphore1.c b/tests/semaphore1.c index b5b2050..4327e73 100644 --- a/tests/semaphore1.c +++ b/tests/semaphore1.c @@ -86,7 +86,7 @@ thr(void * arg) if ( result == -1 ) { int err = errno; - perror("thread: sem_trywait 1: expected error"); // No error + perror("thread: sem_trywait 1: expect an EAGAIN error"); // No error assert(err == EAGAIN); } else @@ -131,7 +131,7 @@ main() if ( result == -1 ) { int err = errno; - perror("main: sem_trywait 1: expected error"); // No error + perror("main: sem_trywait 1: expect an EAGAIN error"); // No error assert(err == EAGAIN); } else diff --git a/tests/stress1.c b/tests/stress1.c new file mode 100644 index 0000000..b8d1c77 --- /dev/null +++ b/tests/stress1.c @@ -0,0 +1,271 @@ +/* + * stress1.c + * + * + * -------------------------------------------------------------------------- + * + * Pthreads-win32 - POSIX Threads Library for Win32 + * Copyright(C) 1998 John E. Bossom + * Copyright(C) 1999,2005 Pthreads-win32 contributors + * + * Contact Email: rpj@callisto.canberra.edu.au + * + * The current list of contributors is contained + * in the file CONTRIBUTORS included with the source + * code distribution. The list can also be seen at the + * following World Wide Web location: + * http://sources.redhat.com/pthreads-win32/contributors.html + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library in the file COPYING.LIB; + * if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * -------------------------------------------------------------------------- + * + * Test Synopsis: + * - Stress test condition variables, mutexes, semaphores. + * + * Test Method (Validation or Falsification): + * - Validation + * + * Requirements Tested: + * - Correct accounting of semaphore and condition variable waiters. + * + * Features Tested: + * - + * + * Cases Tested: + * - + * + * Description: + * Attempting to expose race conditions in cond vars, semaphores etc. + * - Master attempts to signal slave close to when timeout is due. + * - Master and slave do battle continuously until main tells them to stop. + * - Afterwards, the CV must be successfully destroyed (will return an + * error if there are waiters (including any internal semaphore waiters, + * which, if there are, cannot not be real waiters). + * + * Environment: + * - + * + * Input: + * - None. + * + * Output: + * - File name, Line number, and failed expression on failure. + * - No output on success. + * + * Assumptions: + * - + * + * Pass Criteria: + * - CV is successfully destroyed. + * + * Fail Criteria: + * - CV destroy fails. + */ + +#include "test.h" +#include <string.h> +#include <sys/timeb.h> + + +const unsigned int ITERATIONS = 1000; + +static pthread_t master, slave; +typedef struct { + int value; + pthread_cond_t cv; + pthread_mutex_t mx; +} mysig_t; + +static int allExit; +static mysig_t control = {0, PTHREAD_COND_INITIALIZER, PTHREAD_MUTEX_INITIALIZER}; +static pthread_barrier_t startBarrier, readyBarrier, holdBarrier; +static int timeoutCount = 0; +static int signalsTakenCount = 0; +static int signalsSent = 0; +static int bias = 0; +static int timeout = 10;
// Must be > 0 + +enum { + CTL_STOP = -1 +}; + +/* + * Returns abstime 'milliseconds' from 'now'. + */ +struct timespec * +millisecondsFromNow (struct timespec * time, int millisecs) +{ + struct _timeb currSysTime; + int64_t nanosecs, secs; + const int64_t NANOSEC_PER_MILLISEC = 1000000; + const int64_t NANOSEC_PER_SEC = 1000000000; + + /* get current system time and add millisecs */ + _ftime(&currSysTime); + + nanosecs = ((int64_t) (millisecs + currSysTime.millitm)) * NANOSEC_PER_MILLISEC; + if (nanosecs >= NANOSEC_PER_SEC) + { + secs = currSysTime.time + 1; + nanosecs %= NANOSEC_PER_SEC; + } + else + { + secs = currSysTime.time; + } + + time->tv_nsec = (long)nanosecs; + time->tv_sec = (long)secs; + + return time; +} + +void * +masterThread (void * arg) +{ + int dither = (int) arg; + + timeout = (int) arg; + + pthread_barrier_wait(&startBarrier); + + do + { + int sleepTime; + + assert(pthread_mutex_lock(&control.mx) == 0); + control.value = timeout; + assert(pthread_mutex_unlock(&control.mx) == 0); + + /* + * We are attempting to send the signal close to when the slave + * is due to timeout. We feel around by adding some [non-random] dither. + * + * with dither added, sleep time range is 2*timeout peak-to-peak centred on timeout, + * e.g. + * if timeout = 10 then dither = 20 and + * sleep millisecs is: 5 <= ms <= 15 + * + * The bias value attempts to apply some negative feedback to keep + * the ratio of timeouts to signals taken close to 1:1. + * bias changes more slowly than dither so as to average more. + */ + if (signalsSent % timeout == 0) + { + if (timeoutCount > signalsTakenCount) + { + bias++; + } + else if (timeoutCount < signalsTakenCount) + { + bias--; + } + if (bias < -timeout || bias > timeout) + { + timeout++; + } + } + dither = (dither + 1 ) % (timeout * 2); + sleepTime = (timeout - bias + dither) / 2; + Sleep(sleepTime); + assert(pthread_cond_signal(&control.cv) == 0); + signalsSent++; + + pthread_barrier_wait(&holdBarrier); + pthread_barrier_wait(&readyBarrier); + } + while (!allExit); + + return NULL; +} + +void * +slaveThread (void * arg) +{ + struct timespec time; + + pthread_barrier_wait(&startBarrier); + + do + { + assert(pthread_mutex_lock(&control.mx) == 0); + if (pthread_cond_timedwait(&control.cv, + &control.mx, + millisecondsFromNow(&time, control.value)) == ETIMEDOUT) + { + timeoutCount++; + } + else + { + signalsTakenCount++; + } + assert(pthread_mutex_unlock(&control.mx) == 0); + + pthread_barrier_wait(&holdBarrier); + pthread_barrier_wait(&readyBarrier); + } + while (!allExit); + + return NULL; +} + +int +main () +{ + unsigned int i; + + assert(pthread_barrier_init(&startBarrier, NULL, 3) == 0); + assert(pthread_barrier_init(&readyBarrier, NULL, 3) == 0); + assert(pthread_barrier_init(&holdBarrier, NULL, 3) == 0); + + assert(pthread_create(&master, NULL, masterThread, (void *) timeout) == 0); + assert(pthread_create(&slave, NULL, slaveThread, NULL) == 0); + + allExit = FALSE; + + pthread_barrier_wait(&startBarrier); + + for (i = 1; !allExit; i++) + { + pthread_barrier_wait(&holdBarrier); + if (i >= ITERATIONS) + { + allExit = TRUE; + } + pthread_barrier_wait(&readyBarrier); + } + + assert(pthread_join(slave, NULL) == 0); + assert(pthread_join(master, NULL) == 0); + + printf("Signals sent = %d\nWait timeouts = %d\nSignals taken = %d\nBias = %d\nTimeout = %d\n", + signalsSent, + timeoutCount, + signalsTakenCount, + (int) bias, + timeout); + + /* Cleanup */ + assert(pthread_barrier_destroy(&holdBarrier) == 0); + assert(pthread_barrier_destroy(&readyBarrier) == 0); + assert(pthread_barrier_destroy(&startBarrier) == 0); + assert(pthread_cond_destroy(&control.cv) == 0); + assert(pthread_mutex_destroy(&control.mx) == 0); + + /* Success. */ + return 0; +} diff --git a/tests/test.h b/tests/test.h index 11498cd..3132c69 100644 --- a/tests/test.h +++ b/tests/test.h @@ -47,6 +47,15 @@ #define PTW32_THREAD_NULL_ID {NULL,0} +#if defined(__MINGW32__) +#include <stdint.h> +#elif defined(__BORLANDC__) +#define int64_t ULONGLONG +#else +#define int64_t _int64 +#endif + + char * error_string[] = { "ZERO_or_EOK", "EPERM", @@ -109,13 +118,8 @@ char * error_string[] = { # define ASSERT_TRACE 1 #endif -/* - * Trick to force the compiler to not optimise out dead or obvious expressions. - */ -int ptw32_assert_force = 1; - # define assert(e) \ - (ptw32_assert_force && (e) ? ((ASSERT_TRACE) ? fprintf(stderr, \ + ((e) ? ((ASSERT_TRACE) ? fprintf(stderr, \ "Assertion succeeded: (%s), file %s, line %d\n", \ #e, __FILE__, (int) __LINE__), \ fflush(stderr) : \ @@ -125,7 +129,7 @@ int ptw32_assert_force = 1; int assertE; # define assert_e(e, o, r) \ - (ptw32_assert_force && ((assertE = e) o (r)) ? ((ASSERT_TRACE) ? fprintf(stderr, \ + (((assertE = e) o (r)) ? ((ASSERT_TRACE) ? fprintf(stderr, \ "Assertion succeeded: (%s), file %s, line %d\n", \ #e, __FILE__, (int) __LINE__), \ fflush(stderr) : \ diff --git a/tests/tsd1.c b/tests/tsd1.c index 6e21d2a..4d89165 100644 --- a/tests/tsd1.c +++ b/tests/tsd1.c @@ -34,6 +34,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * * + * -------------------------------------------------------------------------- + * * Description: * - * @@ -77,10 +79,15 @@ #include <sched.h> #include "test.h" +enum { + NUM_THREADS = 100 +}; + static pthread_key_t key = NULL; -static int accesscount[10]; -static int thread_set[10]; -static int thread_destroyed[10]; +static int accesscount[NUM_THREADS]; +static int thread_set[NUM_THREADS]; +static int thread_destroyed[NUM_THREADS]; +static pthread_barrier_t startBarrier; static void destroy_key(void * arg) @@ -117,10 +124,7 @@ setkey(void * arg) static void * mythread(void * arg) { - while (key == NULL) - { - sched_yield(); - } + (void) pthread_barrier_wait(&startBarrier); setkey(arg); @@ -134,22 +138,24 @@ main() { int i; int fail = 0; - pthread_t thread[10]; + pthread_t thread[NUM_THREADS]; - for (i = 1; i < 5; i++) + assert(pthread_barrier_init(&startBarrier, NULL, NUM_THREADS/2) == 0); + + for (i = 1; i < NUM_THREADS/2; i++) { accesscount[i] = thread_set[i] = thread_destroyed[i] = 0; assert(pthread_create(&thread[i], NULL, mythread, (void *)&accesscount[i]) == 0); } - Sleep(2000); - /* * Here we test that existing threads will get a key created * for them. */ assert(pthread_key_create(&key, destroy_key) == 0); + (void) pthread_barrier_wait(&startBarrier); + /* * Test main thread key. */ @@ -160,16 +166,16 @@ main() * Here we test that new threads will get a key created * for them. */ - for (i = 5; i < 10; i++) + for (i = NUM_THREADS/2; i < NUM_THREADS; i++) { - accesscount[i] = thread_set[i] = thread_destroyed[i] = 0; + accesscount[i] = thread_set[i] = thread_destroyed[i] = 0; assert(pthread_create(&thread[i], NULL, mythread, (void *)&accesscount[i]) == 0); } /* * Wait for all threads to complete. */ - for (i = 1; i < 10; i++) + for (i = 1; i < NUM_THREADS; i++) { int result = 0; @@ -178,7 +184,9 @@ main() assert(pthread_key_delete(key) == 0); - for (i = 1; i < 10; i++) + assert(pthread_barrier_destroy(&startBarrier) == 0); + + for (i = 1; i < NUM_THREADS; i++) { /* * The counter is incremented once when the key is set to |