Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / cpu usage problem

Author
Message
Oak
21
Years of Service
User Offline
Joined: 13th Sep 2002
Location:
Posted: 3rd Feb 2005 23:17
Does anyone else have a problem where your programs have a game loop that runs over and over and that loop takes up close to 100% of your cpu's time? That's great when the game is running I guess, but my game is a windowed mode game so I can do other tasks while the game runs and it's impossible to load another program when my game is running because the cpu is totally hogged up by the DB game. Any suggestions?

Thanks,

Oak

There are 10 kinds of people in this world. Those that understand binary and those that don't.
CattleRustler
Retired Moderator
20
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 3rd Feb 2005 23:21
its not a bug, its a feature.

BealziBob
19
Years of Service
User Offline
Joined: 9th Jul 2004
Location: The Grim North (UK)
Posted: 3rd Feb 2005 23:28
SYNC OFF, will solve your problem, but you will have to work out a replacement timing routine.

Oak
21
Years of Service
User Offline
Joined: 13th Sep 2002
Location:
Posted: 3rd Feb 2005 23:37
But if you're just drawing a few sprites to the screen and checking for mouse clicks in a chess style game, why on earth would sync on cause such an enormous resource drain? Even firing up Unreal or Battle for Middle Earth (memory hog) they don't suck up 90% of my cpu.

There are 10 kinds of people in this world. Those that understand binary and those that don't.
Narf The Mouse
19
Years of Service
User Offline
Joined: 16th Jul 2004
Location:
Posted: 5th Feb 2005 02:51
Maybe it's the sync command. I havn't looked into it, but is there any way to check if the game is windowed and if it is, to not sync to the screen?

Cheese!
Cryptoman
20
Years of Service
User Offline
Joined: 24th Nov 2003
Location: Utah Mountains
Posted: 5th Feb 2005 03:55
Because its a feature. It really is. But if your program is sitting idle use sync off. There are ways to see if your window has focus or if there has been any input. You can't play a game with sync off cause then your program only gets attention when windows feels like it. Sync on hogs the cpu so windows don't do what sync off does. Makes your program #1 priority.


RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 5th Feb 2005 04:31
Also, other sync setting seem to affect the system as well (though I haven't played around to figure them all out). FastSync for example:
Quote: "FASTSYNC
This command will perform a regular SYNC command, and will skip processing a mandatory check for windows messages."


Setting the Sync Rate too high (assuming it's on) seems to force the system to start calculating the next frame(s?) before the previous frame is finished drawing, which results in lower performance than setting the Sync Rate at a happy number that doesn't overlap frame calcs.

One program had these results ompc:
Sync Rate 250: FPS < 120
Sync Rate 150: FPS = 110 to 166

"Droids don't rip your arms off when they lose." -H. Solo

REALITY II
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 5th Feb 2005 04:42
DirectX does that. There is no workaround.

1800+ XP - GeforceFX 5600 - 256MbDDR - 60Gb Hdd - XP Pro (SP2)
Clueless
20
Years of Service
User Offline
Joined: 16th Feb 2004
Location: Corbin, KY, USA
Posted: 5th Feb 2005 09:17
Windoze traditionally has very poor resource management when compared to operating systems that were designed to be multi-process/multi-user from the beginning. It follows the "give until it hurts" philosophy when it comes to CPU time, memory allocation, max disk I/O rates, etc. Controlling how much CPU time can be allocated to a given process, how much physical memory it can consume, etc. is an exercise in futility and often cannot be done on Windows since it wasn't designed that way.

When Win NT was on the drawing board, the rumor was big changes were in the works because a principal designer was one of the VAX/VMS architects from Digital Equipment Corporation, and VMS had superb resource management. You could set limits on CPU usage, memory usage, etc. Process priorities determined access to resources and bumps/decrements in priorities followed algorithms that allowed the administrator to build fairness into resource allocation. Unix development followed a similar thread (bad pun, sorry).

Alas, it wasn't meant to be. Big flaws in NT 3 grew into V4 which grew into Win 2000 and XP, which grew into... well, you get the picture. It's very hard to do any kind of resource management on a Win platform. The concept doesn't exist in most cases. You can still bring any Windows server to its knees with a simple program that consumes the physical memory or hogs the CPU.

Maybe this isn't such a bad thing for PC's anyway -- if you're running a game then that's really where your attention is focused anyway. Think of the PC as a dedicated game console while you're playing. It's not really a problem with SYNC in DBPro, it's what does or doesn't happen when you issue (or don't issue) SYNC. You can cause the same problems with a Visual Basic program or C# program or any other programmingh language, without ever bringing DirectX into the picture.

[end of sermon, sorry about that]

Login to post a reply

Server time is: 2024-05-19 18:52:31
Your offset time is: 2024-05-19 18:52:31