Questions tagged [concurrency]
The concurrency tag has no usage guidance.
74
questions
3
votes
1
answer
55
views
What is the minimum amount of memory required for starting a process on a Linux-based system?
Routines in both languages are inexpensive: goroutines are 2KB each, while Elixir processes are 0.5KB each.
I understand that to start a process in BEAM requires 0.5KB of memory. This being so ...
0
votes
2
answers
56
views
How might I execute this nested for loop in parallel?
#!/usr/bin/bash
TARGETS=(
"81.176.235.2"
"81.176.70.2"
"78.41.109.7"
)
myIPs=(
"185.164.100.1"
"185.164.100.2"
"185.164.100.3"
"185....
0
votes
1
answer
109
views
Testing file locking
I have a script which locks a file to avoid concurrent access to it, How can I execute this same script from two different terminals synchronously, to check if it works?
Here is the script
#!/bin/bash
...
0
votes
1
answer
33
views
Asynchronous downloading from virtual machine?
I have some files stored on a virtual machine that I'm downloading onto my PC. There are approximately 1 million files and I have been using the following command:
scp vm_user@IP:/home/vm_user/...
0
votes
1
answer
32
views
different process in Linux in a single core PC how been managed?
(this a dummy question)multiple processes are running in the background. my understanding is each CPU core can run only 1 process at a time. so someone has the ability to interrupt the current process(...
3
votes
2
answers
192
views
Concurrency of a find, hash val, and replace across large amount of rows
I have a bunch of files and for each row there is a unique value I'm trying to obscure with a hash.
However there are 3M rows across the files and a rough calculation of the time needed to complete ...
-1
votes
1
answer
40
views
Does inetd simplify server programs, without affecting the part of concurrently handling multiple clients? [closed]
In The Linux Programming Interface, Chapter 60 talks about
designing a server to concurrently handle multiple clients, by using sockets, multiple processes/threads or thread/process pools
designing ...
1
vote
3
answers
2k
views
Concurrency and Parallelism on Bash
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 ...
1
vote
1
answer
103
views
concurrent loops without using a subprocess
I'm working on a script in which I'm trying to have two concurrent timers within the same process.
In the following example, I'm trying to update the ip address every 60 seconds, while outputting the ...
1
vote
0
answers
37
views
Shell output of `ls | cat > new_file ` [duplicate]
The behavior of dash (and also bash) looks non-intuitive in this case.
It seems that new_file is created before ls is executed.
Is it specified in POSIX?
1
vote
1
answer
89
views
What happens if a file is renamed during a copy operation using cp on linux?
So I want to use...
cp /var/log/somelogs/* ./temp
... to copy some log files to a temporary folder and analyse them. The problem is that the process generating the log files isn't under my control ...
3
votes
1
answer
2k
views
Multiple processes redirecting to the same file with >
This is not a "how to append and not overwrite" question. I'm not looking for a file that combines the output of two commands. It's just a mistake I made and I would like to understand why the system ...
0
votes
0
answers
40
views
Can I turn kernel params to make the network stack using swap instead of physical memory?
I'm doing a test about high-currency, and I only have a machine with limited memory. My goal is to setup more than 10M TCP
connections on this memory limited machine. It seems that the network stack ...
5
votes
2
answers
131
views
Is file creation totally ordered?
On Linux, the openat syscall can be used to create files and to test for their existence. Speaking in terms of the C/C++ memory model, creating a file and verifying its existence creates a ...
0
votes
0
answers
142
views
Background processes in bash preserving order
From a GUI terminal emulator running bash, I would like to open a tabbed instance, get its X window ID, and use it to embed four st terminal instances inside tabbed, with titles from 1 to 4, in ...
6
votes
2
answers
3k
views
How to run multiple processes and exit if any of them exits or fails
I am running multiple processes and want to exit with the appropriate exit code (this means error on failure, success otherwise) if any of them fails or exists.
Additionally if any child process ...
0
votes
1
answer
80
views
Is extracting the first line from a file that is accessed via NFS thread safe?
If I mount a directory via NFS on multiple servers each running a process that reads and deletes the first line of a specific file in that directory, can it somehow be guaranteed that no line is read ...
0
votes
0
answers
860
views
How to find concurrent number of connections per second with Apache?
A web-server hosting an application for a client ; which is high-volume or transaction server, it is required to find out "number of concurrent connections" currently in use by the server. This is ...
4
votes
2
answers
1k
views
Can two asynchronous subshell commands safely write to a shared stdout?
Can stdout be overwritten by two bourne (or bash, if that matters) subshell commands running asynchronously?
(tail -f ./file1 & tail -f ./file2) | cat
I don’t care about the line order, just ...
1
vote
1
answer
50
views
How to run multiple 'serial' processes under control considering CPUs available? [duplicate]
Suppose you have a binary that has to be run on maaaaaaaaany files (suppose files are numbered from 1 to N). Each file has to be processed by making a call to this binary (say.... something like ...
1
vote
1
answer
2k
views
Lost wakeup problem - how does UNIX deal with it [closed]
(I give context for my question first, the question itself is at the bottom where it says QUESTION in bold).
Take two processes A and B. A checks a condition, sees that it isn't satisfied, and goes ...
3
votes
1
answer
315
views
Why does this gawk coprocess hang?
While having a go at Convert date in bash shell, I tried GNU awk's coprocess feature:
gawk -F, -v cmd='date +"%Y-%m-%d %H:%M:%S" -f-' '{print $5 |& cmd; cmd |& getline d; $5 = d}1' foo
This ...
4
votes
2
answers
2k
views
Prevent a shell fork from living longer than its initiator?
If I have a Bash script like:
function repeat {
while :; do
echo repeating; sleep 1
done
}
repeat &
echo running once
running once is printed once but repeat's fork lives forever,...
3
votes
2
answers
322
views
Terminate second (parallel) process if first one is terminated
Let's assume we have two shell scripts running in parallel
driver.sh:
./proc1.sh&
./proc2.sh&
how can I terminate a process if the other one exited with non-zero code? (terminate driver.sh)
3
votes
2
answers
237
views
Can you read an updated mtime, but when reading the contents they have yet to be updated?
Assuming touch etc. is not involved, just standard open, write, close, link system calls.
One process is updating files, another is periodically stating to see if they've changed and reloading the ...
5
votes
1
answer
3k
views
Are pipe reads not greater than PIPE_BUF atomic?
The GNU C library manual briefly mentioned that both reads and writes for a pipe are atomic
Reading or writing pipe data is atomic if the size of data written is not greater than PIPE_BUF.
However,...
11
votes
2
answers
17k
views
Concurrent writing to a log file from many processes
In mimicing MacOS's terminal's open command or Window's terminal's start, the comments of this answer suggest appending stdout and stderr to ~/.xsession-errors, something like (bash):
alias open='&...
4
votes
2
answers
2k
views
Is using tar while source directory is being updated safe?
I have to ask question similar to this.
In scenarios where you're backing up directory with tar and
new files/dirs are being added
current files/dirs are being edited and deleted
can you expect ...
2
votes
1
answer
1k
views
Parallel read the contents of a zipped file without extraction
I have the following zip archive structure:
$ unzip -l Undetermined_S0_L004_R1_001_fastqc.zip
Archive: Undetermined_S0_L004_R1_001_fastqc.zip
Length Date Time Name
-------- ---- ---...
1
vote
1
answer
477
views
Weird results of triple piping to STDOUT & tee /dev/null >(wc -l > tmp.txt) & piping again embedding `cat tmp.txt`
$ seq 1 12773 | tee /dev/null >(wc -l > tmp.txt) | head -$((0x`openssl rand -hex 7` % `cat tmp.txt` + 1))|tail -1
--> 8473 (random between 1~12773)
$ cat tmp.txt
--> 8473
$ seq 1 12774 | tee ...
0
votes
1
answer
3k
views
lock bash script to prevent parallel running from within the script itself?
I am aware of using flock and solo (not sure the difference though) when running from a cron job. However, is it possible to prevent parallel running from within the script itself?
3
votes
1
answer
1k
views
Will an `unlink` or `rename` portably and atomically make a `link` fail?
Question
Suppose I have some non-directory (file, named pipe/socket, whatever) at the pathname /tmp/foo and some other non-directory at the pathname /tmp/bar. Then two (or more) processes start ...
2
votes
2
answers
2k
views
concurrent curl could not resolve host
I try to run cocurrent curl but it can easily report "Could not resolve host". To run curl parallel, I use "parallel".
parallel :::: ./a.sh ./a.sh
from api server
% Total % Received % Xferd ...
7
votes
1
answer
6k
views
Multiple appenders writing to the same file on NFS share
If I have 100 servers execute a command, and each redirects their output to the same file on an NFS share, will the resultant file be interleaved neatly or can it become corrupt?
For example, if this ...
2
votes
1
answer
2k
views
Does linux tar block write access to files
I have a large (>10GB) folder full of images on a live webserver that I need to back up and transfer.
I'm worried that if I tar the folder, the files will be blocked for reading by the webserver, ...
1
vote
2
answers
2k
views
Allow one entry at a time in incron job?
I have a directory to monitor. When it is updated, I run some command via incron. When multiple files are copied in this directory, incron execute multiple commands at the same time. Is there any way ...
1
vote
2
answers
28
views
running codes simultaneously while outputting result one by one
I have a scripts looks like:
for simplify in 0.1 ;do
for lmbda in 0.9 1.1 1.3;do
for mu in 2.1 3.4 4.2;do
rm eci.out;
csce.py --mu $mu --lmbda $lmbda --simplify $simplify \
...
7
votes
2
answers
9k
views
Delete file while it is in use
I have a process that receives a video file (RAW) and transcodes it with FFMPEG generating three (different resolutions) resultant files. I'm using a distributed task queue system (Celery) to process ...
3
votes
1
answer
2k
views
Multiple simultaneous instances of apt-get
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
What does these ...
1
vote
0
answers
34
views
Limit cpu usage to one core [duplicate]
I want to run a server with user-written scripts. But these scripts should only use one core (which should be the one with the lowest usage because there will be many concurrent scripts). Also I need ...
11
votes
4
answers
5k
views
How to atomically allocate a loop device?
I am writing some shell scripts to handle some disk image stuff, and I need to use loop devices to access some disk images. However, I am not sure how to properly allocate a loop device without ...
1
vote
2
answers
899
views
Background processes mix up order of shell script execution
Can someone explain me why the script
echo one &&
echo two &
echo three &&
echo four
gives me
[1] 3692
three
four
one
two
[1]+ Done echo one && ...
9
votes
2
answers
677
views
How bash treats "> >()"
While experimenting with output redirection and process substitution I stumbled upon the following command and its resulting output:
me@elem:~$ echo foo > >(cat); echo bar
bar
me@elem:~$ ...
2
votes
2
answers
866
views
Linux lockfile starvation
I want to use lockfile functionality for a bash script that will run in parallel. The problem is that in a functionality as in the script below, a starvation can happen in case that the first one to ...
3
votes
3
answers
2k
views
Atomic removal of directory
Because rename(2) is called by mv, is it safe to assume the following would be atomic?
$ mv /home/me/someDir /tmp/toBeDeleted
$ rm -rf /tmp/toBeDeleted
3
votes
2
answers
3k
views
Am I hitting a race condition in bash?
I have a script which compares the output of a command with the output of the same command as it was ran previously, it works most of the time, but every now and then it doesn't work as expected.
I'...
1
vote
2
answers
3k
views
How to run "&" operation sequentially
From my script I am running following commands:
SCRIPT_1="ksh -x script1.sh & ksh -x script2.sh";
SCRIPT_2="ksh -x script3.sh & ksh -x script4.sh";
eval $SCRIPT_1;
sleep 20s;
eval $...
2
votes
1
answer
1k
views
Concurrency problems with GNU parallel
My scripts are having trouble with correctly running things in GNU parallel.
I have a sub_script like so (all these are actually simplified versions):
#! /bin/bash
input=$1
# input is a date in ...
1
vote
1
answer
2k
views
Running commands after ampersand symbol & in a remote ssh session
I have a shell script that initiates a long, resource-intensive command on several different machines.
In order to execute the script on each machine in parallel, I have an ampersand symbol after ...
4
votes
1
answer
2k
views
Advantages of using named pipes and sockets rather than temporary files
I have two cooperating programs. One program just writes its output to a file and the other one then reads from the file and spits the data out for the front end to work with.
I have been reading ...