Hardware threads (logical cores) on Hyper threaded CPUs + scheduler
I know that software threads get a certain bit of time to execute and each software thread takes turns executing for that block of time but they are not executing at the same time (on a single hardware thread).
My question is, when you have 2 or more hardware threads per core, does each hardware thread run concurrently on that core or do hardware threads get blocks of time to execure like software threads, playing the round robin game?
Hardware thread = logical core
You only have 1 (hardware) Thread per (logical) Core.
Intel muddies the water by running two logical Threads on 1 Physical core, so only for some processors your question is applicable. And Hyper-threading is complicated but mostly concurrent.
For as far we as programmers are concerned, there exist only logical cores running 1 thread at a time.
If you are talking about a processor with hyper threading, then that processor has extra execution pipelines for most parts of the execution cycle. As far as a .net app cares, then yes you will not have the time slicing and locking that a software thread has. You still need to ensure that your operations are thread safe, otherwise you will need to do your own locking to ensure that you don't corrupt your objects by calling them from multiple threads at the same time. A quick test to validate this is to use a computer with hyper threading, spawn off some threads that do processor heavy operations and look at the cpu usage. If you see all of the virtual cores at 100% then you are golden.
链接地址: http://www.djcxy.com/p/36874.html上一篇: 线程在不同的硬件上