test/dummy_libs/synch/kernel_mutexes.dummy.cpp
// Acquire the mutex for the currently running thread. It is permissible for a thread to call this function when it
// already owns the mutex - nothing happens. The maximum time to wait is max_wait milliseconds. If max_wait is set to
// MUTEX_MAX_WAIT then the caller waits indefinitely. Threads acquire the mutex in order that they call this function.
//
// The return values should be self-explanatory.
Acquire the mutex for the currently running thread. It is permissible for a thread to call this function when it
already owns the mutex - nothing happens. The maximum time to wait is max_wait milliseconds. If max_wait is set to
MUTEX_MAX_WAIT then the caller waits indefinitely. Threads acquire the mutex in order that they call this function.

The return values should be self-explanatory.
Acquire the mutex for the currently running thread . It is permissible for a thread to call this function when it already owns the mutex - nothing happens . The maximum time to wait is max_wait milliseconds . If max_wait is set to MUTEX_MAX_WAIT then the caller waits indefinitely . Threads acquire the mutex in order that they call this function . The return values should be self - explanatory .
SYNC_ACQ_RESULT klib_synch_mutex_acquire(klib_mutex &mutex, uint64_t max_wait)
{
  KL_TRC_ENTRY;
  bool locked_ok;
  SYNC_ACQ_RESULT our_result;
  if (max_wait != 0)
  {
    mutex_map[&mutex]->lock();
    locked_ok = true;
  }
  else
  {
    locked_ok = mutex_map[&mutex]->try_lock();
  }
  if (locked_ok)
  {
    KL_TRC_TRACE(TRC_LVL::FLOW, "Acquired mutex\n");
    our_result = SYNC_ACQ_ACQUIRED;
    mutex.mutex_locked = true;
  }
  else
  {
    KL_TRC_TRACE(TRC_LVL::FLOW, "Already owned mutex\n");
    our_result = SYNC_ACQ_TIMEOUT;
    mutex.mutex_locked = true;
  }
  KL_TRC_EXIT;
  return our_result;
}
SYNC_ACQ_RESULT klib_synch_mutex_acquire ( klib_mutex & mutex , uint64_t max_wait ) { KL_TRC_ENTRY ; bool locked_ok ; SYNC_ACQ_RESULT our_result ; if ( max_wait != 0 ) { mutex_map [ & mutex ] -> lock ( ) ; locked_ok = true ; } else { locked_ok = mutex_map [ & mutex ] -> try_lock ( ) ; } if ( locked_ok ) { KL_TRC_TRACE ( TRC_LVL :: FLOW , " \n " ) ; our_result = SYNC_ACQ_ACQUIRED ; mutex . mutex_locked = true ; } else { KL_TRC_TRACE ( TRC_LVL :: FLOW , " \n " ) ; our_result = SYNC_ACQ_TIMEOUT ; mutex . mutex_locked = true ; } KL_TRC_EXIT ; return our_result ; }
Acquire the mutex for the currently running thread.
Acquire the mutex for the currently running thread .
// This isn't quite right - we don't support timed waits here.