OSDev.org

The Place to Start for Operating System Developers
It is currently Sun Mar 24, 2019 7:10 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: new technology: multimedia timers
PostPosted: Mon Sep 05, 2005 7:11 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
you thought your latest readings about ACPI taught you whatever you wanted to know about modern interrupt management ? wrong. they managed to get yet something else: High-Precision Events Timers.

Since we were kindly asked to give notes about it on santa@megatokyo.com, i'm posting what i've found so far ...

The specifications (free for download)
http://www.intel.com/hardwaredesign/hpetspec.htm

The ICH6 (intel chipset) seems to support HPET
http://www.intel.com/design/chipsets/da ... 147302.pdf

And microsoft seems to have a nice word to say about it and why it's so great and why we should all upgrade to systems having it supported, etc :)

http://www.microsoft.com/whdc/system/CE ... =true#img1

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:new technology: multimedia timers
PostPosted: Mon Sep 05, 2005 7:38 am 
Offline
Member
Member

Joined: Wed Oct 18, 2006 11:59 am
Posts: 1600
Location: Vienna/Austria
Oh, praise ole santa for this nice piece of news, ye olden bucks! ;-)

Ah, St. Gnucius will turn green and envy will devour him.

[hilarious mode off /]

Maybe if one can afford a new board that fast, it *might* find an implementation, else *shrugs*. No Hardware to test - no implementing.

_________________
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image


Top
 Profile  
 
 Post subject: Re:new technology: multimedia timers
PostPosted: Mon Sep 05, 2005 7:50 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

From Microsoft's article:

"Current timers theoretically have a maximum resolution of 1 millisecond and an achievable resolution of 2 milliseconds because of performance concerns."

Are these morons serious?? The PIT has a resolution of roughly 838 nS - over one thousand times more precise than the 1 mS resolution they are complaining about.

"In the previous example, the clock interrupt period was lowered to 1 millisecond to play a sound at a precise time. This resulted in 10 interrupts being generated between the times 230 milliseconds and 240 milliseconds while only one interrupt was actually needed. A better approach to this problem is to only schedule an aperiodic timer interrupt when there is work to be done."

OK - so I can assume Microsoft haven't figure out how to use the PIT in "one-shot" mode then. Perhaps they should read some technical material before designing the OS? Even the RTC's periodic interrupt can handle the example they present without problems.

"Although the current timers are still in use and still function properly, they do not meet the needs of time-sensitive applications and depend on legacy technologies such as the Industry Standard Architecture (ISA) bus. To migrate away from these legacy technologies, and to eliminate redundant hardware in the chipset, a new timer is needed that can replace the existing hardware."

ROTFL - reduce the legacy stuff! I find it much more likely that it'll just add more and won't reduce the legacy stuff at all. I can't think of any single case where new technology has ever removed legacy stuff in "PC compatible" computers - the best we could hope for is "legacy emulation only" (like USB keyboard & mouse emulating the PS/s devices through SMM - arguably more messy, not less).

I wonder what the real reason Microsoft wants HPET is....

Let me see. Getting rid of ISA? Not likely, it's been gone for ages (integrated into the LPC bridge in PCI chipsets a long time ago). Getting rid of the RTC? The RTC keeps time when power is off while the HPET won't, so that isn't possible.

Getting rid of the PIT? It would be highly unusual, but if Microsoft can convince hardware manufacturers to make computers without a PIT, then OSs like Windows 9X and WIndows XP won't run on the new hardware, so people will have no choice but to upgrade to Longhorn/Vista. Maybe this is the real reason - after all Win9x and WinXP will be Microsoft's largest marketting problem.


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re:new technology: multimedia timers
PostPosted: Mon Sep 05, 2005 1:48 pm 
This actually makes me ask a completely unrelated question: Do the Pentium Pro and up have precise interrupts anymore, or is that just a legacy feature?

And just why do we need a new damned timer to program? As shown b y the previous posts, we already have 2.


Top
  
 
 Post subject: Re:new technology: multimedia timers
PostPosted: Mon Sep 05, 2005 3:02 pm 
Brendan wrote:
Are these morons serious?? The PIT has a resolution of roughly 838 nS - over one thousand times more precise than the 1 mS resolution they are complaining about.


I suspect they are talking about a design limitation in MS Windows actually ;). They also say "achievable resolution of 2 ms because of performance issues". I guess that's due to a buch of code that seriously goes wrong at a higher frequency - but not the hardware's fault.

Brendan wrote:
OK - so I can assume Microsoft haven't figure out how to use the PIT in "one-shot" mode then. Perhaps they should read some technical material before designing the OS? Even the RTC's periodic interrupt can handle the example they present without problems.


Well that's exactly what I planned to do in my implementation. Use the timer interrupt in one-shot mode for asynchronous events - I have not yet seen a problem with this.

Btw, I don't like the way they write these papers >:(. And that not only because they push shortcomings in software (read the above paragraphs) to hardware. Also some other, rather subtle things.

cheers Joe


Top
  
 
 Post subject: Re:new technology: multimedia timers
PostPosted: Mon Sep 05, 2005 3:18 pm 
I don't like in the FAT document how they say:

Quote:
Do not spend too much time trying to figure out why this math works. The basis for the computation is complicated; the important point is that this is how Microsoft operating systems do it, and it works.


erm... no, the important thing would be for us to understand it.


Top
  
 
 Post subject: Re:new technology: multimedia timers
PostPosted: Mon Sep 05, 2005 3:58 pm 
Kemp wrote:
I don't like in the FAT document how they say:

Quote:
Do not spend too much time trying to figure out why this math works. The basis for the computation is complicated; the important point is that this is how Microsoft operating systems do it, and it works.


erm... no, the important thing would be for us to understand it.


Not really. You implement a FAT driver for compatibility with Microsoft operating systems, which the majority of PC users use, making it much easier to move data between your OS and Microsoft's. If Microsoft implemented their own filesystem technically wrong, you would too, since there's no point outside of compatibility for such a stinky filesystem. The FAT document is more about how to be compatible with Microsoft's implementation of the filesystem than why and all those fascinating design (or lack thereof) details.


Top
  
 
 Post subject: Re:new technology: multimedia timers
PostPosted: Mon Sep 05, 2005 4:14 pm 
As revealed in the next sentence:

Quote:
Note, however, that this math does not work perfectly. It will occasionally set a FATSz that is up to2 sectors too large for FAT16, and occasionally up to 8 sectors too large for FAT32.


In fact, they even go on to say:

Quote:
Because it is OK to have a FATSz that is too large, at the expense of wasting a few sectors, the fact that this computation is surprisingly simple more than makes up for it being off in a safe way in some cases.


Surprisingly simple and yet too complicated to explain? As far as I'm concerned, the document writer was just being lazy (as reinforced by other comments in the document).

I have to let them off due to the humour value of the writer using the document to rant about how annoying it is having to be backward compatible though.


Top
  
 
 Post subject: Re:new technology: multimedia timers
PostPosted: Mon Sep 05, 2005 4:36 pm 
Kemp wrote:
Surprisingly simple and yet too complicated to explain?


Possibly. An algorithm can be easy to do, that doesn't mean that *why* it works is not complex.


Top
  
 
 Post subject: Re:new technology: multimedia timers
PostPosted: Mon Sep 05, 2005 6:42 pm 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

Crazed123 wrote:
This actually makes me ask a completely unrelated question: Do the Pentium Pro and up have precise interrupts anymore, or is that just a legacy feature?


Hmmm - what are precise interrupts?

Crazed123 wrote:
And just why do we need a new damned timer to program? As shown by the previous posts, we already have 2.


There's the local APIC too (3 timers!) which is much more precise as it uses a 64 bit counter and it's frequency is derived from the CPU's bus speed. Microsoft actually are correct in that power management can interfere with the accuracy of the local APIC timer, which (depending on what you use it for) may or may not be a good or bad thing. For e.g. using it to measure real time in any way is a bad idea, but using it to measure the amount of CPU time used is a good idea (IMHO it's great for schedulers, which isn't too surprising as that's what it was probably designed to be used for). They neglected to mention that hyper-threading can also make the local APIC timer a little tricky (might need some form of work-around, depending on what the local APIC timer is being used for).

As for Microsoft's article, it was probably written by the marketting department rather than anyone with any technical knowledge - an honest technical person would probably have had difficulty ("Our OS's timing is so bad we need new hardware" just doesn't sell too well :) ).

I guess one reason why they might want to shift the HPET is non-PC compatibile hardware - for example, a "media center" and/or a games machine using Intel compatible CPU/s and proprietory hardware, running a cut down version of Windows. This is probably the most likely reason I've thought of so far (i.e. use HPET as a way to reduce legacy hardware in proprietory devices rather than in 80x86 compatible computers)...


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re:new technology: multimedia timers
PostPosted: Mon Sep 05, 2005 7:20 pm 
I quote the four properties of precise interrupts, straight from textbook:
Quote:
1. The PC (Program Counter) is saved in a known place.
2. All instructions before the one pointed to by the PC have fully executed.
3. No instruction beyond the one pointed to by the PC has been executed.
4. The execution state of the instruction pointed to by the PC is known.


In the case of an x86, the PC would be the eip register. According to these properties, at least, it's easier to deal with precise interrupts for an operating system coder, and far harder for imprecise interrupts that don't give you a known state on interrupt.


Top
  
 
 Post subject: Re:new technology: multimedia timers
PostPosted: Mon Sep 05, 2005 7:48 pm 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

Crazed123 wrote:
I quote the four properties of precise interrupts, straight from textbook:
Quote:
1. The PC (Program Counter) is saved in a known place.
2. All instructions before the one pointed to by the PC have fully executed.
3. No instruction beyond the one pointed to by the PC has been executed.
4. The execution state of the instruction pointed to by the PC is known.


In the case of an x86, the PC would be the eip register. According to these properties, at least, it's easier to deal with precise interrupts for an operating system coder, and far harder for imprecise interrupts that don't give you a known state on interrupt.


Ahh - OK. In this case, all 80x86 CPUs do or don't support precise interrupts, depending on how much execution state you expect to be saved. All 80x86 CPUs behave in a similar way.

For interrupts, the CPU always saves CS, EIP and EFLAGS, and may save SS, ESP (if the interrupted code wasn't running at CPL=0 and the interrupt handler isn't using a conforming code segment), and might also save DS, ES, FS, GS (if virtual 8086 was interrupted).

Of course this depends on the IDT descriptor too - for an interrupt task gate it does a full hardware task switch, where everything is saved (except the FPU/MMX/SSE/SSE2 state), but most people never use these for performance reasons.

Typically the general registers (except for the interrupt task gate option) are not saved or restored by the CPU - this must be done by the interrupt handler itself.


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re:new technology: multimedia timers
PostPosted: Mon Sep 05, 2005 9:43 pm 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 6:06 pm
Posts: 1437
Location: Redmond, WA, USA
It never makes sense for interrupts to be imprecise (except perhaps NMIs), but sometimes it makes sense for certain exceptions. The only kind of imprecise exceptions I've heard of in practice are FP exceptions on some RISC architectures, and aborts on x86 (usually there's an option to make FP exceptions precise at the cost of performance, but on x86 they're always precise AFAIK).

From the Holy Intel Manual ;) --

Quote:
Aborts
An abort is an exception that does not always report the precise location of the instruction causing the exception and does not allow restart of the program or task that caused the exception. Aborts are used to report severe errors, such as hardware errors and inconsistent or illegal values in system tables.


The only aborts on x86 that I know of are double fault and machine-check exceptions.

_________________
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!


Top
 Profile  
 
 Post subject: Re:new technology: multimedia timers
PostPosted: Mon Sep 05, 2005 11:54 pm 
Good, now I can give Tanenbaum a good smack for scaring me with that talk of later Pentiums (after Pentium Pro) being superscalars that merely emulated precise interrupts. I had begun to think that newer processors (such as the hyperthreading P4s) might have had the feature dropped from emulation, or that precise interrupts might have been dropped from Itanium or Opteron.


Top
  
 
 Post subject: Re:new technology: multimedia timers
PostPosted: Tue Sep 06, 2005 1:45 am 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 6:06 pm
Posts: 1437
Location: Redmond, WA, USA
Crazed123 wrote:
Good, now I can give Tanenbaum a good smack for scaring me with that talk of later Pentiums (after Pentium Pro) being superscalars that merely emulated precise interrupts. I had begun to think that newer processors (such as the hyperthreading P4s) might have had the feature dropped from emulation, or that precise interrupts might have been dropped from Itanium or Opteron.


Well, they are superscalar. Any pipelined processor pretty much has to "emulate" precise interrupts by flushing the pipeline. It just gets trickier with out-of-order execution and longer FP pipelines, but that's a concern for the CPU designers fortunately. :)

_________________
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: doubletriplefault, nck and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group