On Sun, Aug 06, 2000 at 08:33:52AM -0400, John Tobey wrote:
> If the stuff lives in an arena, have one mutex-init lock per page of
> the arena.  I imagine every arena page will be aligned on 4k or so and
> will have a structure at the beginning containing the interpreter
> pointer and stuff like this mutex.  This structure will be found by
> masking the final bits of the variable_data pointer.
> 
>     struct arena_page_header {
>         Interpreter* owner;
>         Lock share_init_lock;
>         /* ... ? */
>     };
> 
>     struct arena_page_header* sv_get_page_header(SV* sv) {
>         return (struct arena_page_header*)sv->variable_data & ~0xfff;
>     }
> 
>     void sv_init_mutex(SV* sv) {
>         Lock* init_lock = &sv_get_page_header(sv)->share_init_lock;
>         lock(init_lock);
>         sv_upgrade_to_shared(sv);
>         /* sv_lock(sv); */
>         unlock(init_lock);
>     }

*sigh* I need more sleep.  sv_lock(sv) here is misplaced; sv_upgrade
needs to hold the lock that it creates.  This share_init_lock would be
better named simply C<lock>, since it's the same one that will be used
for moving data around, allocating and deallocating in the arena.

-John

> This avoids requiring non-shared values to contain individual mutexen.

Reply via email to