[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaTask needs your help
- From: Daniel Quintela <dq@...>
- Date: Sun, 08 Jul 2007 12:06:42 -0300
Duck escribió:
It seems to work across TASK_SLOTS_STEP boundaries when I use the test
code I had before. I tried creating 10 simultanous tasks, then 20, 40,
80,
160, 320 -- all good!
:-)
However, I can't create more than 509 tasks, i.e. 510 in total, including
the "_main_".
When I call task.create() for the 510th time, I get error -3 (can't
create message queue). This happens with PTHREAD_STACK_SIZE set to 1m
or to 2m. With the default PTHREAD_STACK_SIZE of 8m I get error -4
(can't create os thread) at the 383rd task, presumably because I have
exhausted all 3g of virtual memory at that point.
Note that this isn't a new problem -- it exists with the 1.6.1 code as
well. I didn't realise it before because the segfault after
(TASK_SLOT_STEP-1) calls to task.create() got in the way :-) I just went
back to 1.6.1 and compiled with TASK_SLOT_STEP set to 600 in order to see
what happens: you get err -3 from the 510th call to task.create().
The real error is "EMFILE 24 /* Too many open files */" trying to
create a pipe inside "QueCreate".
See your Linux limit with "ulimit -n".
Remember that each Queue needs one pipe == two file descriptors.
About the code itself, I have two suggestions.
Firstly, when you allocate space for the TASK_ENTRYs themselves (not the
list of pointers to TASK_ENTRYs), you don't check the return value of
malloc() for NULL.
You are right... but remember it is a "candidate". ;-)
Secondly, I'd strongly suggest factoring the actual malloc/realloc code
out into a function so it appears only once. At the moment you are
repeating code (except for a malloc() versus a realloc() -- and realloc()
behaves like malloc() when you feed it NULL). This means there are two
places to introduce errors or discrepancies.
Good idea.
My 2c.
Thanks,
Daniel