Skip to content

Commit

Permalink
use val to limit number of threads to wake
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick La Fratta committed Mar 21, 2024
1 parent f582922 commit 0a6cc98
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions src/sst/elements/vanadis/os/syscall/futex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ VanadisFutexSyscall::VanadisFutexSyscall( VanadisNodeOSComponent* os, SST::Link*
{
m_output->verbose(CALL_INFO, 2, VANADIS_OS_DBG_SYSCALL,
"[syscall-futex] addr=%#" PRIx64 " op=%#x val=%#" PRIx32 " timeAddr=%#" PRIx64 " callStackAddr=%#" PRIx64
" addr2=%#" PRIx64 " val3=%#x, \n",
" addr2=%#" PRIx64 " val3=%#x, \n",
event->getAddr(), event->getOp(), event->getVal(), event->getTimeAddr(), event->getStackPtr(), event->getAddr2(), event->getVal3() );

m_op = event->getOp();
Expand Down Expand Up @@ -136,9 +136,10 @@ void VanadisFutexSyscall::wakeWaiter(VanadisSyscallFutexEvent* event) const
delete syscall;
}

int VanadisFutexSyscall::getNumWaiters(VanadisSyscallFutexEvent* event) const
int VanadisFutexSyscall::getNumWaitersToWake(VanadisSyscallFutexEvent* event) const
{
auto numWaiters = m_process->futexGetNumWaiters(event->getAddr());
uint32_t numWaiters = m_process->futexGetNumWaiters(event->getAddr());
uint32_t numWaitersToWake = std::min(numWaiters, event->getVal());
if( numWaiters == 0 )
{
m_output->verbose(CALL_INFO, 3, VANADIS_OS_DBG_SYSCALL,
Expand All @@ -147,15 +148,17 @@ int VanadisFutexSyscall::getNumWaiters(VanadisSyscallFutexEvent* event) const
else
{
m_output->verbose(CALL_INFO, 3, VANADIS_OS_DBG_SYSCALL,
"[syscall-futex] FUTEX_WAKE tid=%d addr=%#" PRIx64 " %u waiters\n", m_process->gettid(), event->getAddr(), numWaiters);
"[syscall-futex] FUTEX_WAKE tid=%d addr=%#" PRIx64 " %u waiters, "
" val is %u, will wake %u threads \n",
m_process->gettid(), event->getAddr(), numWaiters, event->getVal(), numWaitersToWake);

}
return numWaiters;
return numWaitersToWake;
}

int VanadisFutexSyscall::wakeWaiters(VanadisSyscallFutexEvent* event) const
{
auto numWaiters = getNumWaiters(event);
auto numWaiters = getNumWaitersToWake(event);
for(int curWaiter=0;curWaiter<numWaiters;curWaiter++)
{
wakeWaiter(event);
Expand Down
2 changes: 1 addition & 1 deletion src/sst/elements/vanadis/os/syscall/futex.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class VanadisFutexSyscall : public VanadisSyscall {
void futexWake(VanadisSyscallFutexEvent* event);
int wakeWaiters(VanadisSyscallFutexEvent* event) const;
void wakeWaiter(VanadisSyscallFutexEvent* event) const;
int getNumWaiters(VanadisSyscallFutexEvent* event) const;
int getNumWaitersToWake(VanadisSyscallFutexEvent* event) const;
};

} // namespace Vanadis
Expand Down

0 comments on commit 0a6cc98

Please sign in to comment.