Re: thread::mutex lock problem, a bug?
- From: "Zoran Vasiljevic" <zv@xxxxxxxxxxxxx>
- Date: 9 Feb 2006 02:00:39 -0800
I've fixed this one. Please checkout and try again.
FYI, this is the (slightly modified) test I used:
tsv::set MUTEX STATE [thread::mutex create]
tsv::set CON_VAR READY [thread::cond create]
tsv::set STATUS STATE BUSY
puts "Try to bring up thread 1"
thread::create {
set f [open /tmp/locks.log a+]
fconfigure $f -buffering line
puts $f "Thread1 [thread::id] is up"
set state_mutex [tsv::get MUTEX STATE]
set con_var_ready [tsv::get CON_VAR READY]
while { 1 } {
puts $f "Thread1 is checking status.."
thread::mutex lock $state_mutex
while { [tsv::get STATUS STATE] ne "READY" } {
puts $f "Thread1 is waiting until READY..."
thread::cond wait $con_var_ready $state_mutex
}
puts $f "Thread1 found that it is READY now"
thread::mutex unlock $state_mutex
puts $f "Thread1 goes to next cycle.."
}
thread::wait
}
puts "Try to bring up thread 2"
thread::create {
set f [open /tmp/locks.log a+]
fconfigure $f -buffering line
puts $f "Thread2 [thread::id] is up"
set state_mutex [tsv::get MUTEX STATE]
while { 1 } {
thread::mutex lock $state_mutex
tsv::set STATUS STATE READY
thread::cond notify [tsv::get CON_VAR READY]
thread::mutex unlock $state_mutex
puts $f "Thread2 set state to ready"
}
thread::wait
}
puts "Try to bring up thread 3"
thread::create {
set f [open /tmp/locks.log a+]
fconfigure $f -buffering line
puts $f "Thread3 [thread::id] is up"
set state_mutex [tsv::get MUTEX STATE]
while { 1 } {
thread::mutex lock $state_mutex
tsv::set STATUS STATE BUSY
thread::mutex unlock $state_mutex
puts $f "Thread3 set state to busy"
}
thread::wait
}
I've been able to test this on Unix only.
Cheers
Zoran
.
- Follow-Ups:
- Re: thread::mutex lock problem, a bug?
- From: Abuda
- Re: thread::mutex lock problem, a bug?
- References:
- Re: thread::mutex lock problem, a bug?
- From: Abuda
- Re: thread::mutex lock problem, a bug?
- From: Zoran Vasiljevic
- Re: thread::mutex lock problem, a bug?
- From: Abuda
- Re: thread::mutex lock problem, a bug?
- From: Zoran Vasiljevic
- Re: thread::mutex lock problem, a bug?
- From: Abuda
- Re: thread::mutex lock problem, a bug?
- From: Zoran Vasiljevic
- Re: thread::mutex lock problem, a bug?
- From: Abuda
- Re: thread::mutex lock problem, a bug?
- From: Zoran Vasiljevic
- Re: thread::mutex lock problem, a bug?
- From: Abuda
- Re: thread::mutex lock problem, a bug?
- From: Abuda
- Re: thread::mutex lock problem, a bug?
- Prev by Date: Re: Handling mutiple channels using fileevent - or not
- Next by Date: Re: Creating a "Fake" Channel
- Previous by thread: Re: thread::mutex lock problem, a bug?
- Next by thread: Re: thread::mutex lock problem, a bug?
- Index(es):
Relevant Pages
|
|