From fab6bff3106e4a468be4ecc10a9d383666bb6edc Mon Sep 17 00:00:00 2001 From: Curtis Rubel Date: Thu, 1 Dec 2016 16:36:20 -0500 Subject: [PATCH 1/3] Fixed compile time errors that occur when you have ALLOW_PRIORITY_SCHEDULING defined. I also replaced all printf's with OSGNOTIFY to get this more inline with the rest of OSG CGR --- src/OpenThreads/pthreads/PThread.cpp | 47 ++++++++++++++++++---------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/src/OpenThreads/pthreads/PThread.cpp b/src/OpenThreads/pthreads/PThread.cpp index 5cead3ce0..f58d798b4 100644 --- a/src/OpenThreads/pthreads/PThread.cpp +++ b/src/OpenThreads/pthreads/PThread.cpp @@ -52,17 +52,19 @@ #endif #include +#include #include "PThreadPrivateData.h" #include using namespace OpenThreads; - +/* #ifdef DEBUG # define DPRINTF(arg) printf arg #else # define DPRINTF(arg) #endif +*/ //----------------------------------------------------------------------------- // Initialize the static unique ids. @@ -191,7 +193,8 @@ private: int status = pthread_setspecific(PThreadPrivateData::s_tls_key, thread); if (status) { - printf("Error: pthread_setspecific(,) returned error status, status = %d\n",status); + OSG_NOTICE<<"pthread_setspecific(,) returned error status: "<getProcessId(), - strerror(status)); + OSG_NOTICE<<"THREAD INFO - ID("<getProcessId()<<") : Get sched: "<getProcessId(), + strerror(status));*/ } else { - printf( + OSG_NOTICE<<"THREAD INFO - ID("<getProcessId()<<") :\ + Thread running at "<<(my_policy == SCHED_FIFO ? "SCHEDULE_FIFO" + : (my_policy == SCHED_RR ? "SCHEDULE_ROUND_ROBIN" + : (my_policy == SCHED_OTHER ? "SCHEDULE_OTHER" + : "UNKNOWN")))<<"/ Priority: "<<\ + my_param.sched_priority<getProcessId(), + (int)thread->getProcessId(), (my_policy == SCHED_FIFO ? "SCHEDULE_FIFO" : (my_policy == SCHED_RR ? "SCHEDULE_ROUND_ROBIN" : (my_policy == SCHED_OTHER ? "SCHEDULE_OTHER" : "UNKNOWN"))), - my_param.sched_priority); + my_param.sched_priority);*/ max_priority = sched_get_priority_max(my_policy); min_priority = sched_get_priority_min(my_policy); - printf( + OSG_NOTICE<<"THREAD INFO - ID("<getProcessId()<<") :\ + Max priority: "<getProcessId(), - max_priority, min_priority); + (int)thread->getProcessId(), + max_priority, min_priority);*/ } } else { - printf( + OSG_NOTICE<<"THREAD INFO - ID("<getProcessId()<<") :\ + POSIX Priority scheduling not available"<getProcessId()); + (int)thread->getProcessId());*/ } fflush(stdout); @@ -472,7 +486,8 @@ void Thread::Init() int status = pthread_key_create(&PThreadPrivateData::s_tls_key, NULL); if (status) { - printf("Error: pthread_key_create(,) returned error status, status = %d\n",status); + OSG_NOTICE<<"pthread_key_create() returned error status: "<threadPriority = priority; - if(pd->isRunning) + if(pd->isRunning()) return ThreadPrivateActions::SetThreadSchedulingParams(this); else return 0; @@ -869,7 +884,7 @@ int Thread::setSchedulePolicy(ThreadPolicy policy) pd->threadPolicy = policy; - if(pd->isRunning) + if(pd->isRunning()) return ThreadPrivateActions::SetThreadSchedulingParams(this); else return 0; From c829ecf08fc9f63f3ab1874fd00f3ac6031552ae Mon Sep 17 00:00:00 2001 From: Curtis Rubel Date: Fri, 2 Dec 2016 08:05:30 -0500 Subject: [PATCH 2/3] Removed all OSGNOTIFY messages and put back all printf output as requested. Sorry about this mixup, I was not aware that this particular directory was to be considered a separate project and must not rely on any dependencies from the rest of the OSG project. All OSGNOTIFY messages have been removed and the previous printf statements have been put back. --- src/OpenThreads/pthreads/PThread.cpp | 35 ++++++++-------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/src/OpenThreads/pthreads/PThread.cpp b/src/OpenThreads/pthreads/PThread.cpp index f58d798b4..b805331ec 100644 --- a/src/OpenThreads/pthreads/PThread.cpp +++ b/src/OpenThreads/pthreads/PThread.cpp @@ -52,7 +52,6 @@ #endif #include -#include #include "PThreadPrivateData.h" #include @@ -193,8 +192,7 @@ private: int status = pthread_setspecific(PThreadPrivateData::s_tls_key, thread); if (status) { - OSG_NOTICE<<"pthread_setspecific(,) returned error status: "<getProcessId()<<") : Get sched: "<getProcessId(), - strerror(status));*/ + strerror(status)); } else { - OSG_NOTICE<<"THREAD INFO - ID("<getProcessId()<<") :\ - Thread running at "<<(my_policy == SCHED_FIFO ? "SCHEDULE_FIFO" - : (my_policy == SCHED_RR ? "SCHEDULE_ROUND_ROBIN" - : (my_policy == SCHED_OTHER ? "SCHEDULE_OTHER" - : "UNKNOWN")))<<"/ Priority: "<<\ - my_param.sched_priority<getProcessId(), (my_policy == SCHED_FIFO ? "SCHEDULE_FIFO" : (my_policy == SCHED_RR ? "SCHEDULE_ROUND_ROBIN" : (my_policy == SCHED_OTHER ? "SCHEDULE_OTHER" : "UNKNOWN"))), - my_param.sched_priority);*/ + my_param.sched_priority); max_priority = sched_get_priority_max(my_policy); min_priority = sched_get_priority_min(my_policy); - OSG_NOTICE<<"THREAD INFO - ID("<getProcessId()<<") :\ - Max priority: "<getProcessId(), - max_priority, min_priority);*/ - + max_priority, min_priority); } } else { - OSG_NOTICE<<"THREAD INFO - ID("<getProcessId()<<") :\ - POSIX Priority scheduling not available"<getProcessId());*/ + (int)thread->getProcessId()); } fflush(stdout); @@ -486,8 +472,7 @@ void Thread::Init() int status = pthread_key_create(&PThreadPrivateData::s_tls_key, NULL); if (status) { - OSG_NOTICE<<"pthread_key_create() returned error status: "< Date: Fri, 2 Dec 2016 08:07:15 -0500 Subject: [PATCH 3/3] Missed the printf define at the top of this file. Put back this: #ifdef DEBUG # define DPRINTF(arg) printf arg #else # define DPRINTF(arg) #endif I think that should do it now... --- src/OpenThreads/pthreads/PThread.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenThreads/pthreads/PThread.cpp b/src/OpenThreads/pthreads/PThread.cpp index b805331ec..e8d48b5ce 100644 --- a/src/OpenThreads/pthreads/PThread.cpp +++ b/src/OpenThreads/pthreads/PThread.cpp @@ -57,13 +57,13 @@ #include using namespace OpenThreads; -/* + #ifdef DEBUG # define DPRINTF(arg) printf arg #else # define DPRINTF(arg) #endif -*/ + //----------------------------------------------------------------------------- // Initialize the static unique ids.