Thread: CPU time-sharing

  1. #1
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708

    CPU time-sharing

    What is the general idea for doling out X% of CPU time to each operation?

    Generalizations are o.k.

    Code is fine,too.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    It enables a single processor to apparently do more than one thing at a time. Is that what you mean?
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    No, no.

    Let's say we have a theoretical application.

    Now in this application, we have one specific task(such as video, say) which we would like to dedicate more CPU time than Windows would have allocated for that task(assuming Windows reserves the same amount for each task). How would this be addressed?

    Further, let's say we have a task that requires much less CPU time than Windows would have allocated for that task(again, assuming that Windows reserves the same amount for each and every task). How could I give the instuctions to lessen this dedicated CPU time?(This second question may be moot since the task probably would volantarily release the CPU before it's (alloted)"time" runs out anyway).

    So how do I control/modify this process?

    That's the general idea,anyway.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    101
    This is explained in great detail in the MSDN in the part about Processes and Threads. Take a look at the Scheduling Priorities article.
    - lmov

  5. #5
    Fingerstyle Guitarist taylorguitarman's Avatar
    Join Date
    Aug 2001
    Posts
    564
    I think that's more of an OS thing than a programming thing.
    I suppose you might try using threads in the app. That way you can suspend process execution of certain parts of the program, but if you're looking to specify a time I"m not sure how you do it if you even can. (It defeats the purpose of a multitasking system)

    -if there were a way to specify the section of your code as a critical block then the OS shouldn't interrupt its execution, at least that's in theory.
    Last edited by taylorguitarman; 08-16-2001 at 02:33 PM.
    If a tree falls in the forest, and no one is around to see it, do the other trees make fun of it?

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Thanx lmov...

    That link was exactly what I was looking for!

    I will bookmark the site for further reference...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  7. #7
    Banned
    Join Date
    May 2004
    Posts
    55
    yes 1+1 is 2

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. clock()
    By C_ntua in forum C Programming
    Replies: 19
    Last Post: 10-08-2008, 11:45 AM
  2. Determine the closest departure time
    By Kyeong in forum C Programming
    Replies: 9
    Last Post: 10-07-2008, 08:06 PM
  3. Execution Time - Rijandael encryption
    By gamer4life687 in forum C++ Programming
    Replies: 5
    Last Post: 09-20-2008, 09:25 PM
  4. Upgrading my old CPU (for another old one!)
    By foxman in forum Tech Board
    Replies: 16
    Last Post: 01-11-2008, 05:41 PM
  5. CPU time / thread tool
    By Carlos in forum Windows Programming
    Replies: 2
    Last Post: 01-31-2003, 09:11 AM