Hi all,
I want to have periodic triggering of a timer interrupt in all the CPU cores (including BSP), i.e. what I want is the interrupt to occur at the same time interval in all CPU cores.
The way I see it, there are two ways for achieving this:
1) Try to start all processors' LAPIC timers (which will be already configured for periodic interrupt execution) at the same time. I know that by doing this the best I can achieve is to have the LAPIC timers in-phase (as all the LAPIC timers are driven by the same source)) but not in-sync. Another negative is that each LAPIC timer tends to behave (drift) differently so I don't know how big drifting problems would I have.
2) Configure a timer (e.g. HPET) for periodic interrupts and set the I/O APIC to broadcast the interrupt to all CPUs (including self). I don't know the delivery delay that I am going to have in this case, but I guess I will have more jitter than in the 1st method.
Which one of the above do you guys think is the best way of doing this? Do you suggest a better way than the ones mentioned?
Thanks in advance for you time.
Best way of having synchronised periodic interrupts in SMP
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Best way of having synchronised periodic interrupts in S
Not performing such synchronization at all. If you truly need synchronisation, the delay you get is the longest time spent in a core to answer the interrupt plus the overhead of actually checking in each core. That means that if you get twice as many cores, you spend more than twice as many time on the overhead. A good design will only do system-wide core synchronisation a fixed number of times between boots: my OS only needs two of such synchronisation points in its lifetime.Do you suggest a better way than the ones mentioned?
That said, the number of clocks needed to communicate an interrupt across the apic bus, and the number of clocks in difference between apic timers are started not much different, and both are small compared to actually invoking the interrupt handler and any other code operating under an interrupts-disabled lock. An interrupt broadcast is therefore not observably inferior to lockstepped timers. A broadcast however has the advantage of lacking the need for any cross-core synchronisation, making it an order of magnitude simpler, and it uses only one time source rather than all but a few sources. The per-cpuness of the local apic timer has much more practical uses.
Re: Best way of having synchronised periodic interrupts in S
Hi,
I'm relatively intelligent. For example, I'm a lot smarter than a dog.
I don't think I'm more attractive than a cat; but maybe I'm just crazy.
Cheers,
Brendan
I'm relatively intelligent. For example, I'm a lot smarter than a dog.
I don't think I'm more attractive than a cat; but maybe I'm just crazy.
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.
Re: Best way of having synchronised periodic interrupts in S
I agree except for the cat thing
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
Re: Best way of having synchronised periodic interrupts in S
I've had my suspicions about Brendan before, confirmed. He's crazy.
Re: Best way of having synchronised periodic interrupts in S
Hi,
However I probably should stop posting off-topic stuff; and say something about when things appear to have occurred being far more important than when things actually occur..
Imagine if I go to the local pet shop and buy 2 cats (from the pet shop owner, a mysterious Mr Schrodinger). I put each cat into a separate box, and connect each cat to a device that kills the cat as soon as a (cheap, inaccurate) timer expires. I set both of the timers to "about 10 minutes" and seal the boxes. After a few hours of torturing puppies in another room I come back and I open both of the boxes and find 2 dead cats. As far as I know, the cats died at exactly the same time - how could I possibly know they didn't?
As long as things appear to have occurred at the same time to an observer, whether or not they actually did occur at the same time is irrelevant.
What you want is to have timer interrupts that appear to occur at the same time as far as other software can tell. So, how can other software possibly know that the timer IRQs on different CPUs didn't occur at exactly the same time?
Cheers,
Brendan
bluemoon wrote:I agree except for the cat thingBrendan wrote:I'm relatively intelligent. For example, I'm a lot smarter than a dog.
I don't think I'm more attractive than a cat; but maybe I'm just crazy.
Thanks for your support guys - it means a lot to me.Brynet-Inc wrote:I've had my suspicions about Brendan before, confirmed. He's crazy.
However I probably should stop posting off-topic stuff; and say something about when things appear to have occurred being far more important than when things actually occur..
Imagine if I go to the local pet shop and buy 2 cats (from the pet shop owner, a mysterious Mr Schrodinger). I put each cat into a separate box, and connect each cat to a device that kills the cat as soon as a (cheap, inaccurate) timer expires. I set both of the timers to "about 10 minutes" and seal the boxes. After a few hours of torturing puppies in another room I come back and I open both of the boxes and find 2 dead cats. As far as I know, the cats died at exactly the same time - how could I possibly know they didn't?
As long as things appear to have occurred at the same time to an observer, whether or not they actually did occur at the same time is irrelevant.
What you want is to have timer interrupts that appear to occur at the same time as far as other software can tell. So, how can other software possibly know that the timer IRQs on different CPUs didn't occur at exactly the same time?
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.
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: Best way of having synchronised periodic interrupts in S
And this thread has become shaped like itself.
Well played, sir, well played.
Well played, sir, well played.