Subj : Re: Recursive mutexes To : comp.programming.threads From : Marcin 'Qrczak' Kowalczyk Date : Sun Mar 27 2005 02:55 pm "doug" writes: > void my_mutex::acquire() { > EnterCriticalSection(); > if (m_owner == thread_id) { > ++m_count; > } > else { > do > * { > * ExitCriticalSection(); > m_mutex->wait(); > * EnterCriticalSection(); > * } while (m_count > 0); > m_count = 1; > m_owner = thread_id; > } > ExitCriticalSection(); > } It should be while (m_count > 0) {...}, not do {...} while (m_count > 0). Alternatively m_count should be tested at the beginning, so the common case of the mutex being free is faster. -- __("< Marcin Kowalczyk \__/ qrczak@knm.org.pl ^^ http://qrnik.knm.org.pl/~qrczak/ .