[pulseaudio-commits] r1837 - in /branches/lennart: ./ src/daemon/ src/modules/ src/pulse/ src/pulsecore/ src/tests/
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Sun Sep 16 17:32:52 PDT 2007
Author: lennart
Date: Mon Sep 17 02:32:51 2007
New Revision: 1837
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1837&root=pulseaudio&view=rev
Log:
use priority inheritance on mutexes where applicable
Modified:
branches/lennart/configure.ac
branches/lennart/src/daemon/main.c
branches/lennart/src/modules/module-combine.c
branches/lennart/src/pulse/thread-mainloop.c
branches/lennart/src/pulsecore/asyncmsgq.c
branches/lennart/src/pulsecore/memblock.c
branches/lennart/src/pulsecore/mutex-posix.c
branches/lennart/src/pulsecore/mutex.h
branches/lennart/src/pulsecore/once-posix.c
branches/lennart/src/tests/thread-test.c
Modified: branches/lennart/configure.ac
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/configure.ac?rev=1837&root=pulseaudio&r1=1836&r2=1837&view=diff
==============================================================================
--- branches/lennart/configure.ac (original)
+++ branches/lennart/configure.ac Mon Sep 17 02:32:51 2007
@@ -296,6 +296,22 @@
#### POSIX threads ####
ACX_PTHREAD
+
+AC_MSG_CHECKING([for PTHREAD_PRIO_INHERIT])
+AC_LANG_CONFTEST([AC_LANG_SOURCE([[
+#include <pthread.h>
+int main() { int i = PTHREAD_PRIO_INHERIT; }]])])
+$PTHREAD_CC conftest.c $PTHREAD_CFLAGS $CFLAGS $PTHREAD_LIBS -o conftest > /dev/null 2> /dev/null
+ret=$?
+rm -f conftest.o conftest
+
+if test $ret -eq 0 ; then
+ AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], 1, [Have PTHREAD_PRIO_INHERIT.])
+ AC_MSG_RESULT([yes])
+else
+ AC_MSG_RESULT([no])
+fi
+
#### Large File-Support (LFS) ####
Modified: branches/lennart/src/daemon/main.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/daemon/main.c?rev=1837&root=pulseaudio&r1=1836&r2=1837&view=diff
==============================================================================
--- branches/lennart/src/daemon/main.c (original)
+++ branches/lennart/src/daemon/main.c Mon Sep 17 02:32:51 2007
@@ -330,7 +330,7 @@
}
static void libtool_init(void) {
- pa_assert_se(libtool_mutex = pa_mutex_new(1));
+ pa_assert_se(libtool_mutex = pa_mutex_new(TRUE, FALSE));
pa_assert_se(lt_dlmutex_register(libtool_lock, libtool_unlock, libtool_set_error, libtool_get_error) == 0);
pa_assert_se(lt_dlinit() == 0);
}
Modified: branches/lennart/src/modules/module-combine.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/module-combine.c?rev=1837&root=pulseaudio&r1=1836&r2=1837&view=diff
==============================================================================
--- branches/lennart/src/modules/module-combine.c (original)
+++ branches/lennart/src/modules/module-combine.c Mon Sep 17 02:32:51 2007
@@ -947,7 +947,7 @@
u->thread_info.master = u->master = NULL;
u->time_event = NULL;
u->adjust_time = DEFAULT_ADJUST_TIME;
- u->mutex = pa_mutex_new(0);
+ u->mutex = pa_mutex_new(FALSE, TRUE);
pa_thread_mq_init(&u->thread_mq, m->core->mainloop);
u->rtpoll = NULL;
u->thread = NULL;
Modified: branches/lennart/src/pulse/thread-mainloop.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulse/thread-mainloop.c?rev=1837&root=pulseaudio&r1=1836&r2=1837&view=diff
==============================================================================
--- branches/lennart/src/pulse/thread-mainloop.c (original)
+++ branches/lennart/src/pulse/thread-mainloop.c Mon Sep 17 02:32:51 2007
@@ -103,7 +103,7 @@
return NULL;
}
- m->mutex = pa_mutex_new(1);
+ m->mutex = pa_mutex_new(TRUE, FALSE);
m->cond = pa_cond_new();
m->accept_cond = pa_cond_new();
m->thread = NULL;
Modified: branches/lennart/src/pulsecore/asyncmsgq.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/asyncmsgq.c?rev=1837&root=pulseaudio&r1=1836&r2=1837&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/asyncmsgq.c (original)
+++ branches/lennart/src/pulsecore/asyncmsgq.c Mon Sep 17 02:32:51 2007
@@ -67,7 +67,7 @@
PA_REFCNT_INIT(a);
pa_assert_se(a->asyncq = pa_asyncq_new(size));
- pa_assert_se(a->mutex = pa_mutex_new(0));
+ pa_assert_se(a->mutex = pa_mutex_new(FALSE, TRUE));
a->current = NULL;
return a;
Modified: branches/lennart/src/pulsecore/memblock.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/memblock.c?rev=1837&root=pulseaudio&r1=1836&r2=1837&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/memblock.c (original)
+++ branches/lennart/src/pulsecore/memblock.c Mon Sep 17 02:32:51 2007
@@ -660,7 +660,7 @@
p = pa_xnew(pa_mempool, 1);
- p->mutex = pa_mutex_new(1);
+ p->mutex = pa_mutex_new(TRUE, TRUE);
p->semaphore = pa_semaphore_new(0);
p->block_size = PA_PAGE_ALIGN(PA_MEMPOOL_SLOT_SIZE);
@@ -781,7 +781,7 @@
pa_assert(cb);
i = pa_xnew(pa_memimport, 1);
- i->mutex = pa_mutex_new(1);
+ i->mutex = pa_mutex_new(TRUE, TRUE);
i->pool = p;
i->segments = pa_hashmap_new(NULL, NULL);
i->blocks = pa_hashmap_new(NULL, NULL);
@@ -909,18 +909,22 @@
int pa_memimport_process_revoke(pa_memimport *i, uint32_t id) {
pa_memblock *b;
+ int ret = 0;
pa_assert(i);
pa_mutex_lock(i->mutex);
- if (!(b = pa_hashmap_get(i->blocks, PA_UINT32_TO_PTR(id))))
- return -1;
+ if (!(b = pa_hashmap_get(i->blocks, PA_UINT32_TO_PTR(id)))) {
+ ret = -1;
+ goto finish;
+ }
memblock_replace_import(b);
+finish:
pa_mutex_unlock(i->mutex);
- return 0;
+ return ret;
}
/* For sending blocks to other nodes */
@@ -934,7 +938,7 @@
return NULL;
e = pa_xnew(pa_memexport, 1);
- e->mutex = pa_mutex_new(1);
+ e->mutex = pa_mutex_new(TRUE, TRUE);
e->pool = p;
PA_LLIST_HEAD_INIT(struct memexport_slot, e->free_slots);
PA_LLIST_HEAD_INIT(struct memexport_slot, e->used_slots);
Modified: branches/lennart/src/pulsecore/mutex-posix.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/mutex-posix.c?rev=1837&root=pulseaudio&r1=1836&r2=1837&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/mutex-posix.c (original)
+++ branches/lennart/src/pulsecore/mutex-posix.c Mon Sep 17 02:32:51 2007
@@ -40,14 +40,19 @@
pthread_cond_t cond;
};
-pa_mutex* pa_mutex_new(int recursive) {
+pa_mutex* pa_mutex_new(pa_bool_t recursive, pa_bool_t inherit_priority) {
pa_mutex *m;
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
-
+
if (recursive)
pa_assert_se(pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) == 0);
+
+#ifdef HAVE_PTHREAD_PRIO_INHERIT
+ if (inherit_priority)
+ pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT);
+#endif
m = pa_xnew(pa_mutex, 1);
pa_assert_se(pthread_mutex_init(&m->mutex, &attr) == 0);
Modified: branches/lennart/src/pulsecore/mutex.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/mutex.h?rev=1837&root=pulseaudio&r1=1836&r2=1837&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/mutex.h (original)
+++ branches/lennart/src/pulsecore/mutex.h Mon Sep 17 02:32:51 2007
@@ -24,9 +24,17 @@
USA.
***/
+#include <pulsecore/macro.h>
+
typedef struct pa_mutex pa_mutex;
-pa_mutex* pa_mutex_new(int recursive);
+/* Please think twice before enabling priority inheritance. This is no
+ * magic wand! Use it only when the potentially priorized threads are
+ * good candidates for it. Don't use this blindly! Also, note that
+ * only very few operating systems actually implement this, hence this
+ * is merely a hint. */
+pa_mutex* pa_mutex_new(pa_bool_t recursive, pa_bool_t inherit_priority);
+
void pa_mutex_free(pa_mutex *m);
void pa_mutex_lock(pa_mutex *m);
void pa_mutex_unlock(pa_mutex *m);
Modified: branches/lennart/src/pulsecore/once-posix.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/once-posix.c?rev=1837&root=pulseaudio&r1=1836&r2=1837&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/once-posix.c (original)
+++ branches/lennart/src/pulsecore/once-posix.c Mon Sep 17 02:32:51 2007
@@ -58,7 +58,7 @@
return 0;
}
- pa_assert_se(m = pa_mutex_new(0));
+ pa_assert_se(m = pa_mutex_new(FALSE, FALSE));
pa_mutex_lock(m);
if (pa_atomic_ptr_cmpxchg(&control->mutex, NULL, m))
Modified: branches/lennart/src/tests/thread-test.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/tests/thread-test.c?rev=1837&root=pulseaudio&r1=1836&r2=1837&view=diff
==============================================================================
--- branches/lennart/src/tests/thread-test.c (original)
+++ branches/lennart/src/tests/thread-test.c Mon Sep 17 02:32:51 2007
@@ -98,7 +98,7 @@
assert(pa_thread_is_running(pa_thread_self()));
- mutex = pa_mutex_new(0);
+ mutex = pa_mutex_new(FALSE, FALSE);
cond1 = pa_cond_new();
cond2 = pa_cond_new();
tls = pa_tls_new(pa_xfree);
More information about the pulseaudio-commits
mailing list