Overview
| Artifact ID: | 1a00ecab301698cde3210b1eb91ad01d3fa96321 |
|---|---|
| Ticket: | 994229ffffffffffffffffffffffffffffffffff
tsv::lock doesn't lock between threads |
| User & Date: | nobody on 2004-07-20 02:27:11 |
Changes
- assignee changed to: "vasiljevic"
- cmimetype changed to: "text/plain"
- comment changed to:
A [tsv::lock <arrayName>] will not prevent two threads from accessing the tsv array. % puts $tcl_version 8.4 % array get tcl_platform osVersion 7.3.0 byteOrder bigEndian threaded 1 machine {Power Macintosh} platform unix os Darwin user ts anders wordSize 4 % package require Thread 2.5 Testcase: package require Thread tsv::set global true 1 tsv::set global false 0 set a [thread::create] set b [thread::create] set ::finish 0 thread::send $a [list set x [thread::id]]; # main thread id thread::send -async $a { set ::finish 0 puts "a: [thread::id]" tsv::lock global { puts "a: has global lock ([tsv::get global true])" tsv::set global true 2 vwait ::finish } puts "a: released global lock" thread::send $::x {incr ::finish} } # kick thread a out of lock after 5000 {thread::send $a {incr ::finish}} after 1000 { thread::send -async $b { puts "b: [thread::id], waiting for global lock" tsv::lock global { puts "b: got global lock ([tsv::get global true])" } puts "b: released global lock" } } vwait ::finish Output: a: 25173504 a: has global lock (1) b: 25174528, waiting for global lock b: got global lock (2) b: released global lock a: released global lock You can see that b was able to obtain the lock and access the tsv global array data while thread 'a' had the lock. I saw one message in the forum about this also but the person never got an answer there. Any clues? I peeked at the code and didn't see an immediate problem but I'm not familiar with that code at all. sanders012<at>earth.com - foundin changed to: "obsolete: 8.4.6"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "80. Thread Package"
- title changed to: "tsv::lock doesn't lock between threads"
- type changed to: "Bug"