delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/04/22/07:10:58

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f
X-Authentication-Warning: new-smtp1.ihug.com.au: Host p378-tnt3.syd.ihug.com.au [203.173.133.124] claimed to be acceleron
Message-ID: <000901c1e9ee$597df600$0102a8c0@acceleron>
From: "Andrew Cottrell" <acottrel AT ihug DOT com DOT au>
To: <djgpp-workers AT delorie DOT com>
Cc: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Subject: DJGPP 3.04 & uclock_t & gcc 3.0.4 on Windows-2000
Date: Mon, 22 Apr 2002 21:09:30 +1000
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Reply-To: djgpp-workers AT delorie DOT com

I don't know if this is the correct way of doing this, but in the newsgroup
a problem with uclock() around under Win 2K and Eli has responded to the
initial query. I thought I would do some testing with the problem to see
what the underlying issue is and I found one problem with the assert()
function as follows and -

1) In the example below the "assert (start_uclock >= 0);" line sometimes
goes off with the following output:-
        DJGPP_204 D:\dj204\contrib\clock>clock
        [0] start_uclock = 0 (rv 89353211218 - base 89353211218

        [0] end_uclock = 11685 (rv 89353222903 - base 89353211218

        [1] start_uclock = 11685 (rv 89353169070 - base 89353211218

        Assertion failed at test.c line 115: start_uclock >= 0
        Exiting due to signal SIGABRT
        Raised at eip=000050cd

The problem as I see it is that the start_uclock is 11685 and as such the
assert should not have failed. The above results are from a command.com
running in full screen mode. If I run the program in a window I usually get
allot further along to a count of 10 to 12 before I get either the start or
end assert failing.

2) The following is an example of the end_uclock assert failing due to rv
going backwards.

        [10] start_uclock = 9847 (rv 89931447164 - base 89931436824
        [10] end_uclock = 10862 (rv 89931447686 - base 89931436824

        [11] start_uclock = 10862 (rv 89931448197 - base 89931436824
        [11] end_uclock = -53635 (rv 89931383189 - base 89931436824

        Assertion failed at test.c line 120: end_uclock >= 0

Is it worth looking at the uclock() code a bit more and comparing it to the
tiemr code in allegeo to see what the differences are? See point 6) in the
notes.

Programming notes on the example code:-
1) I have included a modified uclock.c in the same file as the main().
2) The modifications to the uclock() function were for testing purposes:-
    a) chaneg the name to acuclock() in order to call the modified code
    b) Create "long long ac_rv, ac_base;" and update these bfore the return
at the end of the uclock() function.
3) I used Rhide 1.5.0 with only the -g compile option
4) The DJGPP 3.04 libc is from 2nd of April.
5) I am using Windows XP.
6) I have used the timer code from Allegro in a comms program and it works
on Windows XP.



On Mon, 22 Apr 2002 09:39:17 +0300 (IDT), in comp.os.msdos.djgpp you wrote:

>
>On Mon, 22 Apr 2002, Alex Vinokur wrote:
>
>> | I can suggest two possible explanations:
>> |
>> |   - the C++ library has a bug when printing long long variables via
>> |     cout (did you try an equivalent C program?);
>>
>>
>> An equivalent C program usually generates  the same result (sometimes it
works OK).
>
>Which leaves us with the other alternative:
>
>> |   - uclock tries to reprogram the system timer chip, but Windows 2000,
>> |     being of the NT family, doesn't let you do so.
>
>This doesn't really surprise me: reprogramming the timer on a
>multi-programming OS is something that needs a lot of support in the DOS
>emulator, since the OS cannot let you reprogram the _real_ timer.  And
>the DOS emulator of the NT family is known as one that implements only
>the bare minimum.  Programming the SVGA registers doesn't work for the
>same reason.


int main()
{
#define TOTAL_TIMES 1000

int  i;

uclock_t start_uclock;
uclock_t end_uclock;

  for (i = 0; i < TOTAL_TIMES; i++)
  {
    start_uclock = acuclock();
    printf ("[%d] start_uclock = %lld (rv %lld - base %lld \n\n", i,
end_uclock, ac_rv, ac_base);
    fflush (NULL);
    assert (start_uclock >= 0);            /* THIS IS THE START ASSERT !!!!!
*/

    end_uclock = acuclock();
    printf ("[%d] end_uclock = %lld (rv %lld - base %lld \n\n", i,
end_uclock, ac_rv, ac_base);
    fflush (NULL);
    assert (end_uclock >= 0);

    assert (start_uclock < end_uclock);
  }

  return 0;


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019