I am newbie to Linux Kernel.
I know that there are two context
1. Process Context, running in user space or in Kernel Space (for ex: as part of System call)
2. Interrupt Context
In what context Kernel Thread (not related to any User Thread, for ex:flush task) runs ?
Is there any other context other than Process and Interrupt context in Linux Kernel ?
Well there are certain tasks that are neither called via a system call or when handling interrupts. Such are handled as pure kernel contexts, for instance the swapper, the INIT_TASk etc which do not have corresponding code running in the user space.
Kernel threads run in process contexts in kernel space. Though there are some kernel threads which handle interrupts too. They are called threaded interrupt handlers. But they still run in process context!
Here is an excellent explanation of the vital difference between the 2 contexts!
Here is one which'll help you gain more understanding!
What context does the scheduler code run in?
As far as I know, process and interrupt are the only 2 contexts.
There is a handful of states—some may be specializations of others. Also see http://www.kernel.org/doc/htmldocs/kernel-hacking.html .
in_nmi()
)in_irq()
)in_softirq()
)in_atomic()
). Possibly entryways are, among others,spin_lock
.rcu_read_lock
for example