简体   繁体   English

smp系统上的Posix线程

[英]Posix threads on smp system

I have developed a C app in linux sytem with 12 posix threads in it.It is a multicore system. 我在Linux系统中开发了一个C应用程序,其中包含12个posix线程。它是一个多核系统。 After reading i found that kernel knows only my process and it will be unaware of threads(posix library will take care). 阅读后,我发现内核只知道我的进程,并且它不知道线程(posix库会注意)。 In this case does my 12 threads will be using only onecore in which the process is sceduled or my threads can run in all available cores ? 在这种情况下,我的12个线程是否仅使用调度了该进程的onecore,或者我的线程可以在所有可用内核中运行? Does Posix library can schedule threads to other cores ? Posix库是否可以将线程调度到其他内核?

Historically, there have been quite a few libraries which implemented POSIX-threads-like functionality. 从历史上看,已经有很多库实现了类似POSIX线程的功能。 LinuxThreads came with glibc, but had severe conformance issues due to limitations of earlier kernels (such as a thread-specific current directory and umask). LinuxThreads随glibc一起提供,但是由于早期内核(例如特定于线程的当前目录和umask)的限制,存在严重的一致性问题。 It could actually run multiple threads in the same process on different CPUs at the same time (people didn't speak of cores back then). 实际上,它可以同时在不同CPU上的同一进程中运行多个线程(当时人们还没有提到内核)。 FSU Threads had better POSIX conformance (even in the area of PI scheduling, if I recall correctly), but was restricted to one CPU per process. FSU线程具有更好的POSIX一致性(即使在PI调度领域,如果我没记错的话),但是每个进程只能使用一个CPU。 Many thread libraries also experimented with an n:m scheme, where a larger number of user space threads was executed on a small number of kernel-scheduled threads (which could run in parallel on different CPUs). 许多线程库还使用n:m方案进行了试验,其中大量用户空间线程是在少数内核调度线程(可以在不同CPU上并行运行)上执行的。

For Linux and C/C++, this pretty much stopped when NPTL was added to glibc and more and more tightly integrated with the rest of the library. 对于Linux和C / C ++,将NPTL添加到glibc并与该库的其余部分越来越紧密地集成时,这几乎停止了。 NPTL has a 1:1 model: each user space thread is visible to the kernel and can run in parallel, as long sufficient hardware resources are available. NPTL具有1:1模型:每个用户空间线程对于内核都是可见的,并且可以并行运行,只要有足够的硬件资源可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM