tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Semantics of copying mutex/rwlock



On 2010年6月16日 11:27:48 -0400 (EDT)
der Mouse <mouse%Rodents-Montreal.ORG@localhost> wrote:
> > What I do is call pthread_mutex_destroy() on every old lock,
> > allocate a new array, call pthread_mutex_init() on all locks in new
> > array and then free old array. I guess there is no way around it.
> 
> There is, actually - you could use an array of pthread_mutex_t *, with
> the mutexes themselves allocated separately and individually. It
> means more allocations and complicated allocation code, it might be
> worth it.
Yeah it's a good idea, this is what I do with hash table buckets, it's
just a pointer to linked list. I definitely need to run a benchmark to
see if malloc()/*init() for each new lock is faster.


Home | Main Index | Thread Index | Old Index

AltStyle によって変換されたページ (->オリジナル) /