Sponsored Content
Top Forums Programming Count Number Of Threads in a Process Post 33183 by S.P.Prasad on Wednesday 18th of December 2002 11:59:42 PM
Old 12-19-2002
We are working on SunOS Rel 5.8.Infact I have worked on the method - counting the number of subdirectories in the /proc/[pid]/lwp by using the following algorithm :

.......
/* After I have found the pid of the required process */
sprintf ( Dir , "/proc/%d/lwp" , pid ) ;
if ( ! chdir ( Dir ) ) {
Counter = 0 ;
if ((dp = opendir ( Dir ))!= NULL) {
while((dirp=readdir(dp))!=NULL)
if(dirp->d_name[0]!='.') Counter ++ ;
}
}
.......
I get the right count of subdirectories in the variable Counter. But the threads created in the program does not matches in number to subdirectories in /proc/[pid]/lwp. For example in an application I have created two thread by using pthread_create but number of subdirectories created in lwp directory for that process is five.I am not able to figure it as to why this difference exists.
 

10 More Discussions You Might Find Interesting

1. HP-UX

how to see the threads count of a process in hp unix?

hi,all: how to see the threads count of a process in hp unix? thanks (2 Replies)
Discussion started by: bugbugbug
2 Replies

2. Linux

Maximum number of threads handled by a process????

Hi Anybody knows max. no. of threads handled by a process in linux. Please reply Thanks in advnce :confused: (0 Replies)
Discussion started by: Agnello
0 Replies

3. UNIX for Advanced & Expert Users

Threads and Threads Count ?

Hi all, How can I get the list of all Threads and the Total count of threads under a particular process ? Do suggest !! Awaiting for the replies !! Thanks Varun:b: (2 Replies)
Discussion started by: varungupta
2 Replies

4. HP-UX

Need help. Unable to create threads after a certain number

Hi, I have a process which creates pthreads to generate some reports. After creating the reports these threads return null. But after 1024 threads, the process is not able to create any threads further.,and at max 5 threads are existing simultaneously and are returning the control back after... (2 Replies)
Discussion started by: Krsh
2 Replies

5. UNIX for Advanced & Expert Users

threads per process

What are the maximum number of threads possible per Process? Is it OS dependent? (1 Reply)
Discussion started by: digdarshan
1 Replies

6. Solaris

Number of threads running

Is there any command to find 1) the number of threads running 2) kernel boot mode in solaris box (2 Replies)
Discussion started by: vickylife
2 Replies

7. Shell Programming and Scripting

how to add the number of row and count number of rows

Hi experts a have a very large file and I need to add two columns: the first one numbering the incidence of records and the another with the total count The input file: 21 2341 A 21 2341 A 21 2341 A 21 2341 C 21 2341 C 21 2341 C 21 2341 C 21 4567 A 21 4567 A 21 4567 C ... (6 Replies)
Discussion started by: juelillo
6 Replies

8. AIX

How to list all threads in a running process

Hello, On Linux, I can use 'ps -efL | grep process_name' to list all threads that belong to a running process. -L has a different meaning on AIX and I could not find an equivalent flag in the man pages. Does anyone know of a way to dump the threads under a running process? Thanks,... (2 Replies)
Discussion started by: makodarear
2 Replies

9. SuSE

Configuring Number Threads

I have this error message from the logs of Zimbra email running on SUSE 11.2 Is the thread maximum of 20 an operating system parameter, or is it part of the application code, or part of the java run time? Part two, how would I increase that number? (3 Replies)
Discussion started by: jgt
3 Replies

10. HP-UX

How to get number of threads for single java process on HP-UX OS?

Hi All, When i was trying to get total number of threads per java process using this command ps -o NLWP PID, I'm not getting any output. Could someone help me in this issue. Thanks, GMar (1 Reply)
Discussion started by: mgangumolu
1 Replies
_LWP_UNPARK(2)						      BSD System Calls Manual						    _LWP_UNPARK(2)

NAME
_lwp_unpark -- resume execution of a waiting LWP LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <lwp.h> int _lwp_unpark(lwpid_t lwp, const void *hint); DESCRIPTION
_lwp_unpark() resumes execution of the light-weight process lwp. The target LWP is assumed to be waiting in the kernel as a result of a call to _lwp_park(). If the target LWP is not currently waiting, it will return immediately upon the next call to _lwp_park(). See _lwp_park(2) for a description of the hint argument. RETURN VALUES
A 0 value indicates that the call succeeded. A -1 return value indicates an error occurred and errno is set to indicate the reason. ERRORS
[ESRCH] No LWP can be found in the current process corresponding to that specified by lwp. SEE ALSO
_lwp_park(2), _lwp_unpark_all(2), _lwp_wakeup(2) HISTORY
The _lwp_unpark() system call first appeared in NetBSD 5.0. BSD
January 20, 2007 BSD
All times are GMT -4. The time now is 07:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy