Questions tagged [multithreading]
The multithreading tag has no usage guidance.
153
questions
0
votes
1
answer
18
views
Is there a way to prevent a descendant thread from getting into cgroup of its ancestor thread automatically?
I write some threads of my app to a Linux cpu cgroup, created by me, explicitly (let us talk e.g. about v1 for now, but if you know a way for v2, that would be also great).
However, I see that ...
0
votes
0
answers
192
views
Does Linux provide a method to fix a thread to a P-core or E-core?
On chips 12th gen and newer in the Intel lineup, (and I'm told on ARM chips) there are distinct classes of cores with different clock speeds
P-cores for performance, higher clock speed
E-cores for ...
0
votes
0
answers
23
views
Frequency of Intra versus interprocess context switching
In a book I'm reading (from 2013) it says that, in the Linux Kernel, intraprocess switching is much more cheaper than interprocess switching, I guess, because the switching in a same CPU between two ...
0
votes
1
answer
100
views
How many times has my process been preempted?
I wrote a simple program with a thread which runs on a CPU core. It spins kind of aggressively, and it takes 100% of the CPU core. I can see that with top + 1.
After N minutes, I would like to be able ...
0
votes
0
answers
79
views
sigtimedwait sets errno to ETIMEDOUT with timeout=0
In a cpp multithreaded program, we're using a copy of Linux sigwait implementation at the end of our main function, after creating all threads and initializing our program:
sigset_t mask;
...
3
votes
2
answers
287
views
Why does higher CPU-usage slow down a task?
I am using whisper.cpp to transcribe some sound files. It is a very CPU heavy process so I try to find some optimal settings and therefore I have done some tests with the thread setting (-t) but the ...
0
votes
0
answers
6
views
Optimising Job Submission on SMT4 Processors with OpenMP and MPI
I have been looking for information on this and I cannot find an example to match this setup.
Say we have a single node with two four-core SMT4 CPUs (32 logical cores), how can I optimise the ...
2
votes
1
answer
360
views
How does round-robin scheduling and context switching work from a low-level?
Using round-robin scheduling, the kernel provides time slices for different processes / tasks.
It seems that the kernel will initialize a timer, and when the timer times out, this will cause the ...
3
votes
1
answer
699
views
Does thread stack comes from the memory mapping segment of the process on Linux?
I'm currently studying Linux. I know the thread is a kind of lightweight process on Linux. But I wonder to know where the thread stack space comes from.
The stack of the thread is private. It is ...
1
vote
2
answers
380
views
Looking for a linux backup tool multithreaded with encryption and good compression algorithm
I am looking for a linux backup tool to upgrade my backup strategy.
Today I do full backups everyday on Linux server (Ubuntu 20.04).
I prefer to backup data directly inside our VMs and send to another ...
0
votes
1
answer
43
views
Is there an implementation of POSIX semaphore not based on Mutex+CV?
I read that semaphores in the FreeBSD kernel is not as efficient as Mutex+CV from this man page. I've examined the kernel and syscall implementation of POSIX semaphore from the source code and ...
1
vote
0
answers
51
views
Task takes 15 minutes with one processor and 20 minutes with two processors
This is the command, run at the root of an NTFS partition from a Debian 12 VM (VirtualBox)
$ (find . -type f -exec cat {} \;) | pv | wc -c
I was trying to check that all files are readable. It's a ...
0
votes
1
answer
247
views
Linux multiprocessors support
I am reading the following paper. In the paper, the authors argue that Unix/Linux "has struggled for a decade to support multiprocessors in a single node" in the last paragraph of the first ...
0
votes
1
answer
211
views
How can I create a dummy multi-threaded process and get its tids using common utilities?
I can make a dummy process that will hang forever and get its PID with:
bash -c 'echo $$; read'
I'd like a multi-threaded alternative to this one-liner which creates 2+ threads, prints the thread ids ...
1
vote
0
answers
413
views
File locking from different therads of the same process, including for Solaris OS
I need to perform a file lock when accessing a file from C/C++ code with the following requirements:
Blocking should be performed when access occurs not only from different processes, but also from ...
2
votes
1
answer
2k
views
How to run one command on several cores
I have a command which I want to run on all free cores to speed up the execution time. Specifically I am running the Pitman-Yor Adaptor-Grammar Sampler software I downloaded from here
./py-cfg/py-cfg-...
1
vote
1
answer
461
views
Understanding load average on multicore system with a multithreaded app
We have a curious situation regarding load average on our system. It's running an application called ZAG that is idle most of the day. But every 80 minutes or so, it has some sort of activity burst of ...
1
vote
2
answers
236
views
Spike in number of page faults with make -j`nproc`
I am running a benchmark to figure out the number of jobs I should allow GNU Make to use in order to have optimal compile time. To do so, I am compiling Glibc with make -j<N> with N an integer ...
4
votes
1
answer
3k
views
Understanding overhead cost of context switching
I've always read/heard that context switching is expensive. I recently started reading Robert Love's "Linux Kernel Development" and have made it through the Processes and Process Scheduling ...
1
vote
1
answer
558
views
Linux equivalent of Thread Director?
The 12th Generation Intel chips are rumoured to have "Efficient" and "Performance" cores. Apparently Microsoft's Thread Director, in Windows 11, takes advantage of them.
What will ...
0
votes
1
answer
960
views
Help understanding lsof and threads
When i use -p $PID on lsof i get only the immediate thread of the process. why and how to work with threads and lsof effectively?
sudo lsof -p 5344 > lsof-p5344.log
sudo lsof | grep '\<5344\>...
6
votes
1
answer
3k
views
Why do threads have their own PID?
I'm using htop and looking at a process (rg) which launched multiple threads to search for text in files, here's the tree view in htop:
PID Command
1019 |- rg 'search this'
1021 |- rg 'search ...
1
vote
1
answer
605
views
xz: OOM when compressing 1TB .tar
I'm trying to compress a large archive with multi-threading enabled, however, my system keeps freezing up and runs out of memory.
OS: Manjaro 21.1.0 Pahvo
Kernel: x86_64 Linux 5.13.1-3-MANJARO
...
3
votes
2
answers
2k
views
Simple BASH script to become a multi-process/'threaded' BASH script?
I have the following, working BASH script, which I run on a Mac Pro 2010/Mojarve OS:
#!/bin/bash
c=0
cnt=0
# count up wav files
cnt=$(find /hummdinger/LoCI/LoCI_orig/VO/WAV_Processed/ -name "*....
3
votes
3
answers
1k
views
How can I parallelize command sha256sum or other hashing commands?
I want to parallelize hash calculation process because I have a very large amount of file counts and sizes.
When I see CPU usage of these commands, I get upset because they are only using one thread; ...
1
vote
1
answer
151
views
FIFO number of processes, sustained growth
I have a FIFO question:
Why the fifo thread_num limit 2,
but number of processes, sustained growth when one process ends,
two processes start, and then got 3 processes.
sustained growth 2n-1
#!bin/...
2
votes
2
answers
2k
views
How to run a bash script using threads/parallel
I am running the following bash script as is. I.e. sequentially. Note that the prefetch and fastq-dump are calls for downloading files from a database, and _shrink is a C++ program that I have made to ...
0
votes
1
answer
826
views
Which thread receives SIGURG?
I recently wrote a "study note" about Unix, and I made following proposition about multi-threaded processes:
it will be almost impossible for the kernel to identify the thread that should ...
3
votes
3
answers
781
views
Boosting the grep search using GNU parallel
I am using the following grep script to output all the unmatched patterns:
grep -oFf patterns.txt large_strings.txt | grep -vFf - patterns.txt > unmatched_patterns.txt
patterns file contains the ...
2
votes
0
answers
229
views
JVM only uses 4 cores
I have a processor-intensive Java program and I want it to use all 8 available cores on the machine.
I've run taskset and it reports the mask to be:
pid 5897's current affinity mask: ff
But in top (...
0
votes
1
answer
457
views
How to switch from one process to another process and kill the first process
I have the following scenario, I have two programs running one in the background and one in front. The back program is doing some stuff for the front program. once the back program has done the ...
0
votes
1
answer
165
views
Bind 9 process of named is using one core cpu only
i Have a DNS server running on Debian os , the named process is taking 394% of cpu.
i noticed it is using one core of the 1 cores provided to the whole VM .
top - 17:29:04 up 105 days, 1:33, 1 user, ...
0
votes
1
answer
376
views
Schedule jobs from a queue onto multiple threads
I have a function that has to process all files in a set of directories (anything between 5-300 files). The number of parallel threads to be used is user-specified (usually 4). The idea is to start ...
2
votes
1
answer
356
views
All processes running on the same core
I found all processes on my machine to only run on a single core and their core affinity set to 0.
Here is a small python script which reproduces this for me:
import multiprocessing
import numpy as np
...
25
votes
3
answers
40k
views
How to use multi-threading for creating and extracting tar.xz
I use
tar -cJvf resultfile.tar.xz files_to_compress
to create tar.xz and
tar -xzvf resultfile.tar.xz
to extract the archive in current directory. How to use multi threading in both cases? I don't ...
-1
votes
1
answer
2k
views
How to find out on which core a thread is running on?
Let's say we have a CPU-intensive application called multi-threaded-application.out that is running on top of Ubuntu with a PID of 10000. It has 4 threads with tid 10001, 10002, 10003, and 10004. I ...
4
votes
2
answers
321
views
What are these threads named disk$0, disk$1, etc.?
I am using Ubuntu 20.04 LTS. The kernel version is 5.4.0-42.
Here is an example program:
// mre.c
// Compile with: cc -o mre mre.c -lSDL2
#include <stdio.h>
#include <SDL2/SDL.h>
int main(...
0
votes
1
answer
354
views
Does a process filling all logical cores have a negative impact on performance? [closed]
Because of hyper-threading, my CPU has 2 logical processors per core. If I understand the premise of hyper-threading correctly, it allows each core to have a separate cache and instruction pointer for ...
0
votes
2
answers
362
views
massive resource consumption during mkfs.ntfs on a zvol, why (and how can I limit this)?
On my machine mkfs.ntfs is slow and results in massive use of resources, preventing me from using the machine for anything else. According to top it (or rather directly related zvol processes) is ...
18
votes
4
answers
3k
views
Are basic POSIX utilities parallelized?
In a common Linux distribution, do utilities like rm, mv, ls, grep, wc, etc. run in parallel on their arguments?
In other words, if I grep a huge file on a 32-threaded CPU, will it go faster than on ...
0
votes
0
answers
723
views
IPSec multithreading via pcrypt worse than single thread
According to this document:
https://www.strongswan.org/docs/Steffen_Klassert_Parallelizing_IPsec.pdf parallelizing IPSec using pcrypt kernel module will make the connection much more efficient (graphs ...
1
vote
1
answer
517
views
Threads to process a million files [closed]
How many threads should be used to process a million files? How yould you justify your answer? This is a question from an OS exam from last year and I'm courious how you guys think. I think that 10....
1
vote
1
answer
519
views
In Solaris box how do we check if hyper-threading/multi-threading is enabled or not using command?
In Solaris, how we can find the status or check hyper-threading or multi-threading is enabled or not using commands?
1
vote
0
answers
366
views
macOSx / what is the kernel variable os_refcnt counting and what might be causing it to overflow?
Trying to figure out why running some software that I am developing causes my Mac to do a panic restart every 16 h or so always with an "os_refcnt" kernel variable overflow when running tcsh scripts.
...
25
votes
1
answer
4k
views
How to use "parallel" to speed up "sort" for big files fitting in RAM?
I have a 100 M line file that fits in RAM on a GNU/Linux system.
This is rather slow:
sort bigfile > bigfile.sorted
and does not use all 48 cores on my machine.
How do I sort that file fast?
0
votes
1
answer
141
views
Thread safe next number (or round-robin) service in linux
I have an Ubuntu machine and a scenario in which I need to generate the next number (starting from X) between 0 and 20 in a round-robin way.
I need a way to get the next number which will be thread ...
1
vote
0
answers
305
views
Using libhugetlbfs to transparently back up glibc malloc calls in a multi-threaded application
I'm trying to back up the memory allocations of a multi-threaded application with 1GiB hugepages using libhugetlbfs. However, only the main thread allocations are being assigned hugepages. If I ...
1
vote
1
answer
2k
views
What types of threads does Java/JVM use from Linux OS's perspective?
A developer friend of mine recently asked the question: On a Linux system when a Java application runs which has threads, how do these threads appear to the underlying Linux OS?
So what are Java ...
3
votes
1
answer
13k
views
Multithreaded xz, with gzip, pv, and pipes - is this the most efficient I can get?
I'm excited to learn that xz now supports multithreading:
xz --threads=0
But now I want to utilise this as much as possible. For example, to recompress gzips as xz:
gzip -d -k -c myfile.gz | pv | ...
3
votes
1
answer
1k
views
Why is this code exiting with return code 16?
I am trying my hands on clone() system call to create a Thread. However program is terminating itself as it return from t2_thread() function. Why is this behaviour? What am I missing?
#define ...