Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Resource Manager threads ( Max number of threads): (2 Items)
   
Resource Manager threads ( Max number of threads)  
Hi 

I am writing multi threaded resource manager , and came across this below document which explains about the threadpool

http://www.qnx.com/developers/docs/qnxcar2/index.jsp?topic=%2Fcom.qnx.doc.neutrino.getting_started%2Ftopic%
2Fs1_procs_tpool.html

I would like to know which is optimistic approach, i am keeping the settings as 

    pool_attr.lo_water = 3;
    pool_attr.hi_water = 20;
    pool_attr.increment = 1;
    pool_attr.maximum = 20;

Would like to know if we keep maximum threads as > 20 will it cause system to hang i mean will it demand more resources 
like cache, memory and CPU.
Or do we need to keep at lower side.

What happens if the increment is more than 1 how it will effect the performance. Do i keep it as 1.

Re: Resource Manager threads ( Max number of threads)  
Hi Thomas,
I don't think that there are general recommendations that are always valid. It largely depends on the nature of your 
resource manager. Here are some questions that you might want to ask yourself:
- How dynamic is the load on your resource manager expected? Is it a more steady state software where load oscillates 
slightly around some avarage, or do you expect large load peaks, maybe even aperiodically?
- Can you actually handle multiple requests truly in parallel? For instance, if the resource manager needs to access 
some backend storage or hardware to fulfil a task, then a high number of running threads would not help at all if they 
all queue up on a lock on such a resource.
- Is a realtime response to a request necessary, and what is the expected reaction time?

So depending on how the answers look like, here are some properties that I came across:
- W.r.t. realtime, the most critical part is the "increment", because it is evaluated after receiving, but prior (!) to 
handling a message. To be more clear, if the resource manager receives a message, and it finds that the number of 
RECEIVE blocked threads is below lo_water, it creates "increment" new threads prior to calling the handler for the 
message, which can spoil realtime responsiveness.
- If you expect large load peaks AND can truly handle them in parallel AND the handling may enter blocking states other 
than acquiring internal locks, you can set the maximum above 20, so that the bulk work can be done faster.
- Maximum should be well above hi_water, since otherwise the thread pool would need todestroy threads even though there 
are no more threads in RECEIVE blocked state.
- Alternatively, you can create steady-state pools by setting all attributes to the same value if you have rather 
constant load on your resource manager.

W.r.t. resource usage, if the threads use a dynamically allocated stack I think in nowadays systems the resources  used 
by blocked threads weigh less than the resulting speed in software operation.

Hope this helps, just do some experiments and compare behaviour.

Regards,
Albrecht