I'm a bit confused about concurrency and parallelism in the bash shell. As I understand it, when we run commands in more than one subshells at the same time, these commands run in parallel on individual processor cores.
**For example;**
cmd1 & cmd2 & cmd3 &
Here, the "ampersand" sign is run in the background (aka the subshells) of each command at the same time.It could be create in subshells in other ways. (Like writing in parentheses or using a pipe ..).
In this direction, the questions I wonder the answers of;
- Bash provides parallelism through subshells, other hand is concurrency also achieved using another method on bash? As far as I know, concurrency works in a way that a single CPU executes operations intermittently. Do I need to implement a method externally to achieve this, or is bash already working this way (concurrency ) anyway.
- If I occupy all CPU cores using parallelism, will the system crash or is there a protection mechanism against this situation?
- What is the difference between the parallel I provide with subshells and the
GNU Parallel tool? If the GNU Parallel tool works better, how does it achieve this?
- Which of the "Parallel" or "Concurrency" operations works more efficiently?
- What kind of losses are experienced when making "parallel" or "concurrency" operation, unlike normal (sequential execution of commands)?
Asked by testter
(1510 rep)
Oct 22, 2020, 04:21 PM
Last activity: Jul 2, 2024, 02:47 PM
Last activity: Jul 2, 2024, 02:47 PM