[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: multi-threaded compiling
From: |
Mischa Baars |
Subject: |
Re: multi-threaded compiling |
Date: |
Tue, 12 Mar 2024 13:30:05 +0100 |
On Tue, Mar 12, 2024 at 12:19 PM Greg Wooledge <greg@wooledge.org> wrote:
> On Tue, Mar 12, 2024 at 10:33:36AM +0100, Mischa Baars wrote:
> > bash -c 'set +m; seconds=1; for (( i=0;i<32;i++ )); do exit ${i} & done;
> > sleep ${seconds}; for (( i=0;i<32;i++ )); do wait -p pid; e=${?}; echo
> > "$(printf %3u ${i}) pid ${pid} exit ${e}"; done;'
>
> "wait -p pid" is not correct here. In that command, pid is an output
> variable, and you have not specified any process IDs to wait for -- so
> wait is going to wait for *all* of the children to finish, and you'll
> get zero as the exit status:
>
These are the two waits I'm now using:
wait ${pid[${i}]};
wait -np pid;
Which gives the following two lines to execute either from script or from
makefile:
script:
seconds=5; for (( i=0;i<32;i++ )); do exit ${i} & pid[${i}]=${!}; done;
sleep ${seconds}; for (( i=0;i<32;i++ )); do wait ${pid[${i}]}; e=${?};
echo "$(printf %3u ${i}) pid ${pid[${i}]} exit ${e}"; done;
seconds=5; for (( i=0;i<32;i++ )); do exit ${i} & done;
sleep ${seconds}; for (( i=0;i<32;i++ )); do wait -np pid; e=${?};
echo "$(printf %3u ${i}) pid ${pid} exit ${e}"; done; #!!! script
only !!!
makefile:
seconds=5; for (( i=0;i<32;i++ )); do exit $${i} & pid[$${i}]=$${!}; done;
sleep $${seconds}; for (( i=0;i<32;i++ )); do wait $${pid[$${i}]}; e=$${?};
echo "$$(printf %3u $${i}) pid $${pid[$${i}]} exit $${e}"; done;
seconds=5; for (( i=0;i<32;i++ )); do exit $${i} & done;
sleep $${seconds}; for (( i=0;i<32;i++ )); do wait -np pid; e=$${?};
echo "$$(printf %3u $${i}) pid $${pid} exit $${e}"; done; #???
script only ???
The first executes correctly from both the script and the Makefile. The
second only executes correctly from script.
> $ help wait
> [...]
>
> Waits for each process identified by an ID, which may be a process ID
> or a
> job specification, and reports its termination status. If ID is not
> given, waits for all currently active child processes, and the return
> status is zero. If ID is a job specification, waits for all processes
> in that job's pipeline.
>
>
- Re: multi-threaded compiling, (continued)
- Re: multi-threaded compiling, Mischa Baars, 2024/03/12
- Re: multi-threaded compiling, Robert Elz, 2024/03/12
- Re: multi-threaded compiling, Greg Wooledge, 2024/03/12
- Re: multi-threaded compiling, Mischa Baars, 2024/03/12
- Re: multi-threaded compiling, Chet Ramey, 2024/03/12
- Re: multi-threaded compiling, Mischa Baars, 2024/03/12
- Re: multi-threaded compiling, Martin D Kealey, 2024/03/12
- Re: multi-threaded compiling, Mischa Baars, 2024/03/13
- Re: multi-threaded compiling, Mischa Baars, 2024/03/12
- Re: multi-threaded compiling, Greg Wooledge, 2024/03/12
- Re: multi-threaded compiling,
Mischa Baars <=
- Re: multi-threaded compiling, Mischa Baars, 2024/03/12
- Re: multi-threaded compiling, Mischa Baars, 2024/03/11
- Re: multi-threaded compiling, alex xmb sw ratchev, 2024/03/11
- Re: multi-threaded compiling, alex xmb sw ratchev, 2024/03/11
- Re: multi-threaded compiling, Mischa Baars, 2024/03/11
- Re: multi-threaded compiling, alex xmb sw ratchev, 2024/03/11
- Re: multi-threaded compiling, Greg Wooledge, 2024/03/11
- Re: multi-threaded compiling, Paul Smith, 2024/03/11
- Re: multi-threaded compiling, Mischa Baars, 2024/03/11
- Re: multi-threaded compiling, alex xmb sw ratchev, 2024/03/11