In Action CLR Thread Pool, and WorkingStealing Scheduling Algorithm - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

In Action CLR Thread Pool, and WorkingStealing Scheduling Algorithm

Description:

Researcher in Computer Sciences ... Any new task will add into the global queue. ... data structure designed to be effective by avoiding locks. WSQ data ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 9
Provided by: ander176
Category:

less

Transcript and Presenter's Notes

Title: In Action CLR Thread Pool, and WorkingStealing Scheduling Algorithm


1
In ActionCLR Thread Pool, and Working-Stealing
Scheduling Algorithm
  • gt Haytham El-Fadeel (Hfadeel.com/blog)
  • Researcher in Computer Sciences

2
Microsoft CLR 3, and prior Thread Pool
Scheduling Algorithm
In Thread Pool there are global queue FIFO that
accept the user work items, then the worker
threads pick them in and execute them in FIFO
order. If in the context of those work items
(i.e. from the executing code) more work items
get created for the thread pool they end up on
the global queue and life goes on. So the global
queue is the main the queue the hold the work
items.
3
CLR 3 Thread Pool in Action
Thread Pool Engine (Ordinary Scheduling Algorithm)
Global Queue
Worker Thread 1
Worker Thread p

Task 3
Task 1
Program Thread
Task 2
4
Modern Parallelism infrastructure Scheduler
  • Work-Stealing scheduler now is the most famous
    task scheduler (invented in MIT around 80s).
  • Work-Stealing Concepts
  • There are global queue that receive the tasks.
  • Every worker thread have its own WSQ
    (Work-Stealing Queue).
  • Any new task will add into the global queue.
  • Any new task belong to worker thread will add in
    its own WSQ.
  • When the worker thread looking for new task he
    will follow this
  • Looking for task into the local WSQ.
  • Then, looking for task into the global queue.
  • Then, looking and try to steal tasks from other
    workers.

5
Modern Parallelism infrastructure Scheduler
  • As I said every worker thread will have its own
    Work-Stealing Queue. WSQ is data structure
    designed to be effective by avoiding locks.
  • WSQ data structure concepts
  • Its special kind of queue that have two ends.
  • Its allow lock-Free pushes, and pops from the
    (private end).
  • But it requires synchronization from the other
    end (public end).
  • Explains
  • Private end private for this worker thread.
  • Public end public to any other thread, so any
    other thread can use the public end to steal a
    task as kind of load balancing.

6
Modern Parallelism infrastructure Scheduler
  • Why Work-Stealing
  • Its effective
  • Because its try to minimize the
    Locks/Synchronize in the global task queue.
  • Because every worker can steal a tasks from the
    other worker. So its provide implicitly load
    balancing.
  • Stable
  • Its tested, and working now in many solutions.
  • Note
  • Work-Stealing is not the only technology for
    user-mode scheduling. You still can crate your
    scheduling technology, if you have special needs .

7
Work-Stealing in Action
Work-Stealing Scheduler
Local Queue
Local Queue

Global Queue
Worker Thread 1
Worker Thread p

Task 6
Task 3
Task 4
Task 5
Task 1
Program Thread
Task 2
8
Thanks,if you have any question, please feel
free to send it to meHFadeel_at_HFadeel.comHFadeel
.com/blog
Write a Comment
User Comments (0)
About PowerShow.com