system locks system time while accessing it

Good afternoon programmers heaven,

I have a timer, that checks the system time, for a specific time. After midnight sometimes, i get a Access is denied error. Can it be that the system lock the system time sometimes ?

regards

Comments

  • : Good afternoon programmers heaven,
    :
    : I have a timer, that checks the system time, for a specific time. After midnight sometimes, i get a Access is denied error. Can it be that the system lock the system time sometimes ?
    :
    : regards
    :
    That's interesting, could you post some code?


  • [b][red]This message was edited by Ripper at 2005-1-31 22:54:4[/red][/b][hr]
    : : Good afternoon programmers heaven,
    : :
    : : I have a timer, that checks the system time, for a specific time. After midnight sometimes, i get a Access is denied error. Can it be that the system lock the system time sometimes ?
    : :
    : : regards
    : :
    : That's interesting, could you post some code?
    :
    :
    :

    the following example of code, only determines if the program is busy processing or in idle mode. it will also check if almost midnight, reset all counters.

    // if processing, increment the following counter
    Inc(Processing);

    // if in idle mode, increment the following counter
    Inc(Idle_Mode);

    The_Time := Idle_Mode/60/60/24;
    Decodetime(The_Time, Idle_Hour, Idle_min ,Idle_sec, Mili);

    The_Time := Processing/60/60/24;
    Decodetime(The_Time, Proc_Hour, Proc_Min ,Proc_sec, Mili);

    Form1.Label23.Caption := Formatfloat('00',Idle_Hour)+':'+Formatfloat('00',Idle_min)+':'+Formatfloat('00',Idle_sec);
    Form1.Label24.Caption := Formatfloat('00',Proc_Hour)+':'+Formatfloat('00',Proc_Min)+':'+Formatfloat('00',Proc_Sec);

    //get the local system time
    GetLocalTime(SystemTime);
    timenow := SystemTimeToDateTime(SystemTime);

    if ((SystemTime.wHour = 23) and (SystemTime.wMinute = 59)) and ((SystemTime.wSecond = 59)) then
    begin
    Processing := 0;
    Idle_Mode := 0;
    end;


  • [b][red]This message was edited by Masterijn at 2005-2-1 1:54:40[/red][/b][hr]
    : [b][red]This message was edited by Ripper at 2005-1-31 22:54:4[/red][/b][hr]
    : : : Good afternoon programmers heaven,
    : : :
    : : : I have a timer, that checks the system time, for a specific time. After midnight sometimes, i get a Access is denied error. Can it be that the system lock the system time sometimes ?
    : : :
    : : : regards
    : : :
    : : That's interesting, could you post some code?
    : :
    : :
    : :
    :
    : the following example of code, only determines if the program is busy processing or in idle mode. it will also check if almost midnight, reset all counters.
    :
    : // if processing, increment the following counter
    : Inc(Processing);
    :
    : // if in idle mode, increment the following counter
    : Inc(Idle_Mode);
    :
    : The_Time := Idle_Mode/60/60/24;
    : Decodetime(The_Time, Idle_Hour, Idle_min ,Idle_sec, Mili);
    :
    : The_Time := Processing/60/60/24;
    : Decodetime(The_Time, Proc_Hour, Proc_Min ,Proc_sec, Mili);
    :
    : Form1.Label23.Caption := Formatfloat('00',Idle_Hour)+':'+Formatfloat('00',Idle_min)+':'+Formatfloat('00',Idle_sec);
    : Form1.Label24.Caption := Formatfloat('00',Proc_Hour)+':'+Formatfloat('00',Proc_Min)+':'+Formatfloat('00',Proc_Sec);
    :
    : //get the local system time
    : GetLocalTime(SystemTime);
    : timenow := SystemTimeToDateTime(SystemTime);
    :
    : if ((SystemTime.wHour = 23) and (SystemTime.wMinute = 59)) and ((SystemTime.wSecond = 59)) then
    : begin
    : Processing := 0;
    : Idle_Mode := 0;
    : end;
    :
    :
    :
    Just a question, do you want to measure how much time is pend on processing and how much time is spend being idle?
    Under Winnt/2000/xp this can be done with: GetProcessTimes, GetThreadTimes
    Calculating time with a timer is not advisable (The above is probably called on an ontimer event every second).
    Maybe this setup is better:
    [code]
    QueryPerformanceCounter(TimestampStart);
    try
    ProcessSomeStuff;
    finally
    QueryPerformanceCounter(TimestampEnd);
    TimeSpendProcessing := TimeSpendProcessing + TimestampEnd - TimestampStart;
    end;
    [/code]

    show in timer:
    [code]
    QueryPerformanceFrequency(TimeFreq)
    MicroSecSpendProcessing := TimeSpendProcessing / 10 / TimeFreq;
    // or
    SecSpendProcessing := TimeSpendProcessing / 10000000 / TimeFreq;
    Form1.Label23.Caption := .....
    [/code]




  • [b][red]This message was edited by Ripper at 2005-2-1 23:6:54[/red][/b][hr]
    : [b][red]This message was edited by Masterijn at 2005-2-1 1:54:40[/red][/b][hr]
    : : [b][red]This message was edited by Ripper at 2005-1-31 22:54:4[/red][/b][hr]
    : : : : Good afternoon programmers heaven,
    : : : :
    : : : : I have a timer, that checks the system time, for a specific time. After midnight sometimes, i get a Access is denied error. Can it be that the system lock the system time sometimes ?
    : : : :
    : : : : regards
    : : : :
    : : : That's interesting, could you post some code?
    : : :
    : : :
    : : :
    : :
    : : the following example of code, only determines if the program is busy processing or in idle mode. it will also check if almost midnight, reset all counters.
    : :
    : : // if processing, increment the following counter
    : : Inc(Processing);
    : :
    : : // if in idle mode, increment the following counter
    : : Inc(Idle_Mode);
    : :
    : : The_Time := Idle_Mode/60/60/24;
    : : Decodetime(The_Time, Idle_Hour, Idle_min ,Idle_sec, Mili);
    : :
    : : The_Time := Processing/60/60/24;
    : : Decodetime(The_Time, Proc_Hour, Proc_Min ,Proc_sec, Mili);
    : :
    : : Form1.Label23.Caption := Formatfloat('00',Idle_Hour)+':'+Formatfloat('00',Idle_min)+':'+Formatfloat('00',Idle_sec);
    : : Form1.Label24.Caption := Formatfloat('00',Proc_Hour)+':'+Formatfloat('00',Proc_Min)+':'+Formatfloat('00',Proc_Sec);
    : :
    : : //get the local system time
    : : GetLocalTime(SystemTime);
    : : timenow := SystemTimeToDateTime(SystemTime);
    : :
    : : if ((SystemTime.wHour = 23) and (SystemTime.wMinute = 59)) and ((SystemTime.wSecond = 59)) then
    : : begin
    : : Processing := 0;
    : : Idle_Mode := 0;
    : : end;
    : :
    : :
    : :
    : Just a question, do you want to measure how much time is pend on processing and how much time is spend being idle?
    : Under Winnt/2000/xp this can be done with: GetProcessTimes, GetThreadTimes
    : Calculating time with a timer is not advisable (The above is probably called on an ontimer event every second).
    : Maybe this setup is better:
    : [code]
    : QueryPerformanceCounter(TimestampStart);
    : try
    : ProcessSomeStuff;
    : finally
    : QueryPerformanceCounter(TimestampEnd);
    : TimeSpendProcessing := TimeSpendProcessing + TimestampEnd - TimestampStart;
    : end;
    : [/code]
    :
    : show in timer:
    : [code]
    : QueryPerformanceFrequency(TimeFreq)
    : MicroSecSpendProcessing := TimeSpendProcessing / 10 / TimeFreq;
    : // or
    : SecSpendProcessing := TimeSpendProcessing / 10000000 / TimeFreq;
    : Form1.Label23.Caption := .....
    : [/code]
    :
    :
    :
    :
    :
    Hi there, yes, you are right. I want to measure how much time is spend on processing and how much time is spend being idle? this should done in a 24 hour period, and the required timers should be reset on midnight every night. I will try and do an example what you said.

    What i also want to mention is, i create en free threads, while any thread is created, the processing counter should be incremented, and while no threads are running, the idle counter should be incremented.

    Is there another way besides an ontimer event to the the required calculations?

    thanks




  • : [b][red]This message was edited by Ripper at 2005-2-1 23:6:54[/red][/b][hr]
    : : [b][red]This message was edited by Masterijn at 2005-2-1 1:54:40[/red][/b][hr]
    : : : [b][red]This message was edited by Ripper at 2005-1-31 22:54:4[/red][/b][hr]
    : : : : : Good afternoon programmers heaven,
    : : : : :
    : : : : : I have a timer, that checks the system time, for a specific time. After midnight sometimes, i get a Access is denied error. Can it be that the system lock the system time sometimes ?
    : : : : :
    : : : : : regards
    : : : : :
    : : : : That's interesting, could you post some code?
    : : : :
    : : : :
    : : : :
    : : :
    : : : the following example of code, only determines if the program is busy processing or in idle mode. it will also check if almost midnight, reset all counters.
    : : :
    : : : // if processing, increment the following counter
    : : : Inc(Processing);
    : : :
    : : : // if in idle mode, increment the following counter
    : : : Inc(Idle_Mode);
    : : :
    : : : The_Time := Idle_Mode/60/60/24;
    : : : Decodetime(The_Time, Idle_Hour, Idle_min ,Idle_sec, Mili);
    : : :
    : : : The_Time := Processing/60/60/24;
    : : : Decodetime(The_Time, Proc_Hour, Proc_Min ,Proc_sec, Mili);
    : : :
    : : : Form1.Label23.Caption := Formatfloat('00',Idle_Hour)+':'+Formatfloat('00',Idle_min)+':'+Formatfloat('00',Idle_sec);
    : : : Form1.Label24.Caption := Formatfloat('00',Proc_Hour)+':'+Formatfloat('00',Proc_Min)+':'+Formatfloat('00',Proc_Sec);
    : : :
    : : : //get the local system time
    : : : GetLocalTime(SystemTime);
    : : : timenow := SystemTimeToDateTime(SystemTime);
    : : :
    : : : if ((SystemTime.wHour = 23) and (SystemTime.wMinute = 59)) and ((SystemTime.wSecond = 59)) then
    : : : begin
    : : : Processing := 0;
    : : : Idle_Mode := 0;
    : : : end;
    : : :
    : : :
    : : :
    : : Just a question, do you want to measure how much time is pend on processing and how much time is spend being idle?
    : : Under Winnt/2000/xp this can be done with: GetProcessTimes, GetThreadTimes
    : : Calculating time with a timer is not advisable (The above is probably called on an ontimer event every second).
    : : Maybe this setup is better:
    : : [code]
    : : QueryPerformanceCounter(TimestampStart);
    : : try
    : : ProcessSomeStuff;
    : : finally
    : : QueryPerformanceCounter(TimestampEnd);
    : : TimeSpendProcessing := TimeSpendProcessing + TimestampEnd - TimestampStart;
    : : end;
    : : [/code]
    : :
    : : show in timer:
    : : [code]
    : : QueryPerformanceFrequency(TimeFreq)
    : : MicroSecSpendProcessing := TimeSpendProcessing / 10 / TimeFreq;
    : : // or
    : : SecSpendProcessing := TimeSpendProcessing / 10000000 / TimeFreq;
    : : Form1.Label23.Caption := .....
    : : [/code]
    : :
    : :
    : :
    : :
    : :
    : Hi there, yes, you are right. I want to measure how much time is spend on processing and how much time is spend being idle? this should done in a 24 hour period, and the required timers should be reset on midnight every night. I will try and do an example what you said.
    :
    : What i also want to mention is, i create en free threads, while any thread is created, the processing counter should be incremented, and while no threads are running, the idle counter should be incremented.
    :
    : Is there another way besides an ontimer event to the the required calculations?
    :
    : thanks
    :
    If you update the same variables from different threads you
    should use a CriticalSection or the InterLocked.. functions in Windows.

    The timer is just fine for updating the screen. But shouldn't use for counting seconds. (It's not accurate enough).
    The resetting can also be done by a single shot timer. You calculate the msec towards midnight. And then you can wait that amount of time. In your case, you might just miss the 59 th second. (Because the harddrive flushed or some other time consuming something) And you don't have a day break.


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories