Do you want to know how many threads a process is allowed to create?
If that's the case then on AIX sysconf(_SC_THREAD_THREADS_MAX) will tell you the max number of threads allowed within a process.
I think the OP wants to now how many threads an application has created, not the maximiun possible.
It is generally possible to determine the number of threads from within a C program. However, how it is done is very OS-specific. If you tell us your platform and OS version, somebody here on this forum should be able to help you.
Do you want to know how many threads a process is allowed to create?
If that's the case then on AIX sysconf(_SC_THREAD_THREADS_MAX) will tell you the max number of threads allowed within a process.
Thats not what I am looking for. I have written a C program that spawns posix threads using pthread_create. I want to programmatically get the no. of threads spawned by the program at some instance of time in the program. There is no function in pthread.h that does this. So I was wondering if there is a way to do it.
Quote:
Originally Posted by fpmurphy
If you tell us your platform and OS version, somebody here on this forum should be able to help you.
I am running my program on a Linux box that runs OpenSUSE 11.
In that case it only depends on how you go about creating threads within your C program especially if threads create other threads using nested function calls.
If you call pthread_create in a master thread or main program it is easy. This sit eh total numbers of threads created, not currently active threads
If "everybody" creates a thread, then you need to create a static mutex then a static integer variable in shared memory, initialize it to zero. Everybody calling pthread_create does this:
pthreads have these basic calls (plus a lot of others)
that lets you play with mutexes. You will have to pass the mutex address to all of your threads or they cannot use it.
I have a need to run any number of identical scripts simultaneously, so I've created a driver script which reads a template script, edits these appropriately and then submits them via nohup. The spawned scripts all check to see at some point how many of their number are running and once the count... (7 Replies)
Hi Guys,
I'm completely new to bash and trying to write a script to spawn a telnet session to retrieve the RSSI value of my device and log the average value of the RSSI over 20 samples. I know that my command does return the RSSI value successfully but my bash scripting is letting me down.
I'm... (5 Replies)
So this one just plain confuses me. I have a bunch of somewhat CPU intensive processes that all communicate using a shared memory region. Some of these programs are threaded and some also change the scheduling to FIFO or round robin. The good news is that everything works as long as I spawn... (3 Replies)
Hi All
I'm currently trying to develop a script which will find the child processes of a process ID already passed to the script.
I then need the script to look for spawned processes of these child processes and so on until it can't find any more.
For example
At the moment, I have to... (6 Replies)
Hi,
I'm trying to spawn a telnet process and trying to do some actions in the remote host using expect script. I would like to know how to suppress all the output in order the user using the script should not be able to see any actions done on the remote host. I tried using the "log_user 0"... (8 Replies)
Hi,
I have a situation where I am writing a programme that runs a series of long running PHP scripts that can take anything from 20 minutes to 10 hours to execute.
I have a solution half implemented where I use via php exec(wget <location to command>) and get the process id back.
This... (1 Reply)