get current->pid while in interrupt

interrupt-handling, kernel, linux, linux-kernel, scheduling

Solution

You can, `current->pid` exists and is the process that was interrupted (may be the idle thread, or any).

If you're writing inside the Linux scheduler, you should be very careful. `current` is changed by the scheduler as it chooses a new process to run, so its value depends on when exactly you read it.

Problem

I'm writing something on the linux scheduler and I need to know which process was running before my interrupt came in.. is the current structure available? If I do current->pid while in the interrupt handler, do I get the pid of the process I interrupted?

Original source