调度程序如何查看Linux上的pthreads [英] how are pthreads on linux seen by scheduler

查看:104
本文介绍了调度程序如何查看Linux上的pthreads的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Linux上的pthread实现有疑问.

I've a question regarding pthread implementation on Linux.

假设一个进程有5个线程. 现在,调度程序如何看到这些线程(或根本看不到). 例如调用调度程序时,它是否仅调度主进程, 然后是在每个线程之间进行调度的主要过程的责任.

Suppose a process has 5 threads. Now how does the scheduler sees these threads (or doesnt see at all). e.g. When scheduler is invoked, does it only schedule the main process, and then its the onus of the main process to schedule between each of its thread.

或者是另一种方式,调度程序将每个线程调度为一个单独的进程.

Or is it the other way, that scheduler schedules each thread as if it is a separate process.

推荐答案

对于现代Linux(NPTL pthread实现),调度程序调度线程,线程被视为轻量级进程". pthread_create是根据 clone 系统调用.

For modern Linux (NPTL pthread implementation), the scheduler schedules threads, a thread is considered a "Light-weight process". pthread_create is implemented in terms of the clone system call.

这篇关于调度程序如何查看Linux上的pthreads的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆