[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: occasional threading in lua
- From: "Taj Khattra" <taj.khattra@...>
- Date: Mon, 27 Nov 2006 03:13:30 -0800
On 11/16/06, Russ Cox <firstname.lastname@example.org> wrote:
This program ends up using just two pthreads.
is this true in the current implementation - both cases seem to create
a sequence of pthreads?
I'd be happy to hear comments or suggestions for even
simpler ways to accomplish this.
it seems like sched_mutex is acquired iff vm_mutex is held - could we
get by with just one mutex?
on linux 2.6 x86, i noticed that the vmsize and rss keep increasing
(until vmsize maxes out at 3GB). since the pthreads are created as
"joinable" by default, their memory isn't reclaimed when they exit.
i added a global pthread_attr_t object, initialize it in luaopen_thread()
if(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0)
and passed it as the second argument to pthread_create() in
luaT_vm_unlock(). another option would be to call
pthread_detach(pthread_self()) in luaT_scheduler().
i also noticed that the default stack size for each pthread is a
whopping 8MB (RLIMIT_STACK) on my linux box. depending on how many
concurrent threads one expects, is it worth having an option to reduce
this by using pthread_attr_setstacksize()?