Limiting another program from taking to much of system

This is a discussion on Limiting another program from taking to much of system within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I was wounding if C++ could limit what another program can do with in it self. Like I want ...

  1. #1
    adr
    adr is offline
    Registered User
    Join Date
    Dec 2005
    Posts
    155

    Limiting another program from taking to much of system

    Hi, I was wounding if C++ could limit what another program can do with in it self. Like I want to limited how much space, ram and cpu usage a program can use inside its self, for a exm. Program B --inside> Program A, but Program B is limited to only 1mb of ram 1mb of space and like can only use maxs of 10% or lower of the cpu to do stuff in? If not, can windows, and if so can this post please be move to windows?

  2. #2
    Registered User
    Join Date
    Dec 2004
    Posts
    465
    I don't know of anything that can do this but if you go into processes in the task manager, you can set priority by right clicking the process.
    My computer is awesome.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    C++ can't do it. Windows might be able to do it. Unix-type OSs can do it. It's called quotas, so searching for this would be profitable.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    adr
    adr is offline
    Registered User
    Join Date
    Dec 2005
    Posts
    155
    Hmmm i'll have to look harder then, and if you dont get why I am asking is, I have a program that takes around over 80-90% of the cpu (I have a 2.4GHz, 1 core) so I only want it to see like maybe 1.9 or so of that GHz witch will trick the program thinking thats my limit leaving me more cpu for me to run other programs....or trying to make it do, lol. If you come across any code for it do post the website or code for me too see, still googling it.
    Last edited by adr; 06-30-2007 at 06:39 AM.

  5. #5
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    If you can make your program block at times instead of busy-wait, that might solve some issues, Otherwise, you can programatically make the program stop working every so often by forcing it to sleep, but I think that to be a poor choice if you can avoid it.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,494
    Setting the process priority to something lower than normal would be the thing to do.

    Ideally, you want your program to have as much CPU as possible when there is absolutely nothing else to do.

    But if there is something more important, like any of your normal apps, then the OS should stop running your background program and run your normal programs.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    adr
    adr is offline
    Registered User
    Join Date
    Dec 2005
    Posts
    155
    Quote Originally Posted by Salem View Post
    Setting the process priority to something lower than normal would be the thing to do.

    Ideally, you want your program to have as much CPU as possible when there is absolutely nothing else to do.

    But if there is something more important, like any of your normal apps, then the OS should stop running your background program and run your normal programs.
    Ideally yes, but if a program thinks it only has so much (meaning it thinks the CPU is 1.9 GHz, 1mb of ram, 1mb of memory so on) and is ever crash or something else's (meaning if the program stop responding) it will only take what I give it up, not the rest of the computer making it easier to just shut the program down (going to control manger) and or letting other programs run till everything fixes (reg. cleaner). Why I kinda want to limit its processing power and other things, kinda like a safety lock.
    Last edited by adr; 06-30-2007 at 10:22 PM. Reason: Someone cant read english O.o

  8. #8
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    ...?

    can you edit that to use better grammar?

    edit:

    I think you mean like a resource cap, meaning you specify a specific limit for memory usage or cpu usage, and the program doesn't go beyond that?
    Last edited by robwhit; 07-01-2007 at 12:36 PM. Reason: I can't read english

  9. #9
    adr
    adr is offline
    Registered User
    Join Date
    Dec 2005
    Posts
    155
    Quote Originally Posted by robwhit View Post
    ...?

    can you edit that to use better grammar?

    edit:

    I think you mean like a resource cap, meaning you specify a specific limit for memory usage or cpu usage, and the program doesn't go beyond that?
    LOL, yes, what I been saying... O.o; can windows or even C++? I know you can go and change the priority or use the sleep funtion but it doesnt limit anything really.
    Last edited by adr; 07-02-2007 at 01:39 AM.

  10. #10
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    but it doesnt limit anything really.
    Do not be so sure...
    Write a program that eats all the CPU
    and run it with RT priority and with Idle priority
    And see if you can kill it using Task manager... I dobt that the results will be the same
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. using system command results in a program
    By finnepower in forum Windows Programming
    Replies: 6
    Last Post: 06-10-2005, 08:58 AM
  2. system commands. deletion of file after program terminates
    By xddxogm3 in forum C++ Programming
    Replies: 12
    Last Post: 11-24-2003, 09:41 PM
  3. How do I put my program into the system tray?
    By kinghajj in forum Windows Programming
    Replies: 1
    Last Post: 11-05-2003, 06:56 PM
  4. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 11:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21