linux - User mode and kernel mode switching during system calls -
on broad level of following happens during linux system call.
- user mode process gets elevated kernel mode , execute kernel code(interrupt service routines) , return normal mode. in other words user process consuming cpu.
- there kernel process running in kernel mode. user mode processes dispatch tasks(in form of system calls) kernel process. kernel process finishes job , return results user mode processes. in other words user process idle during time , kernel process 1 consuming cpu.
- something else.
it 1 little bit of 2.
from perspective of usermode application, system calls happen synchronously. times however, system call not have needs return, puts process sleep. doesn't happen; simple system calls complete synchronously. however, need wait long-running i/o task complete.
the kernel has interrupt handlers , kernel threads handle things asynchronously. example hard drive interrupted system indicate retrieved file reading. 1 of these asynchronous events can come along , wake process, system call has needs return userspace.
so looks whole process happened synchronously, illusion.
Comments
Post a Comment