summaryrefslogtreecommitdiffstats
path: root/lib/libthr/thread/thr_init.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2016-02-28 17:52:33 +0000
committerkib <kib@FreeBSD.org>2016-02-28 17:52:33 +0000
commite76eb4255b957aa73f6228dd8d525d1946e3707d (patch)
tree93354adb0a612a635964c8498072087760a0f93b /lib/libthr/thread/thr_init.c
parent800b1f3198ded0c65c024ea0cef1f44d4bc59fed (diff)
downloadFreeBSD-src-e76eb4255b957aa73f6228dd8d525d1946e3707d.zip
FreeBSD-src-e76eb4255b957aa73f6228dd8d525d1946e3707d.tar.gz
Implement process-shared locks support for libthr.so.3, without
breaking the ABI. Special value is stored in the lock pointer to indicate shared lock, and offline page in the shared memory is allocated to store the actual lock. Reviewed by: vangyzen (previous version) Discussed with: deischen, emaste, jhb, rwatson, Martin Simmons <martin@lispworks.com> Tested by: pho Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'lib/libthr/thread/thr_init.c')
-rw-r--r--lib/libthr/thread/thr_init.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c
index e0400e4..3c81299 100644
--- a/lib/libthr/thread/thr_init.c
+++ b/lib/libthr/thread/thr_init.c
@@ -91,13 +91,15 @@ struct pthread_attr _pthread_attr_default = {
struct pthread_mutex_attr _pthread_mutexattr_default = {
.m_type = PTHREAD_MUTEX_DEFAULT,
.m_protocol = PTHREAD_PRIO_NONE,
- .m_ceiling = 0
+ .m_ceiling = 0,
+ .m_pshared = PTHREAD_PROCESS_PRIVATE,
};
struct pthread_mutex_attr _pthread_mutexattr_adaptive_default = {
.m_type = PTHREAD_MUTEX_ADAPTIVE_NP,
.m_protocol = PTHREAD_PRIO_NONE,
- .m_ceiling = 0
+ .m_ceiling = 0,
+ .m_pshared = PTHREAD_PROCESS_PRIVATE,
};
/* Default condition variable attributes: */
@@ -387,6 +389,7 @@ static void
init_main_thread(struct pthread *thread)
{
struct sched_param sched_param;
+ int i;
/* Setup the thread attributes. */
thr_self(&thread->tid);
@@ -428,9 +431,9 @@ init_main_thread(struct pthread *thread)
thread->cancel_enable = 1;
thread->cancel_async = 0;
- /* Initialize the mutex queue: */
- TAILQ_INIT(&thread->mutexq);
- TAILQ_INIT(&thread->pp_mutexq);
+ /* Initialize the mutex queues */
+ for (i = 0; i < TMQ_NITEMS; i++)
+ TAILQ_INIT(&thread->mq[i]);
thread->state = PS_RUNNING;
@@ -463,6 +466,7 @@ init_private(void)
_thr_once_init();
_thr_spinlock_init();
_thr_list_init();
+ __thr_pshared_init();
_thr_wake_addr_init();
_sleepq_init();
_single_thread = NULL;
OpenPOWER on IntegriCloud