PIT vs. APIC Timer

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

PIT vs. APIC Timer

Post by Love4Boobies »

Everyone today seems to be using the PIT for counters and scheduling in their kernel. I've been doing a bit of reading on APIC, xAPIC and x2APIC and I thought about using the APIC Timer instead. I realize that this hardware is not always present, but if it's not, the PIT could be used instead. Doing it this way would give programmers (when APIC is present) an extra counter to use in their software (which would otherwise be used by the kernel). Any comments?
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Everyone today seems to be using the PIT for counters and scheduling in their kernel.
Not quite true - I'm using the local APIC timers and have come across many others on this forum doing the same thing. In fact, using the local APIC makes sense, because you have a separate time source for each CPU, rather than scheduling everything from a single IRQ.

If you are designing primarily for x86_64, you can pretty much assume that a local APIC will be present.

Cheers,
Adam
User avatar
einsteinjunior
Member
Member
Posts: 90
Joined: Tue Sep 11, 2007 6:42 am

Post by einsteinjunior »

Hi,
The local apic frequency is pretty much dependent on the Motherboard speed.So getting accurate timing will depend on the motherboard frequency.
How do you guys do to cope with that?
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Hi,

Have a look at this topic, which is referenced from the APIC wiki article. It does still mean relying on the PIT initially.

Cheers,
Adam
User avatar
einsteinjunior
Member
Member
Posts: 90
Joined: Tue Sep 11, 2007 6:42 am

Post by einsteinjunior »

Hi,
The local apic frequency is pretty much dependent on the Motherboard speed.So getting accurate timing will depend on the motherboard frequency.
How do you guys do to cope with that?
User avatar
einsteinjunior
Member
Member
Posts: 90
Joined: Tue Sep 11, 2007 6:42 am

Post by einsteinjunior »

I took a look at the article.
The only thing i can say is that you guys practice Witchcraft :D
Where do you get your ideas from.
You are too powerful for me.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

AJ wrote:Have a look at this topic, which is referenced from the APIC wiki article. It does still mean relying on the PIT initially.
What about laptops with constantly changing speeds? Or does this only affect the CPU speed, but not the bus speed the APIC speed is derived from?


JAL
User avatar
einsteinjunior
Member
Member
Posts: 90
Joined: Tue Sep 11, 2007 6:42 am

Post by einsteinjunior »

Do the frequency of laptops actually change?
If its the case then it will be somehow hard to use the APIC on laptops.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

einsteinjunior wrote:Do the frequency of laptops actually change?
If its the case then it will be somehow hard to use the APIC on laptops.
The CPU frequency definitely does, but I'm not sure whether other frequencies (e.g. bus frequency) do as well, that's why I asked.


JAL
User avatar
einsteinjunior
Member
Member
Posts: 90
Joined: Tue Sep 11, 2007 6:42 am

Post by einsteinjunior »

It would have surprised me because the components connected to the motherboard bus usually have constant frequency,so it would have been difficult from the design point of view to change the motherboard frequency yet maintaining the same speed for the components.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

I would certainly think it's possible - overclockers motherboards have been available for a while which allow you to change the FSB (am I using outdated terminology?) frequency, whilst keeping the PCI frequency unchanged.

As to whether laptops do this to save power, someone with more hardware knowlege needs to answer. Brendan, perhaps would know the answer?

Cheers,
Adam
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Post by Brendan »

Hi,
AJ wrote:I would certainly think it's possible - overclockers motherboards have been available for a while which allow you to change the FSB (am I using outdated terminology?) frequency, whilst keeping the PCI frequency unchanged.

As to whether laptops do this to save power, someone with more hardware knowlege needs to answer. Brendan, perhaps would know the answer?
IMHO it's safe to assume that the bus speed is either:
  • - set to a fixed frequency via. motherboard jumpers (typical for old CPUs).
    - set to a constant frequency by the BIOS (typical for newer CPUs). In this case it may be theoretically possible to change the bus speed via. software (e.g. some sort of motherboard driver).
Note 1: This includes FSB and hyper-transport.
Note 2: AFAIK for hyper-transport the width of the link can also be changed.
Note 3: To reduce power consumption, I assume that for hyper-transport the width of the link is reduced while the frequency of the link remains the same (as this allows part of the link to be turned off completely, rather than remaining on while operating at a slower speed with the same power consumption at idle).
Note 4: For now, I'm guessing Intel's CSI will have similar characteristics to AMD's hyper-transport.

Basically, unless your OS includes a "motherboard driver" that's capable of changing the bus speed (using chipset specific magics), then it's safe to assume that the bus speed (and therefore the local APIC timer speed) is constant under all scenarios (including power management in laptops).


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.
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Post by 01000101 »

The FSB can be changed independant of the PCI bus speed, which that can also be changed independant of a PCI-e 16's individual bus speed.

Also, some mobo's such as mine, allow you to drop/raise the cpu multiplier, so IMHO finding the default fixed values can sometimes be horribly incorrect.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Post by bewing »

It sounds, then, like there has to be a method for a Mobo driver to broadcast to the rest of the system when there is an FSB speed change -- so the rest of the system knows to recalibrate timing.
z180
Member
Member
Posts: 32
Joined: Tue Mar 04, 2008 12:32 pm

Post by z180 »

a lot of os cant change the internal timing frequency
Post Reply