Get current-> pid during interrupt

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

+2
source share
2 answers

You can, current->pid exists and is a process that has been interrupted (there may be an idle thread or any).

If you write inside the Linux scheduler, you have to be very careful. current changed by the scheduler because it chooses a new process to start, so its value depends on when exactly you read it.

+3
source

I would not expect the current one to be the actual external context of the process. If you are working on a scheduler, perhaps you can get where it stores a pointer to the task to be performed, for example. struct cfs_rq.

0
source

All Articles