Jump to content
OMRON Forums

Setting thread priorities in C code


Guest DavisG

Recommended Posts

Guest DavisG

In your background C code you can set priorities to get the speed up. You will not want to set it higher than 49 as this can starve your real time processes.

 

In your c code use the following lines:

 

#include //this is before the main routine code

 

//now in the main code:

 

struct sched_param param;

param.__sched_priority = 49; // from 1 - 100. 100 Highest // 1 lowest

pthread_setschedparam(pthread_self(), SCHED_FIFO, &param);

 

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

In your background C code you can set priorities to get the speed up. You will not want to set it higher than 49 as this can starve your real time processes.

 

Hello Davis. Just to clarify, when you say setting to 50 or higher will starve the realtime processes are you saying that the delta tau "system" RTOS threads (RTI, progs, etc) are set at 50 and higher?

 

Thank you,

KEJR

 

 

 

Link to comment
Share on other sites

To clarify how we currently set the priorities. Our background thread which executes the PLC's and checks the watch dog is 50. The CPLC's which are triggered by the background operate at 51. The RTI CPLC is 75. A thread with a higher priority will preempt the scheduling of a lower priority thread. Also with the fifo scheduler if you do not release your thread ie. with a yield or nanosleep you will cause a hang.
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...