Skip to main content
Adjusted on the basis of https://unix.stackexchange.com/a/474807/65008
Source Link
lev
  • 599
  • 4
  • 5
for stuff in things
do
sem -j+0 ("something; something\
  with
with; \
 stuff )stuff"
done
sem --wait

This will use semaphores, parallelizing as many iterations as the number of available cores (-j +0 means you will parallelize N+0 jobs, where N is the number of available cores).

sem --wait tells to wait until all the iterations in the for loop have terminated execution before executing the successive lines of code.

Note: you will need "parallel" from the GNU parallel project (sudo apt-get install parallel).

for stuff in things
do
sem -j+0 ( something
  with
  stuff )
done
sem --wait

This will use semaphores, parallelizing as many iterations as the number of available cores (-j +0 means you will parallelize N+0 jobs, where N is the number of available cores).

sem --wait tells to wait until all the iterations in the for loop have terminated execution before executing the successive lines of code.

Note: you will need "parallel" from the GNU parallel project (sudo apt-get install parallel).

for stuff in things
do
sem -j+0 "something; \
  with; \
  stuff"
done
sem --wait

This will use semaphores, parallelizing as many iterations as the number of available cores (-j +0 means you will parallelize N+0 jobs, where N is the number of available cores).

sem --wait tells to wait until all the iterations in the for loop have terminated execution before executing the successive lines of code.

Note: you will need "parallel" from the GNU parallel project (sudo apt-get install parallel).

add link to https://www.gnu.org/software/parallel/
Source Link
for stuff in things
do
sem -j+0 ( something
  with
  stuff )
done
sem --wait

This will use semaphores, parallelizing as many iterations as the number of available cores (-j +0 means you will parallelize N+0 jobs, where N is the number of available cores).

sem --wait tells to wait until all the iterations in the for loop have terminated execution before executing the successive lines of code.

Note: you will need "parallel" from the GNU parallel project (sudo apt-get install parallel).

for stuff in things
do
sem -j+0 ( something
  with
  stuff )
done
sem --wait

This will use semaphores, parallelizing as many iterations as the number of available cores (-j +0 means you will parallelize N+0 jobs, where N is the number of available cores).

sem --wait tells to wait until all the iterations in the for loop have terminated execution before executing the successive lines of code.

Note: you will need "parallel" (sudo apt-get install parallel).

for stuff in things
do
sem -j+0 ( something
  with
  stuff )
done
sem --wait

This will use semaphores, parallelizing as many iterations as the number of available cores (-j +0 means you will parallelize N+0 jobs, where N is the number of available cores).

sem --wait tells to wait until all the iterations in the for loop have terminated execution before executing the successive lines of code.

Note: you will need "parallel" from the GNU parallel project (sudo apt-get install parallel).

deleted 1 character in body
Source Link
lev
  • 599
  • 4
  • 5
for stuff in things
do
sem -j +0j+0 ( something
  with
  stuff )
done
sem --wait

This will use semaphores, parallelizing as many iterations as the number of available cores (-j +0 means you will parallelize N+0 jobs, where N is the number of available cores).

sem --wait tells to wait until all the iterations in the for loop have terminated execution before executing the successive lines of code.

Note: you will need "parallel" (sudo apt-get install parallel).

for stuff in things
do
sem -j +0 ( something
  with
  stuff )
done
sem --wait

This will use semaphores, parallelizing as many iterations as the number of available cores (-j +0 means you will parallelize N+0 jobs, where N is the number of available cores).

sem --wait tells to wait until all the iterations in the for loop have terminated execution before executing the successive lines of code.

Note: you will need "parallel" (sudo apt-get install parallel).

for stuff in things
do
sem -j+0 ( something
  with
  stuff )
done
sem --wait

This will use semaphores, parallelizing as many iterations as the number of available cores (-j +0 means you will parallelize N+0 jobs, where N is the number of available cores).

sem --wait tells to wait until all the iterations in the for loop have terminated execution before executing the successive lines of code.

Note: you will need "parallel" (sudo apt-get install parallel).

Source Link
lev
  • 599
  • 4
  • 5
Loading