AppManagedScheduler is a empty scheduler. User need to manually add and execute xsched API (refering to xsched API) to control xqueues's behavior.
local.cpp implements processing logic of a scheduler. When running a LocalScheduler, it will start a thread running function Worker. Worker contains a loop to take events in event_queue_ and call Sched API of policy. local.cpp also defines following function:
SuspendandResumeare called bypolicyto really realize control to xqueuesSetPolicyis used to changes policy online
Note:
- If a process's scheduler type is
LocalScheduler, it means the process can only schedule xqueues created by itself. - The scheduler type of
XServermust beGlobalScheduler.
Actually, global scheduler only achieves two IPC channel. Its Worker thread just receive Operation by recv_chan_ and call Execute bound when created (refering to SetExecutor() of sched::Scheduler in file scheduler.h).
send_chan_uses nameXSCHED_SERVER_CHANNEL_NAMEand its type is sender. Whenpreempt::SchedAgentcallRecvEventto force scheduler to receive events,send_chan_will send event to receiver and do nothing else.recv_chan_uses name bound to its PID and its type is receiver.
If a process wants to use GlobalScheduler, user must first run XServer. XServer will create a LocalScheduler and two IPC channels to communicate with process's scheduler, receiving events sended by process's send_chan_ and generating operations by policy in its LocalScheduler, then send these operations back to process's recv_chan_.
event are used in communication among preempt::XQueue, preempt::SchedAgent, sched::Scheduler, service::Server.
When XQueues' status change, e.g. become ready when new commands enqueue, become idle when all commands are completed, XQueue will send event to SchedAgent. SchedAgent will process these events by itself or sent them to the XServer according to the type of its scheduler.
operation is used in communication among service::Server, sched::Scheduler, preempt::SchedAgent.
When policy in sched::Scheduler (LocalScheduler) generate scheduling operations, it will call Execute() bound to service::Server. Then Execute() finds corresponding application process and send these operations to preempt::SchedAgent.
hint are customized data structures to change policy parameters. Developers can define their own hint types when implementing a new policy. The hint types we support now are as follows:
| Name | Used Policy | Description |
|---|---|---|
| kHintTypePriority | HPF, HHPF |
Change priority of the xqueue |
| kHintTypeUtilization | UP, PUP |
Change utilization of the xqueue or process |
| kHintTypeTimeslice | UP, PUP |
Change time slice |
| kHintTypeDeadline | KEDF |
Change deadline of the xqueue |
| kHintTypeLaxity | LAX |
Change laxity of the xqueue. |
| kHintTypeWindowActive | AWF |
Change window activity |
policy.cpp provide a uniform abstract sched::policy, all specific strategies are derived from it.
Now we have implemented several policies, including:
| Value | Full Name | Description |
|---|---|---|
| HPF | Highest Priority First | Firstly run the xqueue with highest priority |
| HHPF | Heterogeneous Highest Priority First | Firstly run the xqueue with highest priority on heterogeneous devices |
| UP | Utilization Partition | Assign time slices with weights to each xqueue |
| PUP | Process Utilization Partition | Assign time slices with weights to each process |
| KEDF | K-Earliest Deadline First | Firstly run the k xqueues with earliest deadline |
| LAX | Laxity-based | Firstly run the xqueue with highest laxity |
| AWF | Active Window First | Firstly run the xqueue in the active window |
Create a new policy class in sched/include/xsched/sched/policy directory, and inherit from sched::policy. Implement the following two functions:
Schedis the main function of the policy, it will be called bysched::Schedulerto schedule xqueues.RecvHintis used to receive hints and change policy parameters.
- Add the new policy type to the enum
PolicyTypeininclude/xsched/types.h. - Add the new policy type to the function
CreatePolicy()insched/src/policy/policy.cpp. - Add the new policy type to the definition of
XSCHED_POLICYinprotocol/include/xsched/protocol/def.h. - Add the new policy type to the map
kPolicyNamesinsched/src/protocol/names.cpp. - Add the new hint type by need in
hint.handhint.cpp.
