Hi!
I am using this fair_mutex implementation in a SystemC application of mine. It is almost doing what it should albeit the mutex accidently slips through the odd user. I cannot spot the prblem :(
Best Regards
class fair_mutex : public sc_mutex
{
std::queue<sc_process_b *> s_queue;
public:
virtual int
lock()
{
if (m_owner == sc_get_current_process_b()) return 0;
s_queue.push(sc_get_current_process_b());
while (in_use()) {
sc_core::wait(m_free);
if (s_queue.front() == sc_get_current_process_b())
break;
}
m_owner = sc_get_current_process_b();
sc_core::wait(SC_ZERO_TIME);
s_queue.pop();
return 0;
}
};