[Cook] parallel confusion

Jason Evans jasone at canonware.com
Wed Jun 25 01:53:40 EST 2003


On Fri, Jun 20, 2003 at 11:07:54PM -0500, Jerry Pendergraft wrote:
> You should try to keep each recipe to a single command. Because multiple
> commands will definately run in different threads, even on different
> machines. Having said that, remember you can do many things in a
> "single" command for example on of my more pathalogical ones:
> 
>    local cmd = [unsplit " " [catenate "PATH=" [getenv PATH]]
>       \[ -d [ts_C_dir] \] || mkdir [ts_C_dir] &&
>       /usr/local/bin/build_test_script --debug [ts_src] [C_file] &&
>       [compile-cmd %1 %2] [target_flags]
>         -D[catenate ARCH [arch-to-identifier %1]]
>         '-DRCS_ID\="'%3_ID'"' -c [C_file]
>         -o [target]                        &&
>       [post_proc] [C_file]] ;
> 
>     [cmd];
> 
> Note the && makes this series of commands be treated as one single one.

What makes you think that this is necessary?  Section 4.3.1 of the User
Guide says:

	Each recipe, when its actions are executed, is executed within an
	execution thread.

The quoted sentence states what I would expect to be the case.  To add more
support that each recipe invocation is sequentially executed by a single
thread, refer to the example of how to use the single-thread flag in
section 4.3:

	%.c: %.y
		single-thread yy.tab.c
	{
		[yacc] [yacc_flags] %.y;
		sed "'s/[yY][yY]/%_/g'" yy.tab.c > [target];
		rm yy.tab.c;
	}

The example talks about protecting against parallel invocations of that
recipe; it does not say anything about needing to serialize the statements
within the recipe body.

Jason



More information about the Cook-users mailing list