在系统中没有其他负载的情况下阻止系统调用(Linux 内核)
如果系统中只有 1 个正在运行的应用程序(默认有 100 个睡眠进程),并且它会执行阻塞系统调用(我对阻塞接收或阻塞读取感兴趣)。 Linux内核会从task_t *current
指针中删除这个应用程序吗?
If there is only 1 running application in the system (and default 100 sleeping process), and it do a blocking syscall (I'm interested in blocking recv or blocking read). Will linux kernel delete this application from task_t *current
pointer?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您问正在运行的应用程序会休眠吗?
如果有数据满足读取,那么它将不会休眠——内核会将排队的数据复制到缓冲区中并从系统调用返回。如果没有等待数据,则进程将休眠。这不依赖于系统上其他进程的状态。如果所有进程都在睡眠,内核将执行一些有用的操作,例如将 CPU 置于低功耗状态,直到发生中断,这可能意味着您的进程正在等待的数据现在可能可用。
You're asking will the running application sleep?
If there is data to satisfy the read, then it will not sleep -- the kernel will copy the queued data into your buffer and return from the syscall. If there is no waiting data, then the process will sleep. This does not depend on the state of other processes on the system. If all the processes are sleeping, the kernel will do useful things like putting the CPU into a lower-power state, until an interrupt occurs, which might possibly mean that the data your process was waiting for may now be available.