lua-users home
lua-l archive

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

On 11/16/06, Russ Cox <> 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)
   luaG_runerror(L, "setdetachstate");

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()?