views:

336

answers:

2

Hello!

Is it possible to disable all interrupts with a ASM/C/C++ program to get full control about the processor?

If yes -> how?

If not -> how do "atomic" operation system calls work (for example entering a critical section)?

Sorry for my English! Thanks for your help!

+2  A: 

on x86 and most other modern processors you can get atomic instructions. Ones that are GURANTEED not to be finished executing before another thread/processor can access that memory.

Under Win32 you have the Interlocked* functions that abstract that from you on supported platforms.

On a MIPS a lot of instruction can have a .I added to the end of the instruction to guarantee interlocking.

Goz
On a x86 you can prefix certain instructions with "lock" to make them atomic.
drhirsch
Ahh thanks :) It had to be something like that :)
Goz
can you give me a source-code example please?
someone
For what platform? If its for windows then http://msdn.microsoft.com/en-us/library/ms684122(VS.85).aspx
Goz
+1  A: 

In x86 assembly the the commands are

  • sti set interrupt disable bit
  • cli clear interrupt disable bit

These commands set and clear the IF Flag. They don't work in unprivileged mode (usually everything higher than ring 0, depending on IOPL) though.

Ludwig Weinzierl