Page 1 of 1
need a way to sleep for 10ms or less, but!!!
Posted: Wed Sep 30, 2020 3:06 am
by ITchimp
I am writing an experimental floppy driver (1.44mb) , and need to be able to sleep for 10ms.
but my PIT timer is 50ms per tick, if I use a linked list of count down objects, the least amount of sleep time is 50ms ... so I have to use some other methods to implement 10ms delay...
Any recommendations?
Re: need a way to sleep for 10ms or less, but!!!
Posted: Wed Sep 30, 2020 8:54 am
by foliagecanine
Use a lower PIT frequency?
Re: need a way to sleep for 10ms or less, but!!!
Posted: Wed Sep 30, 2020 8:59 am
by kzinti
Surely you mean a higher frequency?
50 ms = 20Hz
10 ms = 100Hz
Re: need a way to sleep for 10ms or less, but!!!
Posted: Wed Sep 30, 2020 9:02 am
by nullplan
ITchimp wrote:I am writing an experimental floppy driver (1.44mb) , and need to be able to sleep for 10ms.
but my PIT timer is 50ms per tick,[...]
You do love your fossils, don't you?
Option 1: Speed up the PIT. The PIT is certainly capable of delivering interrupts to you quickly enough for your requirement, so just speed up the PIT, and add a software divider for the other function that uses it.
Option 2: Use a different timer. In a modern PC, you have the HPET, LAPIC timer, ACPI PM timer, and the TSC available. All of which more than capable of measuring 10ms.
Re: need a way to sleep for 10ms or less, but!!!
Posted: Wed Sep 30, 2020 9:09 am
by bzt
ITchimp wrote:I am writing an experimental floppy driver (1.44mb) , and need to be able to sleep for 10ms.
but my PIT timer is 50ms per tick, if I use a linked list of count down objects, the least amount of sleep time is 50ms ... so I have to use some other methods to implement 10ms delay...
Any recommendations?
PS/2 control port B (0x61) bit 5 is oscillating at 15 us.
SeaBIOS uses that to calibrate tsc freq, but you could poll that bit to wait for 15 us.
1. wait until it changes to get a baseline
2. as soon as the bit changes again, 15 us has elapsed
The
bochs bios implements INT 15 AH=86 (wait n microsec) directly by watching that port.
Cheers,
bzt
Re: need a way to sleep for 10ms or less, but!!!
Posted: Wed Sep 30, 2020 9:31 am
by foliagecanine
Sorry, kzinti,
Yes I did mean a higher PIT frequency.
--------------------------------------------
You can easily have a 1ms delay = 1000hz PIT with this code:
Code: Select all
outb(0x43, 0x34);
outb(0x40, 169);
outb(0x40, 4);
You'd have to adjust your sleep function though.
Re: need a way to sleep for 10ms or less, but!!!
Posted: Thu Oct 01, 2020 8:19 am
by Schol-R-LEA
Why are you sleeping, exactly? More details of your design could help, as I suspect you could avoid sleeping entirely with a slightly different approach.