Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2004-12-02
22:33 • Closed ticket [1077210fff]: revise mutex in AliasCreate plus 7 other changes artifact: fbd73cdec6 user: dkf
17:50 • Ticket [1077210fff]: 4 changes artifact: f92d83140a user: dkf
16:25 • Ticket [1077210fff]: 4 changes artifact: 6e012d0da7 user: dkf
16:25 • Ticket [1077210fff]: 1 change artifact: 4b14dc62fd user: dkf
07:46 • Ticket [1077210fff]: 4 changes artifact: f5424aa7c9 user: dgp
00:39 • New ticket [1077210fff]. artifact: 2fa6c2dc17 user: dgp

revise mutex in AliasCreate

Closed / Fixed1077210fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 22 years ago
Descriptionplain2004-12-02 00:39:38
All interps in all threads are
sharing one value of aliasCounter
with mutex protection.

The aliasCounter values only
need to be unique within 
each masterPtr->targetTable,
and each of those will only be
accessed by a single thread, IIUC.

This means we could have a
counter value for each thread 
(Tcl_GetThreadData) instead
of using mutex.
dgpplain2004-12-02 07:46:41
Logged In: YES 
user_id=80530


The use of the nsMutex
in tclNamesp.c is very similar.
so I'll mention it here rather
than open another report.
Again, use of a process-global
counter, where per-thread
(or even per-interp) would do.
dkf Ticket [1077210fff]: 1 change [History diff]2004-12-02 16:25:09
dkfplain2004-12-02 16:25:10
Logged In: YES 
user_id=79902

Why do we have a hash table for alias targets at all? It
looks to me like a deque would be the perfect data structure
here (and cheaper in terms of memory too?) and that wouldn't
need such a piece of mutex-protected state at all.

The mutex-protected stuff in tclNamesp.c should be replaced
with a per-thread counter.

This is a candidate for fixing once we've got 8.5a2 out the
door.
dkfplain2004-12-02 17:50:10
Logged In: YES 
user_id=79902

Fixed tclNamesp.c with some thread-local data magic; appears
to cause no new test-suite failures.
dkfplain2004-12-02 22:33:39
Logged In: YES 
user_id=79902

It turns out that the master references could be (and should
have always been) stored as linked lists instead of in a
hashtable. The hashtable bought a little simplicity in one
spot (the list unlinking code) at the cost of quite a lot of
complexity elsewhere (general obscurity and the use of
global state to issue keys!) Fixed in HEAD
Log in (anonymous is fine) to add a comment.