Why is flags being backed up before calling cli
Dave Hylands
dhylands at gmail.com
Fri Jan 21 02:06:50 EST 2011
Hi Kashyap,
Sending to the group this time.
On Thu, Jan 20, 2011 at 11:00 PM, C K Kashyap <ckkashyap at gmail.com> wrote:
> Hi,
> I noticed that the flags register is being stored before doing 'cli' and
> then restored after calling 'sti'. - eg. in local_irq_save and
> local_irq_restore
> Can someone tell me the scenario that is being guarded against by backing up
> flags?
The flags typically includes the interrupt status register.
If you have nested calls to local_irq_save/restore, like follows
assume interrupts are enabled here
local_irq_save
interrupts are now disabled
local_irq_save
interrupts should continue to be disabled
local_irq_restore
At this point interrupts should be restored to the state they were
at save time (i.e. disabled)
If you didn't save the flags, then you wouldn't know whether to
enable or disable interrupts at this point.
local_irq_restore
At this point interrupts should be restored to the state they were at
save time (i.e. enabled).
Dave Hylands
More information about the Kernelnewbies
mailing list