这是一个概念性问题.
根据这个post,pthread实际上是使用clone()系统调用实现的.因此,我们可以推断在用户空间中有一个内核线程(或轻量级进程)备份pthread.内核知道pthread并且可以像进程一样安排它.
至于kthread,根据Robert Love,kthreads也是用clone()系统调用创建的:
clone(CLONE_VM| CLONE_FS | CLONE_FILES | CLONE_SIGHAND, 0)
所以pthread和kthread都使用clone()调用.我的第一个问题是:
>这两种线程之间有区别吗?
为了回答我自己的问题,我继续读到:
The significant difference between kernel threads and normal processes
is that kernel threads do not have an address space (in fact, their mm
pointer is NULL).
这有区别吗?我的意思是,由pthread_create()创建的线程与正常进程共享地址空间.相反,kthread没有自己的地址空间.那是对的吗?
还有什么不同?
解决方法:
In contrast, a kthread does not have its own address space. Is that correct?
是
a thread created by pthread_create() shares the address space with the normal process.
pthreads:pthread_create()用于用户空间,其中应用程序中的多个线程共享相同的进程地址空