From a311086d622d3c778e1da57cfae167c0ab1c0fb4 Mon Sep 17 00:00:00 2001 From: rpj Date: Sun, 1 Jul 2001 13:23:10 +0000 Subject: 2001-06-25 Ross Johnson * create.c (pthread_create): Add priority inheritance attributes. * mutex.c (pthread_mutex_lock): Remove some overhead for PTHREAD_MUTEX_NORMAL mutex types. Specifically, avoid calling pthread_self() and pthread_equal() to check/set the mutex owner. Introduce a new pseudo owner for this type. Test results suggest increases in speed of up to 90% for non-blocking locks. This is the default type of mutex used internally by other synchronising objects, ie. condition variables and read-write locks. The test rwlock7.c shows about a 30-35% speed increase over snapshot 2001-06-06. The price of this is that the application developer must ensure correct behaviour, or explicitly set the mutex to a safer type such as PTHREAD_MUTEX_ERRORCHECK. For example, PTHREAD_MUTEX_NORMAL (or PTHREAD_MUTEX_DEFAULT) type mutexes will not return an error if a thread which is not the owner calls pthread_mutex_unlock. The call will succeed in unlocking the mutex if it is currently locked, but a subsequent unlock by the true owner will then fail with EPERM. This is however consistent with some other implementations. (pthread_mutex_unlock): Likewise. (pthread_mutex_trylock): Likewise. (pthread_mutex_destroy): Likewise. * attr.c (pthread_attr_init): PTHREAD_EXPLICIT_SCHED is the default inheritance attribute; THREAD_PRIORITY_NORMAL is the default priority for new threads. * sched.c (pthread_attr_setschedpolicy): Added routine. (pthread_attr_getschedpolicy): Added routine. (pthread_attr_setinheritsched): Added routine. (pthread_attr_getinheritsched): Added routine. * pthread.h (sched_rr_set_interval): Added as a macro; returns -1 with errno set to ENOSYS. 2001-06-23 Ross Johnson *sched.c (pthread_attr_setschedparam): Add priority range check. (sched_setscheduler): New function; checks for a valid pid and policy; checks for permission to set information in the target process; expects pid to be a Win32 process ID, not a process handle; the only scheduler policy allowed is SCHED_OTHER. (sched_getscheduler): Likewise, but checks for permission to query. * pthread.h (SCHED_*): Moved to sched.h as defined in the POSIX standard. * sched.h (SCHED_*): Moved from pthread.h. (pid_t): Defined if necessary. (sched_setscheduler): Defined. (sched_getscheduler): Defined. * pthread.def (sched_setscheduler): Exported. (sched_getscheduler): Likewise. 2001-06-23 Ross Johnson Contributed by - Ralf Brese * create.c (pthread_create): Set thread priority from thread attributes. --- ANNOUNCE | 238 ++++++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 152 insertions(+), 86 deletions(-) (limited to 'ANNOUNCE') diff --git a/ANNOUNCE b/ANNOUNCE index b9b4970..689b16d 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,4 +1,4 @@ - PTHREADS-WIN32 SNAPSHOT 2001-06-06 + PTHREADS-WIN32 SNAPSHOT 2001-??-?? ---------------------------------- Web Site: http://sources.redhat.com/pthreads-win32/ FTP Site: ftp://sources.redhat.com/pub/pthreads-win32 @@ -28,83 +28,148 @@ Change Summary (since the last snapshot) (See the ChangeLog file for details.) -New: -- Async cancellation should now work for Windows running - on the following processors: IX86, MIPS, ALPHA, PPC. - - contributors name misplaced (please contact me if it's you) - -- New functions (no-ops) for source code compatibility: - pthread_getconcurrency() - Returns the value previously set by - pthread_setconcurrency(), or 0 (zero) - if no value was previously set. - The implementation does not currently use - this value. - pthread_setconcurrency() - Accepts any value >= 0 but does not - have any effect; returns '0', or - EINVAL if the value is < 0 - 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_mutexattr_setkind_np() - pthread_mutexattr_getkind_np() - PTHREAD_MUTEX_DEFAULT - PTHREAD_MUTEX_NORMAL or PTHREAD_MUTEX_FAST_NP - PTHREAD_MUTEX_ERRORCHECK or PTHREAD_MUTEX_ERRORCHECK_NP - PTHREAD_MUTEX_RECURSIVE or PTHREAD_MUTEX_RECURSIVE_NP - - The *_NP versions are for Linux portability. - - In this implementation PTHREAD_MUTEX_DEFAULT is - mapped to PTHREAD_MUTEX_NORMAL for compatibility - with major Unix vendors. This is also the default - if no type is specified. - - Please note that the default behaviour in previous - versions of the library was equivalent to - PTHREAD_MUTEX_RECURSIVE. This will be a problem - for some applications unless they are updated to - explicitly set the type of any mutexes that are, or - could be, locked recursively. - - PTHREAD_MUTEX_NORMAL will cause thread deadlock - if the owner of a mutex tries to relock it without - first unlocking it. It has slightly less overhead - that other types. - - Thomas Pfaff - -- Pthreads-win32 mutexes are now based on Win32 - critical sections for all Windows versions. The - implementation no longer depends on - TryEnterCriticalSection. - - Thomas Pfaff - -- New implementation of condition variables which attempts to - correct problems of spurious wakeups, unfairness, and - broadcast deadlock. See README.CV for details of the - discussion. - - Alexander Terekhov - - Louis Thomas - -Bugs fixed: -- Pthread_mutex_trylock() now properly returns EBUSY - even when the current thread owns the mutex. - Consequently, pthread_mutex_destroy() will no longer - destroy a locked mutex (it will return EBUSY). - - Thomas Pfaff - -- Errno warnings and building with /MD; - calling conventions (stdcall v cdecl); - thread termination problems; - - Milan Gardian +----------------------- +Additions to Scheduling +----------------------- +New routines: + pthread_attr_setinheritsched() + pthread_attr_getinheritsched() + pthread_attr_setschedpolicy() + pthread_attr_getschedpolicy() + sched_setscheduler() + sched_getscheduler() + sched_rr_get_interval() +Now defined: + _POSIX_THREAD_PRIORITY_SCHEDULING + +These routines complete the set required for defining +_POSIX_THREAD_PRIORITY_SCHEDULING. + + +sched_setscheduler +sched_getscheduler +------------------ +These routines will require patching to work with UWIN +or any other system that provides it's own pid_t. +Pthread.h conditionally defines pid_t as a DWORD, which +is the type returned by GetCurrentProcessId(). + +The only supported policy is SCHED_OTHER, however, in +order to provide semantic compatibility these routines +verify the following: +- that the process identified by pid exists; +- that permission is granted to set or query the policy; +The appropriate error is returned if either of these fail. +On success, both routines return SCHED_OTHER. + + +sched_rr_get_interval +--------------------- +Always returns -1 and sets errno to ENOTSUP. + + +pthread_attr_setschedpolicy +pthread_attr_getschedpolicy +--------------------------- +The only valid supported policy is SCHED_OTHER. +Attempting to set other policies results in an ENOTSUP +error. + + +pthread_attr_setinheritsched +pthread_attr_getinheritsched +---------------------------- +The two possible values that can be set are +PTHREAD_INHERIT_SCHED and PTHREAD_EXPLICIT_SCHED. + +Neither the POSIX standard nor the Single Unix Spec +specifies which should be the default value. +Consequently, implementations use different defaults, +eg (from a scan of the web): + +PTHREAD_INHERIT_SCHED default: + HP, MKS Toolkit, QNX, AIX (?) + +PTHREAD_EXPLICIT_SCHED default: + IBM OS/400, Linux, Sun + +All Win32 threads are created with THREAD_PRIORITY_NORMAL. +They do not inherit the priority of the parent thread or the +process. This behaviour is equivalent to the following +Pthreads defaults: + + Inheritance: PTHREAD_EXPLICIT_SCHED + Priority: THREAD_PRIORITY_NORMAL + +These are also the defaults in pthreads-win32, and now +reinforced by changes to the library which now actually +use these values and routines. This choice maintains the +notion that, from the Pthread point-of-view, Win32 +threads (those not created via pthread_create()) are +treated as detached POSIX threads with default attribute +values. + + +------------------ +Changes to Mutexes +------------------ +Snapshot-2001-06-06 included Thomas Pfaff's enhancements +to the mutex routines to improve speed. The improvements +are most apparent on Win9x class systems where pthreads-win32 +previously used Win32 mutexes rather than critical +sections as the underlying mechanism. The enhancements +also resulted in speed improvements in other primitives +which use mutexes internally, such as condition variables +and read-write locks. Thomas also added mutex +types to the library as described in the Single Unix +Specification documentation, and as provided with +the majority of major Unix and Linux Pthreads +implementations. + +Changes have been made to further improve the speed of the +default PTHREAD_MUTEX_NORMAL type (and therefore also +PTHREAD_MUTEX_DEFAULT which is equivalent in pthreads-win32). + +Specifically, the library no longer sets or checks the real +mutex owner when locking, unlocking, trylocking, or +destroying PTHREAD_MUTEX_NORMAL mutexes. This saves +significant overhead and results in measured speed increases +of around 90 percent for non-blocking lock operations, and a +slight improvement for blocking lock operations. Since the +type of mutex used internally is PTHREAD_MUTEX_DEFAULT, this +also results in additional speed improvements to CVs and R/W +lock operations. Subjective observation shows an +improvement of approximately 30-35% in R/W locks +(from tests/rwlock7.c). This is compared to the +already improved snapshot-2001-06-06. + +The price paid for this improvement is that some checking +for errors is not done for these mutex types. The onus +is placed on the developer to check application code +for logical errors, or use a safer mutex type such as +PTHREAD_MUTEX_ERRORCHECK. For example, it is now +possible for a non-owner thread to unlock or destroy +a mutex of these types. However, because the owner +is not simply left as NULL but set to a special anonymous +owner value when locked and then reset to NULL when +unlocked or destroyed, an error will ultimately eventuate +when the owner thread subsequently attempts to unlock or +destroy the mutex. + +These mutex changes appear to be consistent with both +the behaviour exhibited by other implementations and their +documentation, including the Open Group documentation. + + +------- +Bug fix +------- +Pthread_create now sets the priority of the new thread +from the value set in the thread attribute. +- from Ralf.Brese@pdb4.siemens.de. + +--------------------------- Known bugs in this snapshot --------------------------- @@ -173,24 +238,22 @@ reliably. Level of standards conformance ------------------------------ -The following POSIX 1003.1c 1995 options are defined: +The following POSIX 1003.1c 1995 and POSIX 1003.1b options are defined: _POSIX_THREADS _POSIX_THREAD_SAFE_FUNCTIONS _POSIX_THREAD_ATTR_STACKSIZE + _POSIX_THREAD_PRIORITY_SCHEDULING + _POSIX_SEMAPHORES The following POSIX 1003.1c 1995 options are not defined: _POSIX_THREAD_ATTR_STACKADDR - _POSIX_THREAD_PRIORITY_SCHEDULING _POSIX_THREAD_PRIO_INHERIT _POSIX_THREAD_PRIO_PROTECT _POSIX_THREAD_PROCESS_SHARED -The following POSIX 1003.1b option is defined: - - _POSIX_SEMAPHORES The following functions are implemented: @@ -291,6 +354,10 @@ The following functions are implemented: --------------------------- pthread_attr_getschedparam pthread_attr_setschedparam + pthread_attr_getinheritsched + pthread_attr_setinheritsched + pthread_attr_getschedpolicy (only supports SCHED_OTHER) + pthread_attr_setschedpolicy (only supports SCHED_OTHER) pthread_getschedparam pthread_setschedparam pthread_getconcurrency @@ -299,6 +366,9 @@ The following functions are implemented: pthread_attr_setscope (returns an error ENOSYS) sched_get_priority_max (POSIX 1b) sched_get_priority_min (POSIX 1b) + sched_rr_set_interval (POSIX 1b - returns an error ENOSYS) + sched_setscheduler (POSIX 1b - only supports SCHED_OTHER) + sched_getscheduler (POSIX 1b - only supports SCHED_OTHER) sched_yield (POSIX 1b) --------------------------- @@ -344,10 +414,6 @@ The following functions are not implemented: --------------------------- RealTime Scheduling --------------------------- - pthread_attr_getinheritsched - pthread_attr_getschedpolicy - pthread_attr_setinheritsched - pthread_attr_setschedpolicy pthread_mutex_getprioceiling pthread_mutex_setprioceiling pthread_mutex_attr_getprioceiling -- cgit v1.2.3