Disable just timer interrupt
Disable just timer interrupt
Hey there,
is there any chance to disable the timer interrupt only? I want to idle my cpus, until there is work for them. If I halt them (sure with enabled interrupts for wakeup), they will wake up on every timer interrupt.
Thank you
is there any chance to disable the timer interrupt only? I want to idle my cpus, until there is work for them. If I halt them (sure with enabled interrupts for wakeup), they will wake up on every timer interrupt.
Thank you
Re: Disable just timer interrupt
You can mask the interrupt in the PIC. But an OS that doesn't make use of timer interrupts seems like a bad idea.
Re: Disable just timer interrupt
Thanks! It's just while "sleeping". Are there other realizations for that?
Re: Disable just timer interrupt
You reprogram PIC to fire the timer exactly at the moment when you want to wake up.maco wrote:Thanks! It's just while "sleeping". Are there other realizations for that?
Learn to read.
Re: Disable just timer interrupt
If your timer routine does nothing, why worry? An occasional wakeup, followed by a long period of sleep, is hardly a problem. The proportion of time spent processing the interrupt will be minimal compared to the halt period.
I take it you are not doing any form of pre-emtive multitasking or maintaining a time-since-boot function (otherwise you certainly wouldn't want to disable timer interrupts).
I would have thought that at some point, as your OS becomes more functional, you will want to make use of the timer interrupt. Why not plan for it now rather than having to rewrite things in the future?
I take it you are not doing any form of pre-emtive multitasking or maintaining a time-since-boot function (otherwise you certainly wouldn't want to disable timer interrupts).
I would have thought that at some point, as your OS becomes more functional, you will want to make use of the timer interrupt. Why not plan for it now rather than having to rewrite things in the future?
Re: Disable just timer interrupt
An occasional wakeup, followed by a long period of sleep, is hardly a problem
In what way?
I do, but sometimes, some processors have no work, so they could sleep, until they have. I want to save power with halting the cpus.I take it you are not doing any form of pre-emtive multitasking
You're right, I need the timer interrupt, but not on every cpu every time.I would have thought that at some point, as your OS becomes more functional, you will want to make use of the timer interrupt.
Re: Disable just timer interrupt
The question is not in what way is it not a problem, but in what way is it a problem.
For an interrupt routine to check whether there is work for a particular core to do takes just a few instructions. The time between timer ticks is enough for hundreds of thousands of instructions. The overhead of waking the core to check at each timer tick is negligible - probably far less of an impact than incorporating logic to disable the interrupt for the core and re-enable it.
But, if you still want to do this, doesn't the APIC allows you to route interrupts to a particular core?
For an interrupt routine to check whether there is work for a particular core to do takes just a few instructions. The time between timer ticks is enough for hundreds of thousands of instructions. The overhead of waking the core to check at each timer tick is negligible - probably far less of an impact than incorporating logic to disable the interrupt for the core and re-enable it.
But, if you still want to do this, doesn't the APIC allows you to route interrupts to a particular core?
Re: Disable just timer interrupt
Your scheduler have to know when to be wake up.
It may be a quantum (ex 1ms) but if every task is sleeping on timer, you can program your pic to sleep not a quantum , but a whole sleep timer
It may be a quantum (ex 1ms) but if every task is sleeping on timer, you can program your pic to sleep not a quantum , but a whole sleep timer
-
- Member
- Posts: 1146
- Joined: Sat Mar 01, 2014 2:59 pm
Re: Disable just timer interrupt
...which is probably more trouble than it's worth, especially considering that this situation will only ever happen occasionally (if ever) and this is likely to introduce bugs into the scheduler.Boris wrote:if every task is sleeping on timer, you can program your pic to sleep not a quantum , but a whole sleep timer
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.
Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
Re: Disable just timer interrupt
This is called timer coalescing and all major OSes including Linux and Windows do it because of the gains in battery saving on mobile platforms. You program a one-shot timer for the shortest timer duration requested by all tasks combined and on wake-up you re-evaluate what the next shortest period should be and program another one-shot timer, etc.onlyonemac wrote:...which is probably more trouble than it's worth, especially considering that this situation will only ever happen occasionally (if ever) and this is likely to introduce bugs into the scheduler.Boris wrote:if every task is sleeping on timer, you can program your pic to sleep not a quantum , but a whole sleep timer