signals, syscalls and schedule()
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?