Bug 1476
| Summary: | CHOICE /T timeout bug: delay vs. sleep | ||
|---|---|---|---|
| Product: | Choice | Reporter: | jhall@freedos.org <jhall@freedos.org> |
| Component: | core | Assignee: | jhall@freedos.org <jhall@freedos.org> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | unspecified | ||
| Hardware: | PC | ||
| OS: | FreeDOS | ||
| Description: | Opened: 2002-11-18 07:13 |
|---|
------- Comment
#1 From
jhall@freedos.org
2002-11-18 07:14:00
-------
Subject: using delay() Weird. I confirmed this. When I wrote the code, I used a delay() function to wait 500ms, so the program should have a resolution of 1/2sec. The code is: > /* Grab the key. Don't exit until we found it. */ > > for (wait = 0; ; wait++) > { > if (def_wait > 0) > { > delay (500); /* wait for half a second */ > > if (kbhit()) > { > key = getch(); /* grab the key */ > } > else if ((wait * 2) > def_wait) > { > key = def_key; /* grab the default key */ > } > } > else So maybe I did something wrong? If you use /T:y,5 then this part of the loop should execute at max 10 times (1/2sec * 10 = 5sec). I wonder if delay() isn't working properly on faster hardware???
------- Comment
#2 From
jhall@freedos.org
2003-02-23 19:20:22
-------
Changing owernship to Jim Hall
------- Comment
#3 From
Eric (EA)
2003-03-23 08:24:46
-------
Hi, you should really use sleep(seconds) rather than delay(milliseconds), because delay() often gets the timing wrong if you use an old compiler along with a fast CPU. Sleep uses the clock time so it is more reliable. Delay often uses a delay loop. You can also read out the timer tick counter at $40:[$60] to have some reliable clock with even 1/18 second resolution.
------- Comment
#4 From
jhall@freedos.org
2003-03-29 22:36:20
-------
Fixed in version 3.7. Thanks!