delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2005/02/23/14:45:28

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: "Maurice.Lombardi" <Maurice DOT Lombardi AT ujf-grenoble DOT fr>
Newsgroups: comp.os.msdos.djgpp
Subject: sleep() ?
Date: Wed, 23 Feb 2005 19:31:13 +0000
Organization: Universite Joseph Fourier - Grenoble 1
Lines: 59
Message-ID: <cvim1a$26ff$1@rhone.ujf-grenoble.fr>
NNTP-Posting-Host: knautie.ujf-grenoble.fr
Mime-Version: 1.0
X-Trace: rhone.ujf-grenoble.fr 1109187434 72175 152.77.56.196 (23 Feb 2005 19:37:14 GMT)
X-Complaints-To: abuse AT ujf-grenoble DOT fr
NNTP-Posting-Date: Wed, 23 Feb 2005 19:37:14 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows; U; Win98; fr-FR; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
X-Accept-Language: fr-fr, fr
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi all
I have mistakently sent here mails intended for gpc (GNU pascal)
But these mail raise a problem about DJGPP function sleep().
I translate the gpc test program in C as

#include <stdio.h>
#include <unistd.h>
#include <dos.h>

int main(void)
{
   struct _dosdate_t curdate;
   struct _dostime_t curtime;
   struct _dosdate_t olddate = {31,12,1999,0};
   struct _dostime_t oldtime = {23,59,59,50};
   struct _dosdate_t before, after;
   _dos_gettime (&curtime);
   _dos_getdate (&curdate);
   _dos_settime (&oldtime);
   _dos_setdate (&olddate);
   _dos_getdate (&before);
   sleep (2);
   _dos_getdate (&after);
   curtime.second+=2;
   _dos_settime (&curtime);
   _dos_setdate (&curdate);
   if ((before.year==1999)&&(after.year==2000))
      printf("OK\n");
   else
      printf("failed %d %d\n",before.year,after.year);
   return 0;
}

This program succeeds always when run in bare DOS:
it answers OK after a noticeable delay of 2 seconds.

But if I run it into a W98se DOS windows, it answers immediately
failed 1999 1999
without any noticeable delay, except sometimes,
presumably when an other running process introduces the needed delay.
Running under debugger (rhide) with the clock displayed from the
task bar shows that the programs performs as expected, except that
sleep() introduces no delay.

Is this already known in djgpp ?
This has little importance in the present case, which is just a test,
but may cause trouble to people who have a real reason to use sleep().

Maurice

-- 
        Maurice Lombardi
Laboratoire de  Spectrometrie Physique,
Universite Joseph Fourier de Grenoble, BP87
38402 Saint Martin d'Heres Cedex     FRANCE
Tel: 33 (0)4 76 51 47 51
Fax: 33 (0)4 76 63 54 95
mailto:Maurice DOT Lombardi AT ujf-grenoble DOT fr

- Raw text -


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