[Nomen-dev] Yet more threads
Brought to you by:
bhurt
|
From: Brian H. <bh...@sp...> - 2002-03-30 00:01:17
|
Sorry for the barrage of posts- I'm thinking into email. Here's the problem. Say I have two objects, A and B, and A dominates B (see previous rant). That means that B doesn't have it's own lock, it's protected by A. So mean old thread X wanders along, grabs the lock to object A, uses it to gets a reference to object B, and assigns that reference to object C. Object C may or may not be dominated by object A. If C is not dominated by A, we need to add a lock to B. No big problem, the lock just has to be created owned by thread X. Also, all the other threads have to suddenly be updated to know they need to lock B as well as A. Which probably means we have a bit somewhere- every time we follow a pointer we need to do a branch, possibly bypassing grabbing a lock. Not a big problem, but yet another problem. But we also need to know that C is dominated by A. Also, domination is transitive- all the objects dominated by B are also dominated by A. If we just keep a "I'm dominated by..." pointer in the object, this means that all the objects dominated by B had A in their dominated pointer field- now that has to be changed to B. Wait a minute- maybe I'm looking at this at the wrong level. OK, we have generational copying garbage collection. 'Generational' is the wrong word- what if I broke my memory up into blocks. Say, 64K as a talking number (that feels of the right order of magnitude). The whole block has a lock around it. To access any object in the block, you need to access the lock. Copying garbage collection will tend to "sort" objects so that objects with references to each other will end up "close". This is an observed effect. The very act of garbage collection would then tend to optimize lock usage as well. There's also the possibility of variable-sized regions. I'm not sure about this- one of the attractions is that it lets me split a large data structure automatically up into smaller regions. Maybe variable sized, but with an upper limit. Then there's the question of "what's a data structure?" Brian |