Monitoring The Execution Of POSIX Threads

I work on Red-Hat Enterprice OS.
I run one process which generates many POSIX threads.
How can I monitor/trace their execution.

Best regards,
Yehuda


Similar Content



Difference In Output When Using Pthread_join??

For the below code, I observe that when pthread_join is commented from the code - the order of thread execution is not consistent (the main thread executes first and then the remaining threads - in what sequence I am not sure). But when pthread_join is present in the code - I see that order of execution of the threads is as per the code (First t1, then t2 and finally main exits....I can tell that for sure by observing the increasing value of id in main())

Can anybody tell me why that happens?


#include <pthread.h>
#include <stdio.h>
pthread_once_t once = PTHREAD_ONCE_INIT;

void *myinit()
{
printf("\n I am in init\n");
}

void* t1routine(void* i)
{
printf("\n I am in thread%d\n", *(int*)i);
pthread_once(&once, (void*)myinit);
printf("\n I am exiting from thread %d\n", *(int*)i);
}

void* t2routine(void* i)
{
printf("\n I am in thread%d\n", *(int*)i);
pthread_once(&once, (void*)myinit);
printf("\n I am exiting from thread %d\n", *(int*)i);
}

void* t3routine(void* i)
{
printf("\n I am in thread%d\n", *(int*)i);
pthread_once(&once, (void*)myinit);
printf("\n I am exiting from thread %d\n", *(int*)i);
}

main()
{
int id = 1;
pthread_t t1,t2,t3;
pthread_create(&t1, NULL, t1routine, (void*) &id);
pthread_join(t1, NULL);
id++;

pthread_create(&t2, NULL, t2routine, (void*) &id);
pthread_join(t2, NULL);
id++;

pthread_create(&t3, NULL, t3routine, (void*) &id);
pthread_join(t3, NULL);
pthread_exit(NULL);
}

A Subroutine To Slow Down Calculation/execution In GFortran

Hi there. I need to slow execution of certain portions of my programs (GFortran) to demonstrate in "slow motion" interpolation between points on a graph. The SLEEP subroutine requires a default integer as an argument and thus appears to be too slow. I found one subroutine but it eats up 100% of CPU time. Thanks, - Alex

Process Vs Task Vs Threads

can anyone explain me the exact difference between process task and threads??
thanks in advance!!!

Watching / Capturing An Applications Threads

There is a home grown application that initiates either a telnet or ssh session based on the number of threads set.

I want to watch the process happen from start to finish, that is from the moment the first thread starts until the last thread finishes.

I was thinking netstat, but it wont show the process in its entirety. As connections are established and terminated the status / output of the command would be different..not to mention Id have to keep hitting the command and the enter key.

As usual, I have cracked my Linux in a nutshell book and will be doing web searches to find a solution.

User Permitted To Run Command,execute Program As Root And After Execution, Exit Root

when a command is typed(i.e. /path/to/the/program), as a normal user, he should be able to run that command , execute that program as ROOT and log out root after the execution is completed.
Only one user should be able to do it.
Hence, I have created a new user vj and added the following command in visudo:
Code:
vj ALL=(ALL) NOPASSWD: /path/to/the/program

Now user vj will be able to typein the command.

What I need is that the program which is been called must run as if it is run by a root user,and when the program is completely executed, exit the root user.

How do I proceed?

Monitoring Tomcat6 Access Log With Logwatch

I want to monitor tomcat access.log and catalina.out using logwatch.
There are many tutorials on how to implement new log file groups but I couldn't find any example for setting up a filter in /etc/logwatch/scripts/services/ for monitoring the tomcat logs.
Any help is appreciated.
Thanks.

Time Out For Linux Commands

I am calling lsof command in perl script,but due to node issue it's getting stucked .
Because of this script is unable to exit and finish execution. please help.

Reverse Nat Ssh Tunnel - Open More That One Port?

I will be setting up a few raspberry pi's in various locations, and they will be creating reverse nat ssh tunnels to my ssh server.

I need to set up a monitoring server at the server's location to monitor the raspberry pi's through the ssh server. The monitoring agent that will be installed on the raspberry pi's is communicating with the monitoring server on port 4700.

My question is:

Since I am using reverse nat ssh tunnels to connect on the ssh server, I am guessing that port 4700 will not be opened. If this is true, is there a way to also open port 4700 in that tunnel, so the monitoring server can access the remote agent?

Thanks

Kill Zombie Process Via C Program Without Killing Main Process

Hi ,
In my program, for a process A executing operation, there are multiple threads created.
One of the thread A checks whether process is active or not
Second thread B executes a function
One of the periodic thread C calls a callback function that executes an audit after every 30 secs.

In the audit , the function uses g_spawn_commmand_line_sync() function to spawn a child process that executes a command line (shell script).

Since g_spawn_commmand_line_sync() spawns a new child process .
In the error case scenario, the spawned child process got stuck and became zombie process. It did not get killed.Also it acquired sockets which were assigned to a thread B executing operation.

Even though the thread B got terminated ,the child process did not release the sockets that were connected to it.


My question is ,I have to automate this in C program that if it finds spawned process of g_spawn_commmand_line_sync() defunct, the
health check thread B should be able to clean it without klling the main process.

i could not find any spawn function that will help me find the PID of g_spawn_commmand_line_sync() spawned process.

I get the details from ps commands. But how can I find it in a c-program?

Difference Between Child THREAD And Child PROCESS

Hello,

I am troubleshooting something and I got this problem.

If I do "pstree -p"

It shows,

Code:
        ├─soffice.bin(7734)─┬─{soffice.bin}(7735)
        │                   ├─{soffice.bin}(7736)
        │                   ├─{soffice.bin}(7737)
        │                   └─{soffice.bin}(7743)

However, it does NOT show up in "ps -elf"

Code:
ps -elf | grep soffi
0 S whho      7734     1  0  80   0 - 36435 -      11:14 pts/2    00:00:03 /usr/lib/openoffice/program/soffice.bin -splash-pipe=5
0 S whho      7833  7759  0  80   0 -   751 -      11:21 pts/3    00:00:00 grep soffi

I was wondering if 7735, 7736, 7737, 7743 were really processes. Then I checked /proc, I could cd to /proc/7735, /proc/7736, etc, but I could not ls them out.

I looked at the man page of "pstree", it says,

Code:
Child threads  of a process are found under the parent process and are shown with the process name in curly braces, e.g.

           icecast2---13*[{icecast2}]

So, what does all this mean? Does it mean that 7735, 7736, 7737, 7743 are just threads but not processes? If so, why could I cd to /proc/<id> but not see them in "ps -elf".

Would somebody please help me?

Thanks!

whho