MCPcopy Create free account
hub / github.com/alibaba/PhotonLibOS / try_work_stealing

Function try_work_stealing

thread/thread.cpp:1985–2004  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1983 return ws_scan_q(v, u->idle_worker, true);
1984 }
1985 static bool try_work_stealing(vcpu_t* vcpu) {
1986 assert(CURRENT->get_vcpu() == vcpu);
1987 assert(CURRENT == vcpu->idle_worker);
1988 if (0 == (vcpu->flags & VCPU_ENABLE_ACTIVE_WORK_STEALING))
1989 return false;
1990 scoped_rwlock _(vcpu_list_rwlock, RLOCK);
1991 auto u = vcpu->next;
1992 while (u != vcpu) {
1993 if (0 == (u->flags & VCPU_ENABLE_PASSIVE_WORK_STEALING))
1994 continue;
1995 thread* th;
1996 if ((th = ws_scan_standbyq(vcpu, u)) || (th = ws_scan_runq(vcpu, u))) {
1997 vcpu->idle_worker->insert_list_tail(th);
1998 return true;
1999 }
2000 SCOPED_LOCK(vcpu_list_lock);
2001 u = u->next;
2002 }
2003 return false;
2004 }
2005 static void* idler(void*) {
2006 RunQ rq;
2007 auto last_idle = now;

Callers 1

idlerFunction · 0.85

Calls 4

ws_scan_standbyqFunction · 0.85
ws_scan_runqFunction · 0.85
get_vcpuMethod · 0.80
insert_list_tailMethod · 0.45

Tested by

no test coverage detected