8

I have a question pertaining to time quantum given to processes and threads in windows and linux.

I know operating systems in general give a fixed amount of time quantum per thread. (I know time quantum changes depending on foreground or background threads. May also change depending on the priority of a process.)

Is there a fixed time quantum per process? For eg. If OS gives 36 time quantum per process and if a process has 2 threads then each will get 18 quantum. If number of threads becomes 3 then each will get 12.

However, if a fixed quantum per process does not exist and OS gives fix quantum per thread(No dependency on the parent process.) then I may be able to make my process more efficient by spawning multiple threads.(Assuming I dont have two many mutex/semaphores in my code.)

I have an application which runs on both OS(Windows and linux). So, I am asking it in a general sense.

Thanks

3
  • Where did this awful term 'quantum' come from? 99.99% of all threads never run for anything approaching the OS timer scheduling interval before getting blocked on I/O, another thread or some other system call. I thought 'quanta' were supposed to be indivisible? Stupid term that gives misleading impressions! Aug 24, 2012 at 20:58
  • You may wanna check this: support.microsoft.com/kb/259025 Aug 24, 2012 at 21:00
  • smith - M$, I should'a guessed... Aug 25, 2012 at 0:03

2 Answers 2

1

On linux from a scheduling perspective threads and processes are equivalent. So if a process spawns two threads, each should get 36 quantum. Although I would like to hear this from someone with greater credibility than mine to confirm.

3
  • 1
    Windows too. The scheduler deals with threads, not processes. Aug 24, 2012 at 23:37
  • @Harry: In that case, a process can steal more time by having multiple threads. Is this statement right? Aug 28, 2012 at 17:02
  • Yes, although calling it "stealing" seems slightly odd. :-) Aug 28, 2012 at 22:14
1

Quite an interesting question :)

I do not really have the exact details, but from the link below you can see that the modern OS has an estimate based method of thread scheduling.

http://technet.microsoft.com/en-us/magazine/2007.02.vistakernel.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.