Lines Matching defs:worker
37 void CPUWorker::Run(CPUEUTask* task, CPUWorker* worker)
41 worker->localFifo.PushTail(task);
98 void* CPUWorker::WrapDispatch(void* worker)
100 reinterpret_cast<CPUWorker*>(worker)->NativeConfig();
101 Dispatch(reinterpret_cast<CPUWorker*>(worker));
105 void CPUWorker::RunTask(ffrt_executor_task_t* curtask, CPUWorker* worker)
109 worker->curTask = task;
110 worker->curTaskType_ = task->type;
115 worker->curTaskLabel_ = task->label;
116 worker->curTaskGid_ = task->gid;
120 Run(task, worker);
126 Run(curtask, static_cast<ffrt_qos_t>(worker->GetQos()));
131 worker->curTask = nullptr;
132 worker->curTaskType_ = ffrt_invalid_task;
135 void CPUWorker::RunTaskLifo(ffrt_executor_task_t* task, CPUWorker* worker)
137 RunTask(task, worker);
140 while (worker->priority_task != nullptr && worker->priority_task != &PLACE_HOLDER) {
142 ffrt_executor_task_t* priorityTask = reinterpret_cast<ffrt_executor_task_t*>(worker->priority_task);
144 worker->priority_task = (lifoCount > worker->budget) ? &PLACE_HOLDER : nullptr;
146 RunTask(priorityTask, worker);
150 void* CPUWorker::GetTask(CPUWorker* worker)
153 if (worker->tick % worker->global_interval == 0) {
154 worker->tick = 0;
155 CPUEUTask* task = worker->ops.PickUpTaskBatch(worker);
156 // the worker is not notified when the task attribute is set not to notify worker
162 worker->ops.NotifyTaskPicked(worker);
168 if (worker->priority_task != nullptr) {
169 void* task = worker->priority_task;
170 worker->priority_task = nullptr;
176 return worker->localFifo.PopHead();
179 PollerRet CPUWorker::TryPoll(CPUWorker* worker, int timeout)
181 PollerRet ret = worker->ops.TryPoll(worker, timeout);
183 worker->tick = 0;
189 bool CPUWorker::LocalEmpty(CPUWorker* worker)
191 return ((worker->priority_task == nullptr) && (worker->localFifo.GetLength() == 0));
194 void CPUWorker::Dispatch(CPUWorker* worker)
197 if (worker->ops.IsBlockAwareInit()) {
198 int ret = BlockawareRegister(worker->GetDomainId());
205 ctx->localFifo = &(worker->localFifo);
206 ctx->priority_task_ptr = &(worker->priority_task);
207 ctx->qos = worker->GetQos();
209 worker->ops.WorkerPrepare(worker);
211 FFRT_LOGI("qos[%d] thread start succ", static_cast<int>(worker->GetQos()));
213 FFRT_PERF_WORKER_AWAKE(static_cast<int>(worker->GetQos()));
214 worker->ops.WorkerLooper(worker);
217 worker->ops.WorkerRetired(worker);
223 CPUWorker* worker = reinterpret_cast<CPUWorker*>(p);
226 if (!worker->ops.IsExceedRunningThreshold(worker)) {
229 void* local_task = GetTask(worker);
230 worker->tick++;
232 if (worker->tick % TRY_POLL_FREQ == 0) {
233 worker->ops.TryPoll(worker, 0);
236 RunTaskLifo(work, worker);
240 PollerRet ret = TryPoll(worker, 0);
246 CPUEUTask* task = worker->ops.PickUpTaskBatch(worker);
247 // the worker is not notified when the task attribute is set not to notify worker
252 worker->ops.NotifyTaskPicked(worker);
255 RunTask(work, worker);
260 ret = TryPoll(worker, 0);
265 if (worker->localFifo.GetLength() == 0) {
266 worker->ops.StealTaskBatch(worker);
269 if (!LocalEmpty(worker)) {
270 worker->tick = 1;
274 // enable a worker to enter the epoll wait -1 state and continuously listen to fd or timer events
275 // only one worker enters this state at a QoS level
276 ret = TryPoll(worker, -1);
283 auto action = worker->ops.WaitForNewAction(worker);
285 worker->tick = 0;