[solved] How to enable NMI

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
deste
Posts: 8
Joined: Mon May 26, 2008 9:26 am

[solved] How to enable NMI

Post by deste »

Hi,

I am currently coding task management for my OS, and am unable to activate the NMI. I tried the method described in the wiki, but without success (there is nothing that happens).

Can you tell me how to activate the NMI, knowing that this doesn't work :

Code: Select all

void NMI_enable(void)
{
	outb(0x70, inb(0x70)&0x7F);
	inb(0x71);
}
Thanks in advance.
Last edited by deste on Tue Aug 05, 2008 2:26 am, edited 1 time in total.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: How to enable NMI

Post by jal »

deste wrote:I am currently coding task management for my OS, and am unable to activate the NMI. I tried the method described in the wiki, but without success (there is nothing that happens).
That is exactly what should happen - nothing. The NMI is only triggered in rare cases, like hardware failure (although I'm not even sure it's hooked up at all on a modern PC).


JAL
deste
Posts: 8
Joined: Mon May 26, 2008 9:26 am

Re: How to enable NMI

Post by deste »

Hi,

The NMI is used for preemptive multi-task, isn't it ?

I'd like to know how to get a NMI at a regular interval, in order to switch thread.

Can I use the interruption of the clock (IRQ 0) for that ?
User avatar
Combuster
Member
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: How to enable NMI

Post by Combuster »

Under normal circumstances, you should not get an NMI, just use IRQ0 instead. If you do that kind of things in NMIs you can no longer disable interrupts for anything anymore, so you must be ready to get interrupted at all times, which is probably not what you want.

And if you have multiple sources of an NMI (which you would already have by making the clock an NMI - was it a tick or a system crash?), you can no longer tell what caused it, whereas a regular interrupt is distinguished by interrupt number.

The only way I can think of to get clock NMIs is by doing something with the IOAPIC (of which a) I don't know if it can actually do that, and b) the IOAPIC is not present on all computers, especially not older ones)
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
deste
Posts: 8
Joined: Mon May 26, 2008 9:26 am

Re: How to enable NMI

Post by deste »

Hi,

I will eventually use the IRQ0, which will allow me to hide interruptions with a CLI.

Thanks again for your help.
Post Reply