2022 Developer Survey is open! Take survey.

Questions tagged [thread]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
64 views

How does a spinlock prevents context switching?

I am using this code in order to visualize how a spinlock would prevent context switching: pthread_spinlock_t lock; void pp() { pthread_spin_lock(&lock); char d = 'D'; ...
user avatar
  • 27
0 votes
2 answers
72 views

if a device driver is called multiple times, does the kernel create multiple processes?

what happens if a device driver is called open("/dev/mydrievr") multiple times by multiple programs? is a process created for each call? is it possible to instantiate a thread instead of a ...
user avatar
  • 529
0 votes
0 answers
20 views

user and kernel threads mapping

In this link in the many to many model , it states that : The user thread programming facilities are shared between the threads library and the kernel threads. What does this exactly mean?
user avatar
  • 87
0 votes
1 answer
43 views

What starts threads in Linux OS?

I am currently investigate a question related to threads in the Linux OS. I know that processes are started by the scheduler in Linux Kernel, but what starts threads inside a process - Linux Kernel ...
user avatar
0 votes
0 answers
44 views

Is it possible to get each thread's `comm` from a core dump with gdb?

I wrote a C program that uses multiple threads. For convenience I set the threads comm to some individual value for each thread, and that even might change depending on the state of the thread (a bit ...
user avatar
  • 801
1 vote
1 answer
148 views

top shows different pid for threads of same process. How to fix it?

when i do a ps -efT (where -T = Show threads, possibly with SPID column.), i see all the threads have the same PID, which is as expected. myroot 24958 24958 7942 0 20:20 pts/12 00:00:00 java -...
user avatar
  • 554
1 vote
0 answers
30 views

does pthread_setschedparam can change the priority on the fly once the thread is running? how can I change the thread priority for a running thread

I want to change a thread priority and I have found many examples using pthread_setschedparam, but I need to confirm if the priority can be changed on the fly if the thread is already running. In the ...
user avatar
0 votes
1 answer
651 views

How do I do "ps" command on a thread?

The ps command can be done in terminal to view information about a process. For example, #list processes ps aux #with executable paths ps -ef #path for a specific process ps -p [pid] However, if a ...
user avatar
0 votes
1 answer
176 views

Process I\O vs CPU bound?

I saw this question online preparing for a job interview: Given a Non-Preemptive kernel which type of process will get effected more in terms of performance and why? I\O bound CPU bound I know ...
user avatar
  • 1
1 vote
0 answers
250 views

htop not showing threads of processes on Mac

I am running a java program from inside IntelliJ IDEA (an IDE) on a Mac. The program spawns 2 threads. I have installed htop and I am trying to see the process along with the spawned threads (they are ...
user avatar
  • 1,195
0 votes
1 answer
94 views

thread profiling and monitoring

how can I get lock time values specifically of the threads of any process? in linux.. I was using the command /proc/pid/stat but I am unable to determine which values are of lock time.
user avatar
0 votes
1 answer
254 views

How to solve All threads core not showing

I want ask issue regarding the number of cpu threads that can be read from the os. This question is how to resolve core not showing and not ask how to check core threads. Server spec Hpe dl360p gen8 ...
user avatar
  • 1
0 votes
2 answers
42 views

Will "$!" reliably return the correct ID with "&"?

In my tests, I always get the correct result so far with this: [fabian@manjaro ~]$ sleep 10 & echo $! [1] 302657 302657 But sleep and echo are getting executed simultaneously here, so I would ...
user avatar
-1 votes
1 answer
692 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 ...
user avatar
-1 votes
1 answer
262 views

How to get number of threads/tasks per core in Linux?

As you may know, in Linux, each CPU core has its own run queue. How can I get the number of threads currently running on each core in Linux (Ubuntu)?
user avatar
1 vote
2 answers
824 views

Is it possible for a kernel space thread or process to be child of a userspace process?

I am kind of a newbie when it comes to the Linux Kernel, but I was reading this article about fibrils where it mentions that they are (or were? not sure if they were ultimately kept in the Kernel) ...
user avatar
  • 165
0 votes
1 answer
177 views

Could thread be counted as a CPU? [duplicate]

So I typed in lscpu into my terminal and saw this: CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 2 Core(s) per socket: 2 Socket(s): 1 The no. of CPU(s) is 4 here ...
user avatar
  • 1
9 votes
3 answers
481 views

Should I attempt to 'balance' my threads or does linux do this?

A simple example. I'm running a process that serves http request using TCP sockets. It might A) calculate something which means CPU will be the bottleneck B) Send a large file which may cause the ...
user avatar
0 votes
1 answer
155 views

Process VS Thread in commands Which runs first?

I am wondering which would run or be created first on Linux if I were to run a command which uses both a process and a thread. I know they both use clone() to run and by definition a thread is ...
user avatar
1 vote
1 answer
357 views

Are there any tools to view a process' thread control blocks?

Process Control Blocks expose the /proc file system which allows PCBs to be read by users. Is there a similar file system for Thread Control Blocks? If not, is there a tool to read their contents (...
user avatar
1 vote
2 answers
827 views

Naming convention of worker threads

I started reading about worker threads. Old Legacy worker threads is replaced with worker pools. $ ps -ef | grep 'kworker' root 6 2 0 04:41 ? 00:00:00 [kworker/0:0H-kb] root ...
user avatar
  • 261
1 vote
1 answer
552 views

What data structure is the stack using in Linux?

I have looked in several places such as here but none explain in detail the structs used for implementing the stack itself (the place where "tasks" (processes/threads) store their nested call ...
user avatar
  • 385
-3 votes
1 answer
463 views

Reasons that may cause a running process to voluntarily or involuntarily give-up the CPU?

What are the reasons that may cause a running process to voluntarily or involuntarily give-up the CPU? As only one process can be running in the CPU/Core at any one time.
user avatar
  • 3
0 votes
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 ...
user avatar
  • 344k
2 votes
1 answer
208 views

How do I display the thread / child process count of a process in top?

I know there is a one-line-per-thread view (-H), but the particular threads are not grouped by master process. In fact, I would be completely satisfied with the sole thread count per process (= how ...
user avatar
  • 315
2 votes
0 answers
119 views

Read per thread network statistics from C/C++

I have a Linux process with let's say 10 threads. Some of them make network traffic. From another thread or it can be even within another process I need to find out which threads have network activity....
user avatar
  • 41
0 votes
1 answer
95 views

Why does gunicorn w/ workers as a daemon kill MySQL?

So, I've recently deployed my first Flask app with gunicorn. During deployment, I encountered the most peculiar issue. I had created a systemd unit file (the following is the working, functional ...
user avatar
  • 1
1 vote
0 answers
30 views

Deterministic thread cancelation

Is there a way to deterministicly cancel threads (Light-weight process) in linux. Let say I want to cancel a thread because it is possible in an infinite loop or my scheduler requires it. How would ...
user avatar
0 votes
1 answer
545 views

Information on values in /proc/pid/task/tid/sched

can someone help me out with the meanings of the following terms in the output of /proc/pid/task/tid/sched? avg_per_cpu se.avg.util.sum se.avg.load.sum ravg.demand Do any of these values point to ...
user avatar
1 vote
0 answers
32 views

How to find the number of threads in a OpenVZ containers

A am running a Spark application, it is possible to specify some parameters like the number of threads. My question : how I can find the number of threads in my container OpenVZ. Some details : $...
user avatar
0 votes
0 answers
528 views

Can two threads in the same process belong to different namespaces?

The task_struct structure has an entry nsproxy which points to namespaces associated with the task_struct. My understanding is that task_struct can be used to represent both process and threads in ...
user avatar
  • 1,263
2 votes
2 answers
5k views

How can I list information about a thread/LWP by `ps`?

How can I list information about a thread/LWP by ps? Why can't I do that simply by: $ ps 10173 PID TTY STAT TIME COMMAND $ ps -L 10173 PID LWP TTY STAT TIME COMMAND The best I ...
user avatar
  • 89.8k
2 votes
1 answer
153 views

Look up a string in a log to set an alert and generate thread dumps

I need to write a script to create and alert and get thread dumps if a string (Related string is found) in a log file - /tmp/area.log. I am able to do this in 2 separate scripts so far but would like ...
user avatar
  • 33
2 votes
1 answer
2k views

How to set the SCHED_RR time slice or time quantum per process / thread?

The time slice (also called time quantum) for threads with SCHED_RR policy can, according to the sched_rr_get_interval man page be obtained using int sched_rr_get_interval(pid_t pid, struct timespec *...
user avatar
1 vote
0 answers
274 views

Is it possible to create a thread without sharing memory space?

The http://www.man7.org/linux/man-pages/man2/clone.2.html write Since Linux 2.5.35, flags must also include CLONE_SIGHAND if CLONE_THREAD is specified (and note that, since Linux 2.6.0-test6, ...
user avatar
1 vote
1 answer
247 views

Distribution of threads among CPUs?

lscpu gives: Thread(s) per core: 2 Core(s) per socket: 32 When running an intensive 32-threads process, why does htop show almost 100% CPU activity on #1-32, but very little activity on #33-64? ...
user avatar
  • 1,072
4 votes
1 answer
380 views

Is there a file that associates a thread to its network namespace?

/proc/[pid]/ns/net contains a link to the inode representing the network namespace of the process with PID [pid]. Is there something similar for threads? My use case is a multi-threaded application, ...
user avatar
  • 59
0 votes
1 answer
639 views

SLES 11 SP4 'Resource temporarily unavailable' after upgrade from SP3

After upgrade from SLES 11 sp3 to sp4 I've met the problem while creating threads. Message I got was 'Resource temporarily unavailable'. Is it possible that upgrade changed limits somehow or maybe ...
user avatar
3 votes
2 answers
2k views

Are tgid and pid ever different for a process or lightweight process?

tgid and pid are the same concept for any process or for any lightweight process. In /proc/${pid}/status, tgid and pid are distinct fields. Are tgid and pid ever different for a process or ...
user avatar
  • 89.8k
5 votes
2 answers
2k views

Does Linux not distinguish between processes and threads?

As far as I know in Linux kernel, the structure task_struct represents threads i.e. light weight processes, but not processes. processes are not represented by any structure, but by groups of ...
user avatar
  • 89.8k
4 votes
1 answer
2k views

Are tid and tgid always the same as pid in the output of ps?

In manpage of ps tid TID the unique number representing a dispatchable entity (alias lwp, spid). This value may also appear as: a ...
user avatar
  • 89.8k
0 votes
2 answers
2k views

thread dump of Java using Kill -3

I used to take thread dumps using: kill -3 `pidof java` This will create thread dumps in catalina.out ; how to get those output to a file rather than in catalina.out. Usually kill command won't ...
user avatar
0 votes
1 answer
103 views

Does software threads include user threads?

From this answer - software threads vs hardware threads, software threads are threads managed by OS. But I also learn another term called user threads, which are threads that's not kernel threads, i.e....
user avatar
  • 254
2 votes
1 answer
246 views

OpenBSD threads priorities

Can anybody explain how to work with thread priorities in OpenBSD? Information about this question in MAN pages is poor, it does not give clear understanding. In particular: sched_get_priority_min/...
user avatar
14 votes
1 answer
7k views

What are the relations between processes, kernel threads, lightweight processes and user threads in Unix? [closed]

Unix Internal by Vahalia have figures showing the relations between processes, kernel threads, lightweight processes, and user threads. This book gives most attention to SVR4.2, and it also explores ...
user avatar
  • 89.8k
1 vote
1 answer
1k views

Is a light weight process attached to a kernel thread in Linux?

Based on my understanding from Understanding the Linux Kernel, is it correct that: kernel threads and light weight processes in Linux kernel are both represented by task_struct structure in C. ...
user avatar
  • 89.8k
0 votes
1 answer
184 views

Error message "jrcmd: not found" when I execute a script

I am getting the error below when I execute a script: Ksh: line 1: jrcmd: not found When I execute the same command in weblogic server, I get the output, but executing the same command inside a ...
user avatar
3 votes
2 answers
259 views

Run process as if on a single-core machine to find a bug

I have a bug in my Linux app that is reproducable only on single-core CPUs. To debug it, I want to start the process from the command line so that it is limited to 1 CPU even on my multi-processor ...
user avatar
  • 418
0 votes
1 answer
547 views

What is contention? [closed]

I have been asked to measure the contention of locks a write process is causing. I was looking at the data of the lockstat for that write process. My questions are below: Is contention related to ...
user avatar
  • 47
1 vote
3 answers
2k views

How does the kernel knows which "threads"/processes are associated with a process? [duplicate]

As I have read, a "thread" in Linux is just a process. Say that a process created two "threads", now when the process is terminated, the two "threads"/processes that are associated with the process ...
user avatar