简体   繁体   English

用户空间中实现的线程库可以支持超线程吗?

[英]can a thread library implemented in user space support hyper-threading?

Assume a multiprocessor architecture with an OS which may or may not support kernel-level threads 假设具有操作系统的多处理器体系结构可能支持也可能不支持内核级线程

Correct me where I go wrong: 纠正我在哪里出错:

  • If a thread library is implemented entirely in user space, then the management of threads is done in user space (creation, thread tables, stack info, ect). 如果线程库完全在用户空间中实现,则线程的管理在用户空间(创建,线程表,堆栈信息等)中完成。
  • Thus, even though a process may have multiple user threads, the kernel only sees 1, single-kernel-threaded process. 因此,即使一个进程可能具有多个用户线程,内核也只会看到1个单内核线程的进程。
  • Thus, the kernel schedular assigns CPU usage time to the process as a whole; 因此,内核计划将CPU使用时间分配给整个进程。 the user-space thread library is responsible for time-slicing this CPU time amongst it's user threads. 用户空间线程库负责在用户线程之间对CPU时间进行时间分片。
  • ( corollary 1 ) process A with 20 user-threads will get same priority as process B with 1 user-thread, and so the threads in process A get approximately 1/20th CPU time as thread in process B 推论1 )具有20个用户线程的进程A将具有与具有1个用户线程的进程B相同的优先级,因此进程A中的线程与进程B中的线程相比获得大约1/20的CPU时间。
  • ( corollary 2 ) user threads within the same process will never be hyper-threaded (ie 2 threads executing on separate CPU's at the same time) 必然2 )同一进程内的用户线程将永远不会超线程(即2个线程同时在不同的CPU上执行)

Your first three assumptions are correct. 您的前三个假设是正确的。

Corollary 1 depends on the OS scheduler. 结果1取决于OS调度程序。 Scheduling can be based on threads only, not processes so there is no inherent guarantee that processes with different thread counts get the same total time. 调度只能基于线程,而不能基于进程,因此无法固有地保证具有不同线程数的进程获得相同的总时间。

Many user-space schedulers go a hybrid route and schedule m user space threads to n OS threads (with m >> n ), thus avoiding some of the overheads of OS thread creation. 许多用户空间调度程序采用混合路径,并将m用户空间线程调度到n OS线程( m >> n ),从而避免了OS线程创建的一些开销。 There is no way of magically achieving concurrency without resorting to OS mechanism to bootstrap it. 如果不借助OS机制来引导并发,就无法神奇地实现并发。

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

相关问题 超线程-可以通过哪个测试检查它是启用还是禁用? - Hyper-threading - By which test can I check if it is enabled or disabled? 可以在Linux上的用户空间中实现本机代码的抢占式多任务处理吗? - Can preemptive multitasking of native code be implemented in user space on Linux? 使用pthread制作用户空间线程库,如何正确创建第一个线程? (以及前2个线程) - Making a user space thread library with pthread, how do you properly create the first thread? (well first 2 threads) 从用户空间抢占热循环线程 - Preempt a hot loop thread from user space 可以在没有硬件支持的软件中实现测试和设置吗? - Can Test and Set be implemented in software without hardware support? Linux内核模式中的用户空间库-用于测试 - user space library in Linux kernel modal - for testing 在用户级线程库中实现联接功能 - Implementing join function in a user level thread library 在用户级线程库中实现互斥锁 - Implementing mutex in a user level thread library C语言中的线程和线程安全 - Threading and Thread Safety in C 哪个内核函数调用了timer_settime()并在用户空间中实现了定时器处理程序? - Which kernel function called on timer_settime() and timer handler implemented in User space?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM