LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   need to find the appropriate thread scheduling and priority (https://www.linuxquestions.org/questions/programming-9/need-to-find-the-appropriate-thread-scheduling-and-priority-754004/)

saurin 09-09-2009 06:29 PM

need to find the appropriate thread scheduling and priority
 
I am new to thread programming. I need to generate one thread in one process using posix thread. Which scheduling and priority do i need to use? I want to generate the thread with the lowest priority. As i know there are 3 scheduling policy available SCHED_FIFO, SCHED_RR or SCHED_OTHAR.

neonsignal 09-10-2009 04:23 AM

Normally you would create application processes with priority 0, and they will be scheduled using SCHED_OTHER. The SCHED_OTHER is a hybrid scheduling algorithm, where the processes are scheduled on the basis both of the nice level and on how long the process has been ready to be run. It works well in a desktop environment where processes tend to be competitive rather than cooperative.

The other priority levels are intended only for system processes (ie, they require superuser privileges). They have two scheduling algorithms, both of which are a bit more deterministic than the SCHED_OTHER algorithms. The SCHED_FIFO algorithm cycles through processes of the same priority, letting the processes themselves decide when to switch (which reduces switching overheads). The SCHED_RR algorithm cycles through processes of the same priority, but restricts the time period that each runs for (which provides control over latencies).

Each process is by default a single thread of execution. Creating a thread within in a process means you have two threads within the process. If in doubt, just let created threads inherit the scheduling from the parent.

Sometimes people use prioritization to make up for deficiencies in their interprocess communications (which is misguided). It is best to learn about process communication and how to avoid deadlocks before using multiple priorities/scheduling algorithms. Scheduling is really about improving performance (particular for time critical threads/processes).


All times are GMT -5. The time now is 07:53 PM.