Seastar
High performance C++ framework for concurrent servers
Public Member Functions | List of all members
seastar::thread_scheduling_group Class Reference

Detailed Description

An instance of this class can be used to assign a thread to a particular scheduling group. Threads can share the same scheduling group if they hold a pointer to the same instance of this class.

All threads that belongs to a scheduling group will have a time granularity defined by period, and can specify a fraction usage of that period that indicates the maximum amount of time they expect to run. usage, is expected to be a number between 0 and 1 for this to have any effect. Numbers greater than 1 are allowed for simplicity, but they just have the same meaning of 1, alas, "the whole period".

Note that this is not a preemptive runtime, and a thread will not exit the CPU unless it is scheduled out. In that case, usage will not be enforced and the thread will simply run until it loses the CPU. This can happen when a thread waits on a future that is not ready, or when it voluntarily call yield.

Unlike what happens for a thread that is not part of a scheduling group - which puts itself at the back of the runqueue everytime it yields, a thread that is part of a scheduling group will only yield if it has exhausted its usage at the call to yield. Therefore, threads in a schedule group can and should yield often.

After those events, if the thread has already run for more than its fraction, it will be scheduled to run again only after period completes, unless there are no other tasks to run (the system is idle)

Deprecated:
This class has been replaced by scheduling_group, which can be used to schedule both threads and continuations.

#include <seastar/core/thread.hh>

Public Member Functions

 thread_scheduling_group (std::chrono::nanoseconds period, float usage)
 Constructs a thread_scheduling_group object. More...
 
void update_usage (float new_usage)
 changes the current maximum usage per period More...
 

Constructor & Destructor Documentation

◆ thread_scheduling_group()

seastar::thread_scheduling_group::thread_scheduling_group ( std::chrono::nanoseconds  period,
float  usage 
)

Constructs a thread_scheduling_group object.

Parameters
perioda duration representing the period
usagewhich fraction of the period to assign for the scheduling group. Expected between 0 and 1.

Member Function Documentation

◆ update_usage()

void seastar::thread_scheduling_group::update_usage ( float  new_usage)
inline

changes the current maximum usage per period

Parameters
new_usageThe new fraction of the period (Expected between 0 and 1) during which to run

The documentation for this class was generated from the following file: