OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 2:46 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Disable just timer interrupt
PostPosted: Thu May 11, 2017 5:33 am 
Offline

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


Top
 Profile  
 
 Post subject: Re: Disable just timer interrupt
PostPosted: Thu May 11, 2017 6:14 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
You can mask the interrupt in the PIC. But an OS that doesn't make use of timer interrupts seems like a bad idea.


Top
 Profile  
 
 Post subject: Re: Disable just timer interrupt
PostPosted: Thu May 11, 2017 6:17 am 
Offline

Joined: Fri Apr 07, 2017 3:45 pm
Posts: 6
Thanks! It's just while "sleeping". Are there other realizations for that?


Top
 Profile  
 
 Post subject: Re: Disable just timer interrupt
PostPosted: Thu May 11, 2017 7:01 am 
Offline
Member
Member
User avatar

Joined: Thu Jul 12, 2012 7:29 am
Posts: 723
Location: Tallinn, Estonia
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.


Top
 Profile  
 
 Post subject: Re: Disable just timer interrupt
PostPosted: Thu May 11, 2017 7:12 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
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?


Top
 Profile  
 
 Post subject: Re: Disable just timer interrupt
PostPosted: Thu May 11, 2017 8:40 am 
Offline

Joined: Fri Apr 07, 2017 3:45 pm
Posts: 6
Quote:
An occasional wakeup, followed by a long period of sleep, is hardly a problem

In what way?

Quote:
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.

Quote:
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.


Top
 Profile  
 
 Post subject: Re: Disable just timer interrupt
PostPosted: Thu May 11, 2017 8:59 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
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?


Top
 Profile  
 
 Post subject: Re: Disable just timer interrupt
PostPosted: Thu May 11, 2017 9:33 am 
Offline
Member
Member

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


Top
 Profile  
 
 Post subject: Re: Disable just timer interrupt
PostPosted: Thu May 11, 2017 3:06 pm 
Offline
Member
Member

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


Top
 Profile  
 
 Post subject: Re: Disable just timer interrupt
PostPosted: Thu May 11, 2017 5:03 pm 
Offline

Joined: Sun Apr 16, 2017 4:45 pm
Posts: 6
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot], MichaelPetch and 69 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