Commit acbb66c3 authored by Your Name's avatar Your Name
Browse files

.

parent e6de9525
No preview for this file type
......@@ -4,6 +4,9 @@
//
// Olivier Chamoux <olivier.chamoux@fr.thalesgroup.com>
// notice, ZMQ as well as LSL spawns its own threads. So it
// makes a difference at which point in the code you set
// the real time scheduling options
#include <zmq.h>
#include "zhelpers.hpp"
......@@ -89,18 +92,23 @@ int rtpriority(int n)
memset (&sched, 0, sizeof(sched)) ;
if (n > sched_get_priority_max (SCHED_RR))
sched.sched_priority = sched_get_priority_max (SCHED_RR) ;
if (n > sched_get_priority_max (SCHED_FIFO))
sched.sched_priority = sched_get_priority_max (SCHED_FIFO) ;
else
sched.sched_priority = n ;
return sched_setscheduler (0, SCHED_RR, &sched) ;
return sched_setscheduler (0, SCHED_FIFO, &sched) ;
}
int main (int argc, const char *argv[])
{
parse_options(argc, argv);
if (rtpriority(10) < 0) {
perror("rtpriority");
return 1;
}
// make a new stream_info and open an outlet with it
stream_info info(
info_name.c_str(),
......@@ -117,14 +125,14 @@ int main (int argc, const char *argv[])
// set priority
// GW: check threads with 'ps -mLca'
void * c = (void *) context;
zmq_ctx_set(c,ZMQ_THREAD_SCHED_POLICY,SCHED_RR);
zmq_ctx_set(c,ZMQ_THREAD_PRIORITY,90);
if (rtpriority(89) < 0) {
perror("rtpriority");
return 1;
}
//void * c = (void *) context;
//zmq_ctx_set(c,ZMQ_THREAD_SCHED_POLICY,SCHED_FIFO);
//zmq_ctx_set(c,ZMQ_THREAD_PRIORITY,10);
//if (rtpriority(10) < 0) {
//perror("rtpriority");
//return 1;
//}
// Socket facing clients
zmq::socket_t frontend (context, ZMQ_SUB);
......
......@@ -198,19 +198,19 @@ int rtpriority(int n)
memset (&sched, 0, sizeof(sched)) ;
if (n > sched_get_priority_max (SCHED_RR))
sched.sched_priority = sched_get_priority_max (SCHED_RR) ;
if (n > sched_get_priority_max (SCHED_FIFO))
sched.sched_priority = sched_get_priority_max (SCHED_FIFO) ;
else
sched.sched_priority = n ;
return sched_setscheduler (0, SCHED_RR, &sched) ;
return sched_setscheduler (0, SCHED_FIFO, &sched) ;
}
int main(int argc, const char* argv[])
{
parse_options(argc, argv);
if (rtpriority(99) < 0) {
if (rtpriority(10) < 0) {
perror("rtpriority");
return 1;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment