LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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
 
LinkBack Search this Thread
Old 08-19-2006, 07:13 AM   #1
vkmgeek
Member
 
Registered: Feb 2006
Location: Ahmedabad
Distribution: rhel5
Posts: 185
Blog Entries: 2

Rep: Reputation: 31
thread scheduling


Hi All,
How the threads are scheduled in Linux?
I have written one program. I have created two threads. I am passing two variables for scheduling policies. One is having FIFO and other is having RR. I am passing first variable when creating first thread and second variable when creating second thread?
HOw these two thread will be scheduled?
 
Old 08-19-2006, 10:14 AM   #2
randyding
Member
 
Registered: May 2004
Posts: 552

Rep: Reputation: 30
Hi,
I understand why you want to know, but the real answer is you can't know how they are scheduled.
Any software that relies on or tries to predict which thread runs first, and when, is inherently broken by design.
You have to use external means to synchronize your threads in a manner consistent with your software's design.
I know everyone that starts learning to write threaded code tries to do this, but it always "mostly" or "just barely" works "most of the time".
When you move your software to a different platform with a different kernel, or to a computer with multiple processors, then it mysteriously stops working.
 
Old 08-21-2006, 10:29 AM   #3
bastl
Member
 
Registered: Sep 2003
Location: Germany/BW
Distribution: My own
Posts: 217

Rep: Reputation: 21
O.K. with root permission (get sure) you can change the scheduling of "Linux" the Kernel to FIFO or RR or...
If a process (root) changes to FIFO than that process can be sure that no other process (just IRQs also the Timer for scheduling) is running at this runtime (DOS Real Mode). So no mouse is moving and no key responds no signal is emit no X-server can work and so on.
With other scheduling the Processors time is shared with all threads. So Linux looks for the next thread in the table and give its some time also the kernel gets time like this.So if one process change to FIFO than that Process has to look for the other processes that are needed. So only functions can be (should be) called at this time, anything that returns surly!!! or can handle FIFO mode - no process can be killed in this scope! So this process have to make sure to read from the keyboard (kernel function) some time that the user have a possibility to quit that process. And at the End this process has also to make sure that the scheduling is restored to RR or whatever the scheduling was before. Other scheduling doesn't mather or you won't feel a big different.

So if your FIFO process is to get some time than it happens... only if that process returns the others can continue.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
scheduling thread gives error bndpatel Programming 1 06-24-2005 01:54 PM
Need FIFO thread scheduling policy enigma82 Programming 0 04-20-2005 07:35 AM
[thread control suggestion] add a "solved" button that the thread starter can click atom LQ Suggestions & Feedback 3 03-24-2005 11:55 AM
Main thread sending notification to child thread rajesh_b Programming 1 09-22-2004 09:15 AM
configure qt thread issue (just compiled qt w/ -thread option) cleff Linux - Software 8 05-07-2004 11:11 PM


All times are GMT -5. The time now is 05:35 AM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration