Is there any way (or a useful function) to know whether interrupts are disabled or not?
Interrupts are disabled by changing the control bits in the PS (except in the case of edgetriggered interrupts). 4. The device is informed that its request has been recognized, and in response, it deactivates the interrupt-request signal.
Whenever disabling interrupts, the CPU will be unable to switch processes and processes can use shared variables without another process accessing it. The most obvious way to achieve mutual exclusion is to allow a process to disable interrupts before it enters critical sections.
The Interrupt Enable register is programmed through two addresses. To set the enable bit, you need to write to the SETENA register address; to clear the enable bit, you need to write to the CLRENA register address. In this way, enabling or disabling an interrupt will not affect other interrupt enable states.
You need to disable interrupts to ensure atomic access. You don't want any other process to access and potentially modify that variable while you're reading it.
You can use irqs_disabled()
function:
#include <linux/irqflags.h>
int i = irqs_disabled();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With