summaryrefslogtreecommitdiff
path: root/cmd/Kconfig
diff options
context:
space:
mode:
authorJerome Forissier <[email protected]>2025-04-18 16:09:42 +0200
committerTom Rini <[email protected]>2025-04-23 13:19:44 -0600
commitec89a4f7a3cbdfe601a45c110b375e925190f095 (patch)
tree0cc58c3b91f33ddc658ab24a4b94b5ac375e6af7 /cmd/Kconfig
parent1c0f6999b5589315201ebb5aa659eb6658079b8e (diff)
cmd: add spawn and wait commands
Add a spawn command which runs another command in the background, as well as a wait command to suspend the shell until one or more background jobs have completed. The job_id environment variable is set by spawn and wait accepts optional job ids, so that one can selectively wait on any job. Example: => date; spawn sleep 5; spawn sleep 3; date; echo "waiting..."; wait; date Date: 2025-02-21 (Friday) Time: 17:04:52 Date: 2025-02-21 (Friday) Time: 17:04:52 waiting... Date: 2025-02-21 (Friday) Time: 17:04:57 => Another example showing how background jobs can make initlizations faster. The board is i.MX93 EVK, with one spinning HDD connected to USB1 via a hub, and a network cable plugged into ENET1. # From power up / reset u-boot=> setenv autoload 0 u-boot=> setenv ud "usb start; dhcp" u-boot=> time run ud [...] time: 8.058 seconds # From power up / reset u-boot=> setenv autoload 0 u-boot=> setenv ud "spawn usb start; spawn dhcp; wait" u-boot=> time run ud [...] time: 4.475 seconds Signed-off-by: Jerome Forissier <[email protected]> Acked-by: Ilias Apalodimas <[email protected]>
Diffstat (limited to 'cmd/Kconfig')
-rw-r--r--cmd/Kconfig17
1 files changed, 17 insertions, 0 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig
index c2ce519d1e3..2d31abcef73 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -3081,4 +3081,21 @@ config CMD_MESON
help
Enable useful commands for the Meson Soc family developed by Amlogic Inc.
+config CMD_SPAWN
+ bool "spawn and wait commands"
+ depends on UTHREAD
+ help
+ spawn runs a command in the background and sets the job_id environment
+ variable. wait is used to suspend the shell execution until one or more
+ jobs are complete.
+
+config CMD_SPAWN_NUM_JOBS
+ int "Maximum number of simultaneous jobs for spawn"
+ default 16
+ help
+ Job identifiers are in the range 1..CMD_SPAWN_NUM_JOBS. In other words
+ there can be no more that CMD_SPAWN_NUM_JOBS running simultaneously.
+ When a jobs exits, its identifier is available to be re-used by the next
+ spawn command.
+
endif