I am using taskset according to linux manual page in order to run a very processing intense task only on specific cores.
The taskset is encapsulated in a loop. Each time a new target directory is selected and the task is beeing run. Running the process multiple times in parallel may lead to fatal results.
The pseudo code is as follows:
#!/bin/bash
while :
do
target_dir=$(select_dir) # select new directory to process
sudo taskset -c 4,5,6,7,8,9,10,11 ./processing_intense_task --dir $target_dir
done
I have found nothing in the documentation if taskset actually waits for the process to finish.
If it does not wait, how do I wait for the task completion before starting a new instance of processing_intense_task
?
CodePudding user response:
the documentation if taskset actually waits for the process to finish.
Taskset executes exec, so it becomes the command. https://github.com/util-linux/util-linux/blob/master/schedutils/taskset.c#L246
This is the same as do other similar commands, like nice
ionice
.
If it does not wait,
Well, technically taskset doesn't wait, it becomes the command itself.
how do I wait for the task completion before starting a new instance of processing_intense_task?
You just wait for taskset process to finish, as it's the same process as the command. I.e. do nothing.