内核级线程库 [英] Kernel Level Thread Library

查看:97
本文介绍了内核级线程库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须实现内核级线程,但是在网上搜索时,我发现有三种方法可以在linux中创建内核级线程:

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

它写在某个地方,现在linuxThreads被放弃了.但是我找不到NPTL&的当前支持. kthread.我也找不到任何可以简单地向我解释如何使用其功能的资源.

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?

推荐答案

您正在混淆内核线程"的两个非常不同的定义.

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

LinuxThreads和NPTL是用于用户空间进程的POSIX pthreads的实现.他们使用内核调度实体到用户空间线程的一对一映射.有时将它们描述为仅 的内核线程实现,因为它们创建由内核调度的线程.

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不被支持,并且已经完全过时. NPTL现在是glibc的一部分,因此您已经拥有了它.没有什么特别的安装.您可以像使用任何POSIX线程库一样使用这些方法,并可以调用pthread_create之类的函数.

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.

实际内核线程运行内核代码.这些库都不相关,因为它们都是用户空间库.看一下kthread_run之类的功能.没有魔术,没有秘密.以类似于编写类似内核代码的方式编写内核代码. (需要编写内核代码的知识和经验.不幸的是,这并不简单.)

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.)

这篇关于内核级线程库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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