removing thread prioritization for writer, streamer and tcp threads

This commit is contained in:
Dhanya Maliakal 2017-05-16 14:45:48 +02:00
parent a182ca3660
commit 001d6415bf
5 changed files with 21 additions and 12 deletions

View File

@ -41,7 +41,7 @@
#define DUMMY_PACKET_VALUE 0xFFFFFFFF #define DUMMY_PACKET_VALUE 0xFFFFFFFF
#define LISTENER_PRIORITY 99 #define LISTENER_PRIORITY 90
#define PROCESSOR_PRIORITY 90 #define PROCESSOR_PRIORITY 70
#define STREAMER_PRIORITY 80 #define STREAMER_PRIORITY 10
#define TCP_PRIORITY 50 #define TCP_PRIORITY 10

View File

@ -187,8 +187,9 @@ void DataProcessor::SetGeneralData(GeneralData* g) {
int DataProcessor::SetThreadPriority(int priority) { int DataProcessor::SetThreadPriority(int priority) {
struct sched_param param; struct sched_param param;
param.sched_priority = priority; param.sched_priority = priority;
if (pthread_setschedparam(thread, SCHED_RR, &param) == EPERM) if (pthread_setschedparam(thread, SCHED_FIFO, &param) == EPERM)
return FAIL; return FAIL;
FILE_LOG(logINFO) << "Processor Thread Priority set to " << priority;
return OK; return OK;
} }

View File

@ -151,8 +151,9 @@ void DataStreamer::SetGeneralData(GeneralData* g) {
int DataStreamer::SetThreadPriority(int priority) { int DataStreamer::SetThreadPriority(int priority) {
struct sched_param param; struct sched_param param;
param.sched_priority = priority; param.sched_priority = priority;
if (pthread_setschedparam(thread, SCHED_RR, &param) == EPERM) if (pthread_setschedparam(thread, SCHED_FIFO, &param) == EPERM)
return FAIL; return FAIL;
FILE_LOG(logINFO) << "Streamer Thread Priority set to " << priority;
return OK; return OK;
} }

View File

@ -187,8 +187,9 @@ void Listener::SetGeneralData(GeneralData*& g) {
int Listener::SetThreadPriority(int priority) { int Listener::SetThreadPriority(int priority) {
struct sched_param param; struct sched_param param;
param.sched_priority = priority; param.sched_priority = priority;
if (pthread_setschedparam(thread, SCHED_RR, &param) == EPERM) if (pthread_setschedparam(thread, SCHED_FIFO, &param) == EPERM)
return FAIL; return FAIL;
FILE_LOG(logINFO) << "Listener Thread Priority set to " << priority;
return OK; return OK;
} }

View File

@ -644,26 +644,27 @@ void UDPStandardImplementation::SetThreadPriorities() {
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it){ for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it){
if ((*it)->SetThreadPriority(LISTENER_PRIORITY) == FAIL) { if ((*it)->SetThreadPriority(LISTENER_PRIORITY) == FAIL) {
FILE_LOG(logWARNING) << "No root privileges to prioritize threads"; FILE_LOG(logWARNING) << "No root privileges to prioritize listener threads";
return; return;
} }
} }
/*
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){ for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){
if ((*it)->SetThreadPriority(PROCESSOR_PRIORITY) == FAIL) { if ((*it)->SetThreadPriority(PROCESSOR_PRIORITY) == FAIL) {
FILE_LOG(logWARNING) << "No root privileges to prioritize threads"; FILE_LOG(logWARNING) << "No root privileges to prioritize writer threads";
return; return;
} }
} }
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){ for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){
if ((*it)->SetThreadPriority(STREAMER_PRIORITY) == FAIL) { if ((*it)->SetThreadPriority(STREAMER_PRIORITY) == FAIL) {
FILE_LOG(logWARNING) << "No root privileges to prioritize threads"; FILE_LOG(logWARNING) << "No root privileges to prioritize streamer threads";
return; return;
} }
} }
struct sched_param tcp_param; struct sched_param tcp_param;
tcp_param.sched_priority = TCP_PRIORITY; tcp_param.sched_priority = TCP_PRIORITY;
if (pthread_setschedparam(pthread_self(),5 , &tcp_param) != EPERM) { if (pthread_setschedparam(pthread_self(),5 , &tcp_param) != EPERM) {
FILE_LOG(logWARNING) << "No root privileges to prioritize threads"; FILE_LOG(logWARNING) << "No root privileges to prioritize tcp threads";
return; return;
} }
@ -675,6 +676,11 @@ void UDPStandardImplementation::SetThreadPriorities() {
if (dataStreamEnable) if (dataStreamEnable)
osfn << ", Streamer:" << STREAMER_PRIORITY; osfn << ", Streamer:" << STREAMER_PRIORITY;
*/
ostringstream osfn;
osfn << "Priorities set - "
"Listener:" << LISTENER_PRIORITY;
FILE_LOG(logINFO) << osfn.str(); FILE_LOG(logINFO) << osfn.str();
} }