diff options
author | Rickard Green <[email protected]> | 2010-06-01 13:52:51 +0000 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2010-06-01 13:52:51 +0000 |
commit | 0b81970d641577dfbcb7d0ba31090c4e362cf860 (patch) | |
tree | 9cd07e0fe9cdf09b65809f50fce9eef0c9eacfc0 /erts/lib_src | |
parent | 9e57c65cac4dd1c26db98bfc8d0295cbc39a28e9 (diff) | |
download | otp-0b81970d641577dfbcb7d0ba31090c4e362cf860.tar.gz otp-0b81970d641577dfbcb7d0ba31090c4e362cf860.tar.bz2 otp-0b81970d641577dfbcb7d0ba31090c4e362cf860.zip |
OTP-8661 Enable writer preferred pthread read/write locks on Linux
Writer preferred pthread read/write locks has been enabled on Linux.
Diffstat (limited to 'erts/lib_src')
-rw-r--r-- | erts/lib_src/common/ethread.c | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/erts/lib_src/common/ethread.c b/erts/lib_src/common/ethread.c index eb4d0cad20..a4ec4c448b 100644 --- a/erts/lib_src/common/ethread.c +++ b/erts/lib_src/common/ethread.c @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 2004-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 2004-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% */ @@ -269,6 +269,11 @@ static ethr_mutex no_ethrs_mtx; #warning "Cannot enforce fork-safety" #endif +#ifdef ETHR_HAVE_PTHREAD_RWLOCK_INIT +static pthread_rwlockattr_t write_pref_attr_data; +static pthread_rwlockattr_t *write_pref_attr; +#endif + /* * ---------------------------------------------------------------------------- * Static functions @@ -525,6 +530,24 @@ ethr_init(ethr_init_data *id) } #endif +#ifdef ETHR_HAVE_PTHREAD_RWLOCK_INIT +#if defined(ETHR_HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP) \ + && defined(ETHR_HAVE_PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP) + res = pthread_rwlockattr_init(&write_pref_attr_data); + if (res != 0) + goto error; + res = pthread_rwlockattr_setkind_np( + &write_pref_attr_data, + PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP); + if (res != 0) + goto error; + write_pref_attr = &write_pref_attr_data; +#else + write_pref_attr = NULL; +#endif +#endif + + return 0; error: @@ -1060,7 +1083,7 @@ ethr_rwmutex_init(ethr_rwmutex *rwmtx) } rwmtx->initialized = ETHR_RWMUTEX_INITIALIZED; #endif - return pthread_rwlock_init(&rwmtx->pt_rwlock, NULL); + return pthread_rwlock_init(&rwmtx->pt_rwlock, write_pref_attr); } int |