System call service routine and interrupt context

Greg KH greg at kroah.com
Mon Apr 30 11:12:34 EDT 2018


On Mon, Apr 30, 2018 at 08:13:11PM +0530, Pritam Bankar wrote:
> Hi,
> 
> My question is, do all the code of interrupt handler in system call
> gets executed in interrupt context?

No.

> System calls generate software interrupts.

Some do, some do not.  It all depends :)

> So when I do open() syscall it we call do_sys_open()  handler which
> will eventually call file system specific open function call.

Normal file open calls do not generate a hardware interrupt.  Some
might, but some might not.  It all depends.

> Will all this happen in interrupt context until I get open file
> descriptor in user land?

No, if disk I/O is needed, which requires interrupts, the system call
process (your process) will sleep in the kernel until the needed I/O
happens and is returned.  That I/O can cause irq code to run, and if so,
that's fine, it runs in its own context.

> If not when does context change?

Often and frequently :)

Sorry, it's a complex thing, all depending on the hardware, system,
cache, and loads of other things.  Try using ftrace or other function
tracing tools to follow a call through the kernel to see how this all
plays out.

hope this helps,

greg k-h



More information about the Kernelnewbies mailing list