Menu

threadpool Log in to Edit

Bin Yu

Overview

A priority equal-opportunity threadpool that consists of the following sections in its backing queue.

  • Preemptive Section: First part of the master queue, simple FIFO queue. Preempt all other tasks in the queue, reserved for system usage, system process, messaging, user interaction etc.
  • Round Robin Section: second part of the master queue, round robin queue, with each member of the queue a separate priority queue. Used for different use cases.
  • Can Wait Section: last part of the master queue, simple FIFO queue. Used for low priority tasks or scheduled long running type of tasks.

Algorithm

All tasks in “preemptive queue” will be executed FIFO.
All tasks in “round robin queue” will be executed Round Robin if preemptive queue is empty.
All tasks in “can wait queue” will be executed FIFO if both preemptive and round robin queue are empty.

This is to guarantee an overall priority of different categories of tasks. Tasks that are critical to the system are allowed to preemptively run with minimum wait time. Application tasks are given fair chances to run with as little wait time as possible. Non-critical and long running tasks are only run when the system is idle.

Round Robin Section consists of multiple priority queue(s) for every use case.
Algorithm: Thread pool runner keeps a count of running threads for every use case and when there are idle thread, and no new task in the preemptive queue, a task from the round robin queue will be chosen to run. The candidate will be picked from all use case queues that have pending tasks with round robin fashion. Fairness among all use cases is guarenteed, this implementation provides equal opportunity for tasks from different use cases to be run.

Each use case queue is a priority queue by itself; tasks are sorted based on its priority specified by its submitter.


Related

Home: Home

Discussion

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.