<div dir="ltr">Thank you Maxim. Will try to see if I can get to the single threaded model. Basically when I was talking about accept_mutex, what I meant was, if the worker thread is busy with my cpu-intensive work, I would obviously want the other workers to take over. IIUC, if I have the accept mutex I am the one who will take the requests, is it possible that my worker plugin is caught up doing the work *and* has not released the mutex? In other words, is it possible that my CPU intensive operation prevents other workers who are free from taking requests with any configuration option enabled/disabled.</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jan 2, 2013 at 2:49 AM, Maxim Dounin <span dir="ltr"><<a href="mailto:mdounin@mdounin.ru" target="_blank">mdounin@mdounin.ru</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello!<br>
<div class="im"><br>
On Tue, Jan 01, 2013 at 11:57:30PM +0530, Fasih wrote:<br>
<br>
> Hi guys<br>
><br>
> I need to write a plugin which does some CPU intensive work. I want to be<br>
> able to create a thread which does some work and once done post an event<br>
> into nginx thread via ngx_add_timer. I tried compiling my plugin with<br>
> NGX_THREADS=pthread but that doesnt configure saying that the threading<br>
> support is broken. I can obviously switch to a single threaded mode but<br>
> that would be significantly difficult for me and would prefer to use only<br>
> as the very last resort.<br>
><br>
> Can you please advice how to go about doing this? I am considering pulling<br>
> out the usage of 'ngx_event_timer_mutex' outside #if NGX_THREADS. Frankly I<br>
> am surprised how no other plugin had this kind of requirement, the "broken<br>
> support" commit has been there since quite some time now.<br>
<br>
</div>Threading support as currently present was an experiment, and it's<br>
broken for a long time (some very limited part of it is still used<br>
on win32, but it's different story). I wouldn't expect you'll be<br>
able to work with threads without problems.<br>
<div class="im"><br>
> One final question, if I do the CPU intensive work in the nginx thread and<br>
> I have <cpu-cores> number of workers, how would the system behave? Will<br>
> accept_mutex on/off change the behavior?<br>
<br>
</div>Accept mutex only ensures no two processes try to accept new<br>
connections at the same time, and it doesn't care how do you<br>
handle requests. Obviously enough it will change the behaviour,<br>
much like in any other case.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Maxim Dounin<br>
<a href="http://nginx.com/support.html" target="_blank">http://nginx.com/support.html</a><br>
<br>
_______________________________________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a><br>
</font></span></blockquote></div><br></div>