LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-30-2009, 11:26 PM   #1
aloktiagi
LQ Newbie
 
Registered: Jul 2009
Posts: 20

Rep: Reputation: 0
increasing the load on the CPU


i need to write a code to increase the load on the cpu to some x percentage

the value x should be given by the user

how can i go about achieving this
 
Old 07-30-2009, 11:57 PM   #2
karamarisan
Member
 
Registered: Jul 2009
Location: Illinois, US
Distribution: Fedora 11
Posts: 374

Rep: Reputation: 55
What's this for? Not homework, I trust?
 
Old 07-31-2009, 12:42 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,355

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
The OS is a dynamic env, it'll only be at a given load for a fraction of a second.
If you have the system only running the bare minimum OS, plus your program, you should be able to get your prog to fork new processes and check the load until you get close to the number you want.
It's trial and error.
For cpu load, use a prog that just does basic calcns, that'll make it cpu bound.
 
Old 07-31-2009, 12:56 AM   #4
aloktiagi
LQ Newbie
 
Registered: Jul 2009
Posts: 20

Original Poster
Rep: Reputation: 0
thanks for the reply.

Will doing calculations cause the kernel to lower the priority of my program thus not getting the necessary results?

also can it put fork() inside a loop for some definite iterations and see the cpu usage increase. Won't the kernel terminate this fork() loop?
 
  


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
cpu utilization and cpu load soltanloo Linux - General 1 06-07-2009 02:19 AM
CPU load monitoring Igrushkin Linux - Software 2 06-03-2009 06:17 AM
Which site is increasing cpu load praveenyadav Linux - Software 1 09-09-2007 04:21 AM
Generate alert with "CPU load average" "CPU utilization" viky Linux - Hardware 3 07-25-2007 04:24 AM
Cpu load at 59% when idle stubbe Linux - General 12 09-26-2006 01:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:48 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