Kernel Level Thread Library

岁酱吖の 提交于 2019-12-08 13:26:28

问题


I have to implement kernel level thread but while searching on the net I found that there are three ways to create kernel level thread in linux:

  1. NPTL
  2. kthread
  3. linuxThreads

It was written somewhere that linuxThreads are now abandoned. But I am unable to find current support of NPTL & kthread. Also I am unable to find any source that can simply explain me how to use their functionality.

Which is the currently supported and good library to use kernel level thread?

Also pls share any resource for installing these library and also using them?


回答1:


You are confusing two very different definitions of "kernel thread".

LinuxThreads and NPTL are implementations of POSIX pthreads for user-space processes. They use a 1-to-1 mapping of kernel scheduling entities to user-space threads. They are sometimes described as kernel threads implementations only because they create threads that are scheduled by the kernel.

LinuxThreads is unsupported and entirely obsolete. NPTL is now part of glibc, so you already have it. There's nothing special to install. You use these the same way you use any POSIX threading library, with calls to functions like pthread_create.

Actual kernel threads run kernel code. None of those libraries are relevant since they're all user-space libraries. Have a look at functions like kthread_run. There's no magic, no secret. Write kernel code the way similar kernel code is written. (Knowledge and experience in writing kernel code is needed. It's, unfortunately, not simple.)




回答2:


I assume that; if you really wanted to create a kernel thread, you would already know about these things.

I think, you want to create multi-threaded applications and trying to find info about user-level multi-threading functions.

And yes, these threads you created will be managed by the kernel itself. This is what you are looking for :: POSIX Threads



来源:https://stackoverflow.com/questions/14561311/kernel-level-thread-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!