1

As I was going through the Interrupt Handling in Linux, I had this question if we can make reference to the current macro pointing to the interrupted task, while the core is in hard-irq mode? Also, if this referencing is possible whatwill happen if we make a call to semaphore "down", though this is highly discouraged.?

adkuv123
  • 36
  • 2

1 Answers1

0

I believe it's possible to do, at least on x86, in the sense that it won't cause an immediate panic.

It is however ALWAYS wrong to do this. An interrupt is not associated with any task, there's no link between the interrupt and a certain task running, so there's no sensible reason to try to do this anyway. What good it the current task if it could be any task on the system?

Kristof Provost
  • 26,018
  • 2
  • 26
  • 28
  • Do you think it's architecture dependant, if we can access current from hard-irq context? Yes, I agree it's wrong to do it, but as I was walking through the semaphore code was just wondering what would be the consequence if we call down in the ISR. This was more to do with just being curious.... Will try it on my Panda board though.... – adkuv123 May 18 '12 at 09:04
  • No, it's **NEVER** allowed. It's possible that it will lead to immediate panics on certain architectures, but it is just not allowed. It doesn't even make sense to want to do it. – Kristof Provost May 18 '12 at 09:06
  • 1
    I think it's perfectly OK to access `current` from hard-IRQ, but you should know what you're looking at (the interrupted task, not necessarily related to the IRQ in any way). Calling `down` in hard-IRQ is certainly wrong, but not due to `current`. – ugoren May 18 '12 at 12:57