35 :
addr(addr_in), tgid(tgid_in) {}
44 : tc(_tc), bitmask(_bitmask) { }
49 return bitmask & wakeup_bitmask;
68 auto &waiterList = it->second;
70 while (!waiterList.empty() && woken_up <
count) {
75 auto& tc = waiterList.front().tc;
78 waiterList.pop_front();
82 if (waiterList.empty())
97 insert({key, waiterList});
118 auto &waiterList = it->second;
119 auto iter = waiterList.begin();
121 while (iter != waiterList.end()) {
127 iter = waiterList.erase(iter);
134 if (waiterList.empty())
144 auto it1 = find(key1);
150 auto &waiterList1 =
it1->second;
152 while (!waiterList1.empty() && woken_up <
count) {
153 waiterList1.front().tc->activate();
154 waiterList1.pop_front();
161 while (!waiterList1.empty() && requeued < count2) {
162 auto w = waiterList1.front();
163 waiterList1.pop_front();
164 tmpList.push_back(
w);
169 auto it2 = find(key2);
171 if (
it2 == end() && requeued > 0) {
172 insert({key2, tmpList});
174 it2->second.insert(
it2->second.end(),
175 tmpList.begin(), tmpList.end());
178 if (waiterList1.empty())
181 return woken_up + requeued;
FutexKey class defines an unique identifier for a particular futex in the system.
FutexKey(uint64_t addr_in, uint64_t tgid_in)
bool operator==(const FutexKey &in) const
void suspend_bitset(Addr addr, uint64_t tgid, ThreadContext *tc, int bitmask)
bool is_waiting(ThreadContext *tc)
Determine if the given thread context is currently waiting on a futex wait operation on any of the fu...
int requeue(Addr addr1, uint64_t tgid, int count, int count2, Addr addr2)
This operation wakes a given number (val) of waiters.
void suspend(Addr addr, uint64_t tgid, ThreadContext *tc)
Inserts a futex into the map with one waiting TC.
std::unordered_set< ThreadContext * > waitingTcs
int wakeup(Addr addr, uint64_t tgid, int count)
Wakes up at most count waiting threads on a futex.
int wakeup_bitset(Addr addr, uint64_t tgid, int bitmask)
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual void activate()=0
Set the status to Active.
virtual void suspend()=0
Set the status to Suspended.
WaiterState defines internal state of a waiter thread.
bool checkMask(int wakeup_bitmask) const
return true if the bit-wise AND of the wakeup_bitmask given by a waking thread and this thread's inte...
WaiterState(ThreadContext *_tc, int _bitmask)
this constructor is used if futex ops with bitset are used
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.