From mboxrd@z Thu Jan 1 00:00:00 1970 From: greg@kroah.com (Greg KH) Date: Mon, 30 Apr 2018 08:12:34 -0700 Subject: System call service routine and interrupt context In-Reply-To: References: Message-ID: <20180430151234.GD31520@kroah.com> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org 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