not know
Results 1 to 7 of 7

Thread: not know

  1. #1
    Senior Member
    Join Date
    Oct 2003
    Posts
    394

    not know

    Hi!
    I traing to develop my first tool for monitiring of some changes in windows but I got big problem and do not know where to look.

    I can nothing about classes and struct, difficult to understand yet. And I using just simple functions for that. "Ehhh, may be it is problem"

    I used time function for that, to pause time,

    [gloworange]
    seconds = time ( NULL ) ;
    int i = seconds;
    while ( i > seconds ) seconds = time ( NULL ) ;
    [/gloworange]

    but i getting up to 100% process usage. Do you know what to do or where I can get answer for that? PM me then.
    // too far away outside of limit

  2. #2
    Senior Member
    Join Date
    Jul 2004
    Posts
    469

    Re: not know

    Originally posted here by MrBabis
    Hi!
    I traing to develop my first tool for monitiring of some changes in windows but I got big problem and do not know where to look.

    I can nothing about classes and struct, difficult to understand yet. And I using just simple functions for that. "Ehhh, may be it is problem"

    I used time function for that, to pause time,

    [gloworange]
    seconds = time ( NULL ) ;
    int i = seconds;
    while ( i > seconds ) seconds = time ( NULL ) ;
    [/gloworange]

    but i getting up to 100% process usage. Do you know what to do or where I can get answer for that? PM me then.
    Ummm.. that code won't do anything useful I wouldn't think... Let me run through it...

    you have seconds = time (NULL);

    From that you're setting a variable called seconds to be whatever time(NULL) returns... just for simplicity, we'll pick the number 5.

    Then you have int i = seconds;

    This should set i to equal seconds... so now i=5 and seconds=5.

    Then you have while (i > seconds) seconds = time(NULL);

    Well, i is never greater than seconds because you just set them equal to each other.

    I'm not really sure what you're looking for, but I have a feeling that this snippet of code isn't setting your CPU to 100%.

  3. #3
    Senior Member
    Join Date
    Oct 2003
    Posts
    394
    oops
    "i" can be modifed simple by adding some more. And when I do that I getting 100% at CPU.

    I using Borland C++ Trial. If it do somthing.
    // too far away outside of limit

  4. #4
    Senior Member
    Join Date
    Jul 2004
    Posts
    469
    I would suggest something simple, like... output what i and seconds are during each loop. Or even comment out the loop and just output what i and seconds are before the loop and start there. I have a strange feeling that time(NULL) is returning 0.

  5. #5
    Senior Member
    Join Date
    Oct 2003
    Posts
    394
    whole code:

    #include <time.h>
    #include <iostream.h>

    int TESTER (void)
    {
    time_t seconds;

    seconds = time (NULL);

    int i=(seconds+10);
    while(i>seconds) seconds = time (NULL);
    return seconds;

    }

    exempel taken from:
    http://www.cplusplus.com/ref/ctime/time.html
    // too far away outside of limit

  6. #6
    Senior Member
    Join Date
    Jul 2004
    Posts
    469
    Ok, a couple things that I noticed.. First, shouldn't this be a main function? Secondly, you're doing an improper type comparison of time_t and int. They might be equivilent but I would suggest making them the same type. I assume that there is a method for the > operator of time_t type. I ran this code on my machine and it worked fine. 10 seconds of computing and then it quits. Try this code and tell me what you get.

    #include <time.h>
    #include <iostream.h>

    int main()
    {
    time_t seconds;

    time(&seconds);

    time_t i = seconds+10;
    while(i > seconds) {
    time(&seconds);
    printf ("Seconds: %ld \n", seconds);
    printf ("I: %ld \n", i);
    }
    return 0;

    }

  7. #7
    Senior Member
    Join Date
    Oct 2003
    Posts
    394
    I still getting high cpu usage.
    // too far away outside of limit

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •