1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0+
3#
4# Start up the specified number of jitter.sh scripts in the background.
5#
6# Usage: . jitterstart.sh n jittering-dir duration [ sleepmax [ spinmax ] ]
7#
8# n: Number of jitter.sh scripts to start up.
9# jittering-dir: Directory in which to put "jittering" file.
10# duration: Time to run in seconds.
11# sleepmax: Maximum microseconds to sleep, defaults to one second.
12# spinmax: Maximum microseconds to spin, defaults to one millisecond.
13#
14# Copyright (C) 2021 Facebook, Inc.
15#
16# Authors: Paul E. McKenney <paulmck@kernel.org>
17
18jitter_n=$1
19if test -z "$jitter_n"
20then
21	echo jitterstart.sh: Missing count of jitter.sh scripts to start.
22	exit 33
23fi
24jittering_dir=$2
25if test -z "$jittering_dir"
26then
27	echo jitterstart.sh: Missing directory in which to place jittering file.
28	exit 34
29fi
30shift
31shift
32
33touch ${jittering_dir}/jittering
34for ((jitter_i = 1; jitter_i <= $jitter_n; jitter_i++))
35do
36	jitter.sh $jitter_i "${jittering_dir}/jittering" "$@" &
37done
38