Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8412797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:46:03+00:00 2026-06-10T00:46:03+00:00

I was reading a question on difference between Thread and Task. I got this

  • 0

I was reading a question on difference between Thread and Task. I got this link to read on: Task Schedulers on MSDN.

But i got confused on this paragraph:

In some cases, when a Task is waited on, it may be executed synchronously on the Thread that is performing the wait operation. This enhances performance, as it prevents the need for an additional Thread by utilizing the existing Thread which would have blocked, otherwise. To prevent errors due to re-entrancy, task inlining only occurs when the wait target is found in the relevant Thread’s local queue.

I want to understand the highlighted portion. Moreover, i local cache and global queue is also bit confusing… i am really curious to understand the TaskScheduler…
Please help..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:46:05+00:00Added an answer on June 10, 2026 at 12:46 am

    First, what are the local and global queues? This is an optimization of parallel processing in .Net 4.0. If you have lots of small Tasks and only one global queue, you get a lot of contention. That’s because all threads are taking Tasks to process from the same place (the front of the global queue) and they are also placing new Tasks to the same place (the rear of the global queue). This requires lots of synchronization between the threads, which can affect performance.

    The TPL in .Net 4.0 instead uses a technique called “work-stealing”: There one global queue, as before, and each ThreadPool worker thread (but not other threads) also has a local queue. If a non-worker thread starts a Task, it goes to the rear of the global queue, as before. If a worker thread starts a Task, it goes to the rear of its local queue.

    Now to the interesting part. If a worker thread should process a new Task, it looks for it in these places (in this order):

    1. the rear of its local queue
    2. the front of the global queue
    3. the front of other threads’ local queues

    The last part is why this is called “work-stealing”: a worker thread can “steal” a Task to process from another thread. A thread doesn’t need to use synchronization to access the rear of its local queue, because no other thread can access it. And processing Tasks in LIFO order locally is also good for caching, because the last Task (and the data it uses) are the most likely to still be in the CPU cache.

    For another explanation of all this (with pictures), see Work-Stealing in .NET 4.0.


    What does this have to do inlining and reentrancy? I have no idea. I could understand why there could be a reentrancy problem if the Tasks used some thread static fields, but that has nothing to do with the queues. This problem could happen no matter which queue the inlined Task came from. I can’t think of any situation where Tasks from the local queue are guaranteed to be safe to inline, but Tasks from other queues may not be safe.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was reading the answer to this question: Haskell: difference between . (dot) and
After reading this question , i saw the answer by Naveen containing a link
I was reading this question, but didn't understand some part of the aix's answer
I was reading this question (which you do not have to read because I
Reading the answer to the question, What's the difference between globals(), locals(), and vars()?
I hope this question is appropriate for stackoverflow... What is the difference between storing
I know this is not a specific question, but I'm reading about this subject
Simple question I imagine, but what is the difference between these lines of code:
After reading a question on the difference between pointers and references , I decided
I know the difference between static and dynamic linking, and this isn't another question

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.