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).
Last edited by neonsignal; 09-10-2009 at 04:33 AM.
|