Re: [Geekos-devel] Re: IDE driver details
Status: Pre-Alpha
Brought to you by:
daveho
From: 'Parc' <ne...@ri...> - 2002-01-30 01:03:54
|
On Tue, Jan 29, 2002 at 06:19:48PM -0500, David Hovemeyer wrote: [snip] > > Is the idea that you'd program a one-shot timer, and wait for > it to go off? Would the resolution be sufficient? > Yes and no. I'm still researching a bit, but I'll have a design made up pretty soon, and should have an implementation pretty quickly. The basic is that I'm going to fire off the RTC with a 2x divider. That gives me a 8MHz clock. When you nanosleep, I'll fire it up, and turn it off when the timer is done. It looks stupid, though, so I'm still thinking about it. [snip] > > NOP gets optimized out by bochs, and some processors may do odd things. > > VMWare would also not like it. Another way to do it might be to watch > > the DRAM refresh status. It runs at 66Mhz, so watch it's flip-flops > > for enough time. > > Interesting idea, although wouldn't it actually be dependent on > the motherboard and processor? I realized that yes, it would be. Maybe. All my references are for older machines. I'll look some more. > [snip] > > Linux uses a hard coded loop of (roughly) the form: > > while ( count > 0 ) > --count; > > The BogoMIPS value is the result of a test that calibrates how many > iterations of this loop can execute per second. > > I looked at the Linux BogoMIPS code, and it's pretty hairy. > So, I hacked something similar into timer.c; basically, it runs > a similar loop, and determines how many iterations occur in one > timer tick. The patch is attached to this email. (I'm going to > commit it, so you can also just cvs update.) I really don't like that. The compiler can optimize that completely out if it feels like it. Also, CPU caching changes how it behaves. If something invalidates your cache while you're spinning, the timing won't be accurate. > > I haven't actually written the delay function yet, since I want to > see whether it works on real hardware. (It seems to be pretty stable > in Bochs; on my 450 MHz Ultra 60 it can execute 1464 iterations of > the loop in one tick :-) I also need to write the loop in assembly > so the same code gets executed in the delay function and the > timing function. > > -Dave BogoMIPs are just bogus. There are variables that I don't think are good to rely on. Then again, I don't do OS coding for a living, so I could be wrong... :) -parc |