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

Method lock

thread/thread.cpp:1621–1631  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1619 }
1620
1621 int ticket_spinlock::lock() {
1622 const auto ticket = next.fetch_add(1, std::memory_order_relaxed);
1623 while (serv.load(std::memory_order_acquire) != ticket) {
1624#ifdef __aarch64__
1625 asm volatile("isb" : : : "memory");
1626#else
1627 _mm_pause();
1628#endif
1629 }
1630 return 0;
1631 }
1632
1633 void ticket_spinlock::unlock() {
1634 const auto successor = serv.load(std::memory_order_relaxed) + 1;

Callers 15

lock_callbackMethod · 0.45
response_senderMethod · 0.45
st_mutex_lockFunction · 0.45
dieMethod · 0.45
indirect_lockFunction · 0.45
thread_joinFunction · 0.45
mutex_lockFunction · 0.45
spinlock_lockFunction · 0.45
wait_interruptibleMethod · 0.45
~implMethod · 0.45
dtorMethod · 0.45
rwlocktestFunction · 0.45

Calls 9

_mm_pauseFunction · 0.85
thread_yieldFunction · 0.85
waitq_translate_errnoFunction · 0.85
thread_usleep_deferFunction · 0.70
unlikelyFunction · 0.50
loadMethod · 0.45
unlockMethod · 0.45
expiredMethod · 0.45
waitMethod · 0.45

Tested by 5

rwlocktestFunction · 0.36
TESTFunction · 0.36
smprwlocktestFunction · 0.36
TESTFunction · 0.36
TESTFunction · 0.36