Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 31st, 2005, 1:54 PM   #1
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
Setting a Script's CPU Priority

I have two scripts running on my server,
- the server-side script which handles all incoming traffic
- a server manager which automatically makes backups, configures my IP, reboots the server, etc...

The server-side script has been reconfigured through CherryPy to only take up 3-4 CPU cycles. Python by default will take up all the remaining CPU cycles.

This raises a problem. My server manager takes up %96 of my CPU, doing nothing but waiting for a checkpoint while my server-side script slowly fulfills the main purpose of the computer.

How would I flip these CPU priorities around, making CherryPy by default take up the remaining cycles (instead of 3-4), and Python only take up 3-4?
Sane is offline   Reply With Quote
Old Dec 31st, 2005, 5:27 PM   #2
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4 Arevos is on a distinguished road
If you're using Linux, or something similar, would using the renice and nice commands help?
Arevos is offline   Reply With Quote
Old Dec 31st, 2005, 7:07 PM   #3
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
Nope, windows XP. Because I needed something that could be conveniently accessed from the shared folders, and used os calls I already knew.
Sane is offline   Reply With Quote
Old Jan 1st, 2006, 10:00 AM   #4
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
There is (unsurprisingly) an os.nice method to set the priority level, but i'm not sure if this only available on posix systems. Do you have that method available?
Cerulean is offline   Reply With Quote
Old Jan 1st, 2006, 4:34 PM   #5
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
>>> import os
>>> os.nice()

Quote:
Originally Posted by Python Shell
AttributeError: 'module' object has no attribute 'nice'
=(
Sane is offline   Reply With Quote
Old Jan 1st, 2006, 10:43 PM   #6
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
FOUND IT!

=D

from os import system
system( "start /realtime c:/windows/notepad.exe" )

# /low - Priority 4
# /belownormal - Priority 6
# /normal - Priority 8
# /high - Priority 13
# /realtime - Priority 24

So that would open notepad with a priority of 24/31. Yay.
Sane is offline   Reply With Quote
Old Jan 3rd, 2006, 6:36 PM   #7
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Don't use /realtime - it can screw things up. It takes a higher priority than critical system tasks - I can't explain why, but that be a Bad Thing. Use /high.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Jan 3rd, 2006, 10:19 PM   #8
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
What's an example of a critical system task?
Sane is offline   Reply With Quote
Old Jan 4th, 2006, 9:36 AM   #9
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Y'know, I don't actually know. I'm really just spouting what I've been told, but I can kinda see why it would be a problem.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Jan 4th, 2006, 10:20 AM   #10
coldDeath
Expert Programmer
 
coldDeath's Avatar
 
Join Date: Aug 2005
Location: UK
Posts: 862
Rep Power: 3 coldDeath is on a distinguished road
Send a message via AIM to coldDeath Send a message via Yahoo to coldDeath
Well i'm guessing here. Push ctrl+alt+del and clcik the processes tab, then look for SYSTEM processes, I would assume that at least one of those is vital.
__________________
Join us at #programmingforums @ irc.freenode.net!

My software never has bugs. It just develops random features.
coldDeath is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:58 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC