Disable just timer interrupt

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
maco
Posts: 6
Joined: Fri Apr 07, 2017 3:45 pm

Disable just timer interrupt

Post by maco »

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
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Disable just timer interrupt

Post by iansjack »

You can mask the interrupt in the PIC. But an OS that doesn't make use of timer interrupts seems like a bad idea.
maco
Posts: 6
Joined: Fri Apr 07, 2017 3:45 pm

Re: Disable just timer interrupt

Post by maco »

Thanks! It's just while "sleeping". Are there other realizations for that?
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: Disable just timer interrupt

Post by dozniak »

maco wrote:Thanks! It's just while "sleeping". Are there other realizations for that?
You reprogram PIC to fire the timer exactly at the moment when you want to wake up.
Learn to read.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Disable just timer interrupt

Post by iansjack »

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?
maco
Posts: 6
Joined: Fri Apr 07, 2017 3:45 pm

Re: Disable just timer interrupt

Post by maco »

An occasional wakeup, followed by a long period of sleep, is hardly a problem

In what way?
I take it you are not doing any form of pre-emtive multitasking
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 would have thought that at some point, as your OS becomes more functional, you will want to make use of the timer interrupt.
You're right, I need the timer interrupt, but not on every cpu every time.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Disable just timer interrupt

Post by iansjack »

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?
Boris
Member
Member
Posts: 145
Joined: Sat Nov 07, 2015 3:12 pm

Re: Disable just timer interrupt

Post by Boris »

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
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: Disable just timer interrupt

Post by onlyonemac »

Boris wrote:if every task is sleeping on timer, you can program your pic to sleep not a quantum , but a whole sleep timer
...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.
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
Muf
Posts: 6
Joined: Sun Apr 16, 2017 4:45 pm
Libera.chat IRC: mf

Re: Disable just timer interrupt

Post by Muf »

onlyonemac wrote:
Boris wrote:if every task is sleeping on timer, you can program your pic to sleep not a quantum , but a whole sleep timer
...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.
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.
Post Reply