summaryrefslogtreecommitdiff
path: root/muse2/muse/thread.cpp
diff options
context:
space:
mode:
authorTim E. Real <termtech@rogers.com>2011-02-13 22:19:33 +0000
committerTim E. Real <termtech@rogers.com>2011-02-13 22:19:33 +0000
commitb1c3f0d7ccce8feafa9f043aa5a4ee32bc78624e (patch)
treee478c71255065f0f0d0ab883771a8b2b4c244a3c /muse2/muse/thread.cpp
parentab1e5cf55eec23a64eed68835a5f0bd6b2ad0a39 (diff)
Fixed MusE failing with non-RT kernel.
Fixed dummy audio thread not running FIFO with RT kernel.
Diffstat (limited to 'muse2/muse/thread.cpp')
-rw-r--r--muse2/muse/thread.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/muse2/muse/thread.cpp b/muse2/muse/thread.cpp
index 444d5219..8e89a862 100644
--- a/muse2/muse/thread.cpp
+++ b/muse2/muse/thread.cpp
@@ -63,7 +63,8 @@ void Thread::start(int prio, void* ptr)
// pthread_mutex_lock(&lock);
- if (_realTimePriority) {
+ //if (_realTimePriority) {
+ if (realTimeScheduling && _realTimePriority > 0) { // p4.0.16
attributes = (pthread_attr_t*) malloc(sizeof(pthread_attr_t));
pthread_attr_init(attributes);
@@ -98,14 +99,26 @@ void Thread::start(int prio, void* ptr)
*/
- int rv;
- if ((rv = pthread_create(&thread, attributes, ::loop, this)))
+ int rv = pthread_create(&thread, attributes, ::loop, this);
+ if(!thread)
{
- fprintf(stderr, "creating thread <%s> failed: %s\n",
- _name, strerror(rv));
- thread = 0;
+ // p4.0.16: realTimeScheduling is unreliable. It is true even in some clearly non-RT cases.
+ // I cannot seem to find a reliable answer to the question of "are we RT or not".
+ // MusE was failing with a stock kernel because of PTHREAD_EXPLICIT_SCHED.
+ // So we'll just have to try again without attributes.
+ if (realTimeScheduling && _realTimePriority > 0)
+ rv = pthread_create(&thread, NULL, ::loop, this);
}
+ if(rv || !thread)
+ fprintf(stderr, "creating thread <%s> failed: %s\n", _name, strerror(rv));
+
+ if (attributes) // p4.0.16
+ {
+ pthread_attr_destroy(attributes);
+ free(attributes);
+ }
+
//undoSetuid();
}
@@ -316,7 +329,7 @@ void Thread::loop()
if (debugMsg)
printf("Thread <%s, id %p> has %s priority %d\n",
_name, (void *)pthread_self(), policy == SCHED_FIFO ? "SCHED_FIFO" : "SCHED_OTHER",
- _realTimePriority);
+ policy == SCHED_FIFO ? _realTimePriority : 0);
// pthread_mutex_lock(&lock);