Re: netcamlbox: checking the mail box without waiting

Gerd Stolpmann <[email protected]> Tue, 23 Mar 2010 19:51:56 +0100
Newsgroups gmane.comp.lang.ocaml.lib.net.devel
Message-ID <1269370316.7681.143.camel@thinkpad>
On Di, 2010-03-23 at 15:50 +0000, Hugo Ferreira wrote:
> Hello,
> 
> I am trying to use netcaml3 mailbox to
> allow a coordinator process to distribute
> tasks among worker processes. To do this
> I must check if any process's message box has
> space. If so I place a request for task
> execution otherwise I go on and do something
> else (process worker responses).
> 
> To check the mail box free space I tried to use:
>    let n = Netcamlbox.camlbox_messages wname in
> 
> and if (n - message_size) I proceed with the
> blocking calls (wait and send). My problem
> is that when I call this function from the
> coordinator process I get:
> 
> 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.

> For testing purposes I used:
> 
>    let wslots = 2 in (* maximum of two messages queued for each worker *)
>    let wboxes =  Array.init n_workers
>                    ( fun k ->
>                      let wname = mname ^ "_" ^ string_of_int k in
>                      let wbox, _, ws = prep_mbox wname wslots msg_size in
>                      let n = Netcamlbox.camlbox_messages wname in
>                      (wname, wbox, ws) ) in
>    let coord_box = (mname, mbox, mfd, ms) in
>    let worker_boxs = wboxes in
>    coord_box, worker_boxs
> 
> 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.

Gerd

> 
> TIA,
> Hugo F.
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> Download Intel&#174; 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
> 


-- 
------------------------------------------------------------
Gerd Stolpmann, Bad Nauheimer Str.3, 64289 Darmstadt,Germany 
[email protected]          http://www.gerd-stolpmann.de
Phone: +49-6151-153855                  Fax: +49-6151-997714
------------------------------------------------------------


------------------------------------------------------------------------------
Download Intel&#174; 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