summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrpj <rpj>2001-02-07 08:45:46 +0000
committerrpj <rpj>2001-02-07 08:45:46 +0000
commit7a31ef49c345dfb39de7cd6d43eeb29c34129495 (patch)
tree9515903248d26f12144a0e6161f7b1f6fd726978
parent2f4a1905d1a8c424900a8615ec730f7637482525 (diff)
Updates and minor corrections and changes.
-rw-r--r--ANNOUNCE66
-rw-r--r--ChangeLog6
-rw-r--r--README114
-rw-r--r--README.NONPORTABLE119
-rw-r--r--mutex.c4
-rw-r--r--pthread.h6
6 files changed, 181 insertions, 134 deletions
diff --git a/ANNOUNCE b/ANNOUNCE
index eed3003..8ba2989 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -27,20 +27,51 @@ Change Summary (since the last snapshot)
New:
- New functions (no-ops) for source code compatibility:
- pthread_getconcurrency
+ pthread_getconcurrency()
(Only returns the value '0' to indicate
that the system default concurrency is
used)
- pthread_setconcurrency
+ pthread_setconcurrency()
(Accepts any value >= 0 but does not
have any effect; always returns '0' or
EINVAL if arg < 0)
- pthread_attr_getscope
- pthread_attr_setscope
+ pthread_attr_getscope()
+ pthread_attr_setscope()
(Currently only return ENOSYS)
+- The following mutex types and related functions are now
+ supported:
+ pthread_mutexattr_gettype()
+ pthread_mutexattr_settype()
+ PTHREAD_MUTEX_DEFAULT
+ PTHREAD_MUTEX_NORMAL
+ PTHREAD_MUTEX_ERRORCHECK
+ PTHREAD_MUTEX_RECURSIVE
+ In this implementation PTHREAD_MUTEX_DEFAULT is
+ mapped to PTHREAD_MUTEX_RECURSIVE for backward
+ compatibility. Note that this mapping is allowed
+ by the Open Group description but that behaviour
+ considered as "undefined" in manual descriptions may
+ be different to some other implementations, eg
+ Solaris.
+
+ PTHREAD_MUTEX_NORMAL will simulate thread deadlock
+ if the owner of a mutex tries to relock it without
+ first unlocking it, however the lock will be released
+ if the owner thread is async-canceled.
+
+- Pthreads-win32 mutexes are now always based on
+ Win32 critical sections. We no longer use Win32
+ mutexes when TryEnterCriticalSection isn't
+ supported.
+ - Thomas Pfaff <tpfaff@gmx.net>
+
Bugs fixed:
--
+- The condition variable and read-write lock functions
+ have been improved. For details re the [fixed] problems
+ in the CV implementation see the file README.CV
+ - Alexander Terekhov <TEREKHOV@de.ibm.com>
+
Known bugs in this snapshot
---------------------------
@@ -147,6 +178,11 @@ The following functions are implemented:
pthread_mutexattr_destroy
pthread_mutexattr_getpshared
pthread_mutexattr_setpshared
+ pthread_mutexattr_gettype
+ pthread_mutexattr_settype (types: PTHREAD_MUTEX_DEFAULT
+ PTHREAD_MUTEX_NORMAL
+ PTHREAD_MUTEX_ERRORCHECK
+ PTHREAD_MUTEX_RECURSIVE )
pthread_mutex_init
pthread_mutex_destroy
@@ -200,10 +236,10 @@ The following functions are implemented:
pthread_attr_setschedparam
pthread_getschedparam
pthread_setschedparam
- pthread_getconcurrency
- pthread_getconcurrency
- pthread_attr_getscope
- pthread_attr_setscope
+ pthread_getconcurrency (always returns '0' indicating system default)
+ pthread_setconcurrency (accepts any value >= 0 but is ignored)
+ pthread_attr_getscope (returns an error ENOSYS)
+ pthread_attr_setscope (returns an error ENOSYS)
sched_get_priority_max (POSIX 1b)
sched_get_priority_min (POSIX 1b)
sched_yield (POSIX 1b)
@@ -214,15 +250,15 @@ The following functions are implemented:
pthread_sigmask
---------------------------
- Non-portable routines (see the README file for usage)
+ Non-portable routines (see the README.NONPORTABLE file for usage)
---------------------------
pthread_mutexattr_setforcecs_np
pthread_getw32threadhandle_np
- pthread_delay_np
- pthread_win32_process_attach_np
- pthread_win32_process_detach_np
- pthread_win32_thread_attach_np
- pthread_win32_thread_detach_np
+ pthread_delay_np
+ pthread_win32_process_attach_np
+ pthread_win32_process_detach_np
+ pthread_win32_thread_attach_np
+ pthread_win32_thread_detach_np
---------------------------
Static Initializers (macros)
diff --git a/ChangeLog b/ChangeLog
index 074526f..b266e0d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-02-07 Ross Johnson <rpj@setup1.ise.canberra.edu.au>
+
+ * mutex.c (pthread_mutex_lock): Map default type
+ PTHREAD_MUTEX_DEFAULT to PTHREAD_MUTEX_RECURSIVE
+ for backward compatibility.
+
2001-02-07 Ross Johnson <rpj@special.ise.canberra.edu.au>
* rwlock.c: Revamped.
diff --git a/README b/README
index 0ca6271..250ada2 100644
--- a/README
+++ b/README
@@ -94,120 +94,6 @@ Otherwise neither pthreads cancelation nor pthread_exit() will work
reliably.
-Non-portable functions included in the library
-----------------------------------------------
-
-void
-pthread_mutexattr_setforcecs_np(pthread_mutexattr_t *attr,
- int forcecs);
-
- Allows an application to force the library to use
- critical sections rather than win32 mutexes as
- the basis for any mutex that uses "attr".
- Critical sections are significantly faster than
- mutexes.
-
- Values for "forcecs" are:
- PTHREAD_MUTEX_AUTO_CS_NP
- - allow the library to decide based on
- availability of tryEnterCriticalSection().
- The library determines this at runtime
- and will use critical sections whenever
- tryEnterCriticalSection() is available.
- PTHREAD_MUTEX_FORCE_CS_NP
- - force use of critical sections even if
- tryEnterCriticalSection() isn't provided
- by the system, but you'd better not try
- to use pthread_mutex_trylock() on any
- mutex that uses "attr" if you want your
- application to work on all versions of
- Windows.
-
-HANDLE
-pthread_getw32threadhandle_np(pthread_t thread);
-
- Returns the win32 thread handle that the POSIX
- thread "thread" is running as.
-
- Applications can use the win32 handle to set
- win32 specific attributes of the thread.
-
-int
-pthread_delay_np (const struct timespec *interval);
-
- This routine 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.
-
- 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 cancelation request.
-
- This routine is a cancelation point.
-
- The timespec structure contains the following two fields:
-
- tv_sec is an integer number of seconds.
- tv_nsec is an integer number of nanoseconds.
-
- Return Values
-
- If an error condition occurs, this routine returns an integer value
- indicating the type of error. Possible return values are as follows:
-
- 0 Successful completion.
- [EINVAL] The value specified by interval is invalid.
-
-
-BOOL
-pthread_win32_process_attach_np (void);
-
-BOOL
-pthread_win32_process_detach_np (void);
-
-BOOL
-pthread_win32_thread_attach_np (void);
-
-BOOL
-pthread_win32_thread_detach_np (void);
-
- These functions contain the code normally run via dllMain
- when the library is used as a dll but which need to be
- called explicitly by an application when the library
- is statically linked.
-
- You will need to call pthread_win32_process_attach_np() before
- you can call any pthread routines when statically linking.
- You should call pthread_win32_process_detach_np() before
- exiting your application to clean up.
-
- pthread_win32_thread_attach_np() is currently a no-op, but
- pthread_win32_thread_detach_np() is needed to clean up
- after Win32 threads that have called pthreads routines
- have exited.
-
- These functions invariably return TRUE except for
- pthread_win32_process_attach_np() which will return FALSE
- if pthreads-win32 initialisation fails.
-
-
-int
-pthreadCancelableWait (HANDLE waitHandle);
-
-int
-pthreadCancelableTimedWait (HANDLE waitHandle, DWORD timeout);
-
- These two functions provide hooks into the pthread_cancel
- mechanism that will allow you to wait on a Windows handle
- and make it a cancellation point. Both functions block
- until either the given w32 handle is signaled, or
- pthread_cancel has been called. It is implemented using
- WaitForMultipleObjects on 'waitHandle' and a manually
- reset w32 event used to implement pthread_cancel.
-
-
Building under VC++ using either C++ EH or Structured EH
--------------------------------------------------------
diff --git a/README.NONPORTABLE b/README.NONPORTABLE
new file mode 100644
index 0000000..7dfba7f
--- /dev/null
+++ b/README.NONPORTABLE
@@ -0,0 +1,119 @@
+Non-portable functions included in the library
+----------------------------------------------
+
+HANDLE
+pthread_getw32threadhandle_np(pthread_t thread);
+
+ Returns the win32 thread handle that the POSIX
+ thread "thread" is running as.
+
+ Applications can use the win32 handle to set
+ win32 specific attributes of the thread.
+
+int
+pthread_delay_np (const struct timespec *interval);
+
+ This routine 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.
+
+ 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 cancelation
+ request.
+
+ This routine is a cancelation point.
+
+ The timespec structure contains the following two fields:
+
+ tv_sec is an integer number of seconds.
+ tv_nsec is an integer number of nanoseconds.
+
+ Return Values
+
+ If an error condition occurs, this routine returns an integer value
+ indicating the type of error. Possible return values are as follows:
+
+ 0 Successful completion.
+ [EINVAL] The value specified by interval is invalid.
+
+
+BOOL
+pthread_win32_process_attach_np (void);
+
+BOOL
+pthread_win32_process_detach_np (void);
+
+BOOL
+pthread_win32_thread_attach_np (void);
+
+BOOL
+pthread_win32_thread_detach_np (void);
+
+ These functions contain the code normally run via dllMain
+ when the library is used as a dll but which need to be
+ called explicitly by an application when the library
+ is statically linked.
+
+ You will need to call pthread_win32_process_attach_np() before
+ you can call any pthread routines when statically linking.
+ You should call pthread_win32_process_detach_np() before
+ exiting your application to clean up.
+
+ pthread_win32_thread_attach_np() is currently a no-op, but
+ pthread_win32_thread_detach_np() is needed to clean up
+ after Win32 threads that have called pthreads routines
+ have exited.
+
+ These functions invariably return TRUE except for
+ pthread_win32_process_attach_np() which will return FALSE
+ if pthreads-win32 initialisation fails.
+
+
+int
+pthreadCancelableWait (HANDLE waitHandle);
+
+int
+pthreadCancelableTimedWait (HANDLE waitHandle, DWORD timeout);
+
+ These two functions provide hooks into the pthread_cancel
+ mechanism that will allow you to wait on a Windows handle
+ and make it a cancellation point. Both functions block
+ until either the given w32 handle is signaled, or
+ pthread_cancel has been called. It is implemented using
+ WaitForMultipleObjects on 'waitHandle' and a manually
+ reset w32 event used to implement pthread_cancel.
+
+
+void
+pthread_mutexattr_setforcecs_np(pthread_mutexattr_t *attr,
+ int forcecs);
+
+ This function is no longer required as pthreads-win32
+ mutexes are now based entirely on Win32 critical
+ sections. Retained for backward compatibility.
+
+ Allows an application to force the library to use
+ critical sections rather than win32 mutexes as
+ the basis for any mutex that uses "attr".
+ Critical sections are significantly faster than
+ mutexes.
+
+ Values for "forcecs" are:
+ PTHREAD_MUTEX_AUTO_CS_NP
+ - allow the library to decide based on
+ availability of tryEnterCriticalSection().
+ The library determines this at runtime
+ and will use critical sections whenever
+ tryEnterCriticalSection() is available.
+ PTHREAD_MUTEX_FORCE_CS_NP
+ - force use of critical sections even if
+ tryEnterCriticalSection() isn't provided
+ by the system, but you'd better not try
+ to use pthread_mutex_trylock() on any
+ mutex that uses "attr" if you want your
+ application to work on all versions of
+ Windows.
diff --git a/mutex.c b/mutex.c
index 4ef39c1..c980ee5 100644
--- a/mutex.c
+++ b/mutex.c
@@ -732,7 +732,7 @@ pthread_mutexattr_settype (pthread_mutexattr_t * attr,
* return with an error.
*
* PTHREAD_MUTEX_DEFAULT
- * Same as PTHREAD_MUTEX_ERRORCHECK.
+ * Same as PTHREAD_MUTEX_RECURSIVE.
*
* PTHREAD_MUTEX_RECURSIVE
* A thread attempting to relock this mutex without
@@ -851,7 +851,6 @@ pthread_mutex_lock(pthread_mutex_t *mutex)
ptw32_EnterCriticalSection(&mx->cs);
}
break;
- case PTHREAD_MUTEX_DEFAULT:
case PTHREAD_MUTEX_ERRORCHECK:
if (pthread_equal(mx->ownerThread, self))
{
@@ -862,6 +861,7 @@ pthread_mutex_lock(pthread_mutex_t *mutex)
ptw32_EnterCriticalSection(&mx->cs);
}
break;
+ case PTHREAD_MUTEX_DEFAULT:
case PTHREAD_MUTEX_RECURSIVE:
ptw32_EnterCriticalSection(&mx->cs);
break;
diff --git a/pthread.h b/pthread.h
index 2f09031..029216b 100644
--- a/pthread.h
+++ b/pthread.h
@@ -363,10 +363,10 @@ typedef struct pthread_rwlockattr_t_ *pthread_rwlockattr_t;
/*
* pthread_attr_(get,set}scope
*
- * PTHREAD_SCOPE_PROCESS is the only scope supported.
+ * PTHREAD_SCOPE_SYSTEM is currently the only scope supported.
*/
-#define PTHREAD_SCOPE_SYSTEM 0
-#define PTHREAD_SCOPE_PROCESS 1
+#define PTHREAD_SCOPE_SYSTEM 0
+#define PTHREAD_SCOPE_PROCESS 1
/*
* ====================