Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 09-09-2005, 05:09 AM   #1
Registered: Aug 2003
Posts: 66

Rep: Reputation: 15
Reserve CPU Resource


Is it possible to write a C program that trigger CPU resource reservation on RH9 kernel? Anyone has done anything relevant before?
Old 09-09-2005, 06:48 AM   #2
Registered: Nov 2004
Location: Germany
Distribution: Debian Testing
Posts: 332

Rep: Reputation: 31
I'm not quite sure what you mean. Do you want to reserve a certain CPU utilisation for your program? I doubt that this is possible, but you can set the priority of your program: man 2 setpriority
Old 09-09-2005, 10:46 AM   #3
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 7,009

Rep: Reputation: 2126Reputation: 2126Reputation: 2126Reputation: 2126Reputation: 2126Reputation: 2126Reputation: 2126Reputation: 2126Reputation: 2126Reputation: 2126Reputation: 2126
What you are generally speaking of is real-time scheduling, where the name of the game is to control the latency, or response-time, of a particular thread or task. It may also be necessary to guarantee a minimum amount of CPU-time per second to a particular thread, so that it cannot be crowded-out by another thread of greater or equal priority. So-called embedded systems, where Linux is used to control a hardware device, place a high degree of importance on these issues.
"Turn it off! TURN IT OFF! Aaaiieeee....!"
--early experiment with a robotic arm, gone terribly wrong...
Linux is not a true RTOS (real-time operating system), although there are third-party improvements (from TimeSys and other vendors) which make it very close to one. The 2.6 scheduler does make a lot of improvements in that regard, with the so-called "pre-emptible kernel" and a faster, fairer scheduler. But, at least as far as I know, the "stock" kernel does not yet allow you to "reserve" a guaranteed-minimum block of CPU time to any one thread.

The scheduler attempts to allocate CPU-time fairly among the competing tasks, respecting both their activity-patterns (I/O vs. CPU-bound, for example) and their user-set "priority" (niceness). It seeks to provide prompt (but not guaranteed) response to interrupts, respectful scheduling that also does not "starve" lower-priority threads, and a good balance among the various CPUs. But if two threads are both running at high priority, one of them can crowd-out the other such that latency or CPU-share requirements are not achieved.


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
apache2 reserve proxy hoffmanyew Linux - Software 2 05-13-2005 01:48 AM
Reserve local ip only for Router and for nobody else. RINO2004 Linux - Networking 4 07-08-2004 03:56 PM
Reserve IP in DHCP plexus Red Hat 6 03-08-2004 01:20 PM
How do I reserve an IRQ to ISA? peso Linux - Hardware 9 02-07-2004 04:20 PM
openwebmail used all CPU resource Joe_Zhu Linux - Software 0 01-07-2004 10:10 PM

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

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