LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-09-2009, 06:29 PM   #1
saurin
Member
 
Registered: Aug 2008
Posts: 50

Rep: Reputation: 0
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.
 
Old 09-10-2009, 04:23 AM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Bookworm (Fluxbox WM)
Posts: 1,391
Blog Entries: 54

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bandwith priority / scheduling? MasterOfTheWind Linux - Software 4 07-02-2007 11:17 AM
LXer: Influence scheduling priority with nice and renice LXer Syndicated Linux News 0 11-29-2006 11:33 PM
Thread Scheduling using POSIX THREAD rameshtekumudi Programming 3 09-01-2006 10:47 AM
Priority Scheduling with Pthreads gs_martin Programming 0 06-28-2006 09:08 AM
Scheduling priority for the 'nice' command savoiu Linux - Newbie 2 05-18-2004 11:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration