From mboxrd@z Thu Jan 1 00:00:00 1970 From: sironhide0null@gmail.com (zerons) Date: Fri, 25 Nov 2016 10:32:50 +0800 Subject: signals, syscalls and schedule() Message-ID: <26bda631-e316-316e-e0f5-1dcb9b2753a2@gmail.com> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org Hi all. I have several doubts about signals and syscalls. When a signal handler gets involved? About signal, I think I have figured it out, maybe? I checked the source code, and found that when call `prepare_exit_to_usermode` -> `exit_to_usermode_loop`, then `do_signal` gets involved. So when switch to user mode, the signal handler get called before restart the syscall if needed. That means when return from a syscall or the process scheduled, we could handle the signal. Interruptible syscalls, they check the process signal state by themselves and return -ERESTARTSYS or -EINTR, is that why we call them interruptible syscalls? When a syscall running, and then the time slice runs out, does it switch to a new process or wait until the system call returns? If switch to a new process, when the interrupted process runs again, is it still in kernel mode to finish the syscall? Is that to say, a signal is handled when return from a syscall or the process scheduled and it is in usermode?