tech-userlevel archive

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

Re: pthread_key_{create,delete} pthread_{g,s}etspecific on NetBSD



On Dec 4,  3:33pm, dholland-tech%netbsd.org@localhost (David Holland) wrote:
-- Subject: Re: pthread_key_{create,delete} pthread_{g,s}etspecific on NetBSD

| On Mon, Dec 03, 2012 at 11:23:39AM -0500, Christos Zoulas wrote:
|  > The size increase is not really necessary if you are willing to
|  > pay the cost of going through the all_thread list when you remove
|  > a key (and hold a different lock). Having said that, even in the
|  > case of 1000 threads, this just amounts to 6M of memory on a 64
|  > bit host, instread of ~2M, since I've added 2 pointers to the array
|  > of 256 keys; you need at least one more to hold the data.
| 
| Shouldn't a singly-linked list serve?

You are going to pay more at join time then; which might not such a big
deal (you get to linearly scan to delete, and stop all threads in the
meantime).

| Also it seems like it would be better to allocate the space when a key
| is added to a thread, e.g. by allocating a resizeable array in the
| global structures instead of stuffing list links in every thread.

I thought about that, but then you end up allocating on all new
threads once a key is added to any thread. And I think that most
programs use get/set specific, so you just end up allocating the
space from the heap.

christos


Home | Main Index | Thread Index | Old Index