在用户空间和内核空间之间切换

内核管理操作系统资源。用户程序只能通过对内核进行系统调用来访问这些资源。系统调用类似于内核的 API,从长远来看,它运行程序所需的内核任务。

str = "something" // run on user space
x = x + 1 // run on user space
file.write(str) // switch to kernel space
y = x + 4 // switch back to user space