Inlining Task - Request

I read a question about the difference between Thread and Task. I got this read link: Job Schedulers on MSDN .

But I got confused in this paragraph:

In some cases, when a task is executed, it can be executed synchronously in a thread that performs a wait operation. This improves performance, as it prevents the need for an additional thread using an existing thread that would otherwise block. To prevent errors due to re-entry, the task execution occurs only when the wait target is found in the corresponding local thread queue.

I want to understand the highlighted part. Moreover, I local cache and global queue are also a bit confusing ... I'm really interested to know TaskScheduler ... Please help ..

+5
source share
2 answers

First, what are the local and global queues? This is an optimization of parallel processing in .Net 4.0. If you have many small ones Taskand only one global queue, you get a lot of controversy. This is because all threads accept Taskfor processing from the same place (front of the global queue), and they also put a new Taskone in the same place (back of the global queue). This requires a lot of synchronization between threads, which can affect performance.

TPL .Net 4.0 "work-stealing": , , ThreadPool ( ) . - Task, - . Task, .

. Task, ( ):

- " ": "" Task . , . Task LIFO- , Task ( ), , CPU.

( ), . .NET 4.0".


, reentrancy? . , , Task , . , Task. , Task , Task .

+2

/ ThreadPool, TaskScheduler ThreadPool, ... , MSDN: ThreadPool Global Queue . svick .

- , , .

, - WaitHandle, . , WaitHandle lcoal - Task local.

, , .Wait "Inlining" .

+2

All Articles