Re: netcamlbox: checking the mail box without waiting
Hugo Ferreira <[email protected]> Tue, 23 Mar 2010 19:08:19 +0000
| Newsgroups | gmane.comp.lang.ocaml.lib.net.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello,
Gerd Stolpmann wrote:
> On Di, 2010-03-23 at 15:50 +0000, Hugo Ferreira wrote:
snip..
>> Fatal error: exception Unix.Unix_error(20, "shm_open", "/camlbox_9838_0")
>> Raised by primitive operation at unknown location
>> Called from file "netcamlbox.ml", line 322, characters 4-21
>
> 20 is ENOENT, so I guess you unlinked the shm object before.
>
Correct. I unlink the mbox as per your example.
No need to keep it around.
>> For testing purposes I used:
snip...
>> My question is: how do I go about avoiding the block
>> on a mailing box?
>
> Well, generally you need some trigger from the worker, and a counter.
> The trigger should be a message the worker sends out when it freed a
> slot. The counter could be implemented inside the coordinator, or as a
> shared counter (i.e. as semaphore). That depends on a lot of details, so
> without knowing the code I cannot give an advice.
>
Interesting. I was looking at it the other way around.
In other words workers wait on their mboxes for work.
In fact I had envisioned a common mbox for all task dispatch.
In the meantime I have looked at the mbox source code.
I realized that with a small change to camlbox_messages
my problem is solved. I have altered it to:
let camlbox_messages box =
Netsys_posix.sem_getvalue box.sem.s_free_slots
Upon reflection I have come to realize that:
a) I am in fact using a global counter to push work
onto idle workers (basically does as you suggested -
use a counting semaphore).
b) I think that "camlbox_messages" should use a box because
it is a:
i) a value of a specific mbox and
ii) allows faster access to the same information.
Might I suggest the above alteration to the API?
Thanks for the suggestions.
Regards,
Hugo F.
> Gerd
>
>> TIA,
>> Hugo F.
>>
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Download Intel® Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> Ocamlnet-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/ocamlnet-devel
>>
>
>
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev