From a091d823ad89a36935ba6e5568c4720a35f9a99b Mon Sep 17 00:00:00 2001 From: David Xu Date: Sat, 2 Apr 2005 01:20:00 +0000 Subject: Import my recent 1:1 threading working. some features improved includes: 1. fast simple type mutex. 2. __thread tls works. 3. asynchronous cancellation works ( using signal ). 4. thread synchronization is fully based on umtx, mainly, condition variable and other synchronization objects were rewritten by using umtx directly. those objects can be shared between processes via shared memory, it has to change ABI which does not happen yet. 5. default stack size is increased to 1M on 32 bits platform, 2M for 64 bits platform. As the result, some mysql super-smack benchmarks show performance is improved massivly. Okayed by: jeff, mtm, rwatson, scottl --- lib/libthr/thread/thr_mutex_protocol.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'lib/libthr/thread/thr_mutex_protocol.c') diff --git a/lib/libthr/thread/thr_mutex_protocol.c b/lib/libthr/thread/thr_mutex_protocol.c index 56c8622555a3..526cbe08a050 100644 --- a/lib/libthr/thread/thr_mutex_protocol.c +++ b/lib/libthr/thread/thr_mutex_protocol.c @@ -31,6 +31,7 @@ * * $FreeBSD$ */ + #include #include #include @@ -43,19 +44,28 @@ __weak_reference(_pthread_mutexattr_setprotocol, pthread_mutexattr_setprotocol); int _pthread_mutexattr_getprotocol(pthread_mutexattr_t *mattr, int *protocol) { - if (*mattr == NULL) - return (EINVAL); - *protocol = (*mattr)->m_protocol; - return(0); + int ret = 0; + + if ((mattr == NULL) || (*mattr == NULL)) + ret = EINVAL; + else + *protocol = (*mattr)->m_protocol; + + return(ret); } int _pthread_mutexattr_setprotocol(pthread_mutexattr_t *mattr, int protocol) { - if (*mattr == NULL || protocol < PTHREAD_PRIO_NONE || - protocol > PTHREAD_PRIO_PROTECT) - return (EINVAL); - (*mattr)->m_protocol = protocol; - (*mattr)->m_ceiling = PTHREAD_MAX_PRIORITY; - return(0); + int ret = 0; + + if ((mattr == NULL) || (*mattr == NULL) || + (protocol < PTHREAD_PRIO_NONE) || (protocol > PTHREAD_PRIO_PROTECT)) + ret = EINVAL; + else { + (*mattr)->m_protocol = protocol; + (*mattr)->m_ceiling = THR_MAX_PRIORITY; + } + return(ret); } + -- cgit v1.2.3