Sponsored Content
Operating Systems HP-UX how to see the threads count of a process in hp unix? Post 60569 by bugbugbug on Tuesday 18th of January 2005 10:41:49 PM
Old 01-18-2005
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
 

10 More Discussions You Might Find Interesting

1. Programming

Count Number Of Threads in a Process

I am trying to find out that how many number of threads are currently running or in any other state which is created by POSIX standard in a process. First I have defined a variable called proc_var of type proc defined in sys/proc.h.Next I open up the dir /proc and per directory wise I do an ioctl... (7 Replies)
Discussion started by: S.P.Prasad
7 Replies

2. UNIX for Advanced & Expert Users

Unix threads information

Hi, Can someone tell help me on how to know the threads statistics on a unix machine similar to memory statisitcs. I woule like to monitor the Number of threads per process and total number of threads that a system can accomodate. Thank you mrag (1 Reply)
Discussion started by: mrag74
1 Replies

3. 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

4. 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

5. Programming

Can SIGTERM to main process kill the detached threads?

Hi, I am stuck up with a strange problem. I am writing an application - a kinda tracker that reads data from memcache and invokes theads to process each record of the memcache. I dont want to join all my threads because my tracker should poll the cache in regular intervals say sum 300... (2 Replies)
Discussion started by: deepti_v25
2 Replies

6. 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

7. Programming

how can I get to know what threads run within process java.exe on windows

I am writing java application on windows. There are more than 100 threads run within java.exe. I want to know what threads run within process java.exe so that I can find out if there are abnormal java threads. (4 Replies)
Discussion started by: mika
4 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. UNIX for Advanced & Expert Users

How to kill a thread among several threads belongs to a process?

I would like to know is there any we can kill a single thread among multiple threads belongs to process? Since Signal action is process wise not per thread, i strongly feel that we can not or for that mater from external sources as well single thread can not be killed which is critical section... (2 Replies)
Discussion started by: murali242512
2 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
semaphore(3C)						   Standard C Library Functions 					     semaphore(3C)

NAME
semaphore, sema_init, sema_destroy, sema_wait, sema_trywait, sema_post - semaphores SYNOPSIS
cc [ flag... ] file... -lthread -lc [ library... ] #include <synch.h> int sema_init(sema_t *sp, unsigned int count, int type, void * arg); int sema_destroy(sema_t *sp); int sema_wait(sema_t *sp); int sema_trywait(sema_t *sp); int sema_post(sema_t *sp); DESCRIPTION
A semaphore is a non-negative integer count and is generally used to coordinate access to resources. The initial semaphore count is set to the number of free resources, then threads slowly increment and decrement the count as resources are added and removed. If the semaphore count drops to 0, which means no available resources, threads attempting to decrement the semaphore will block until the count is greater than 0. Semaphores can synchronize threads in this process and other processes if they are allocated in writable memory and shared among the coop- erating processes (see mmap(2)), and have been initialized for this purpose. Semaphores must be initialized before use; semaphores pointed to by sp to count are initialized by sema_init(). The type argument can assign several different types of behavior to a semaphore. No current type uses arg, although it may be used in the future. The type argument may be one of the following: USYNC_PROCESS The semaphore can synchronize threads in this process and other processes. Initializing the semaphore should be done by only one process. A semaphore initialized with this type must be allocated in memory shared between processes, either in Sys V shared memory (see shmop(2)), or in memory mapped to a file (see mmap(2)). It is illegal to initialize the object this way and not allocate it in such shared memory. arg is ignored. USYNC_THREAD The semaphore can synchronize threads only in this process. The arg argument is ignored. USYNC_THREAD does not support multiple mappings to the same logical synch object. If you need to mmap() a synch object to different locations within the same address space, then the synch object should be initialized as a shared object USYNC_PROCESS for Solaris threads and PTHREAD_PROCESS_PRIVATE for POSIX threads. A semaphore must not be simultaneously initialized by multiple threads, nor re-initialized while in use by other threads. Default semaphore initialization (intra-process): sema_t sp; int count = 1; sema_init(&sp, count, NULL, NULL); or sema_init(&sp, count, USYNC_THREAD, NULL); Customized semaphore initialization (inter-process): sema_t sp; int count = 1; sema_init(&sp, count, USYNC_PROCESS, NULL); The sema_destroy() function destroys any state related to the semaphore pointed to by sp. The semaphore storage space is not released. The sema_wait() function blocks the calling thread until the semaphore count pointed to by sp is greater than 0, and then it atomically decrements the count. The sema_trywait() function atomically decrements the semaphore count pointed to by sp, if the count is greater than 0; otherwise, it returns an error. The sema_post() function atomically increments the semaphore count pointed to by sp. If there are any threads blocked on the semaphore, one will be unblocked. The semaphore functionality described on this man page is for the Solaris threads implementation. For the POSIX-conforming semaphore interface documentation, see sem_close(3C), sem_destroy(3C), sem_getvalue(3C), sem_init(3C), sem_open(3C), sem_post(3C), sem_unlink(3C), and sem_wait(3C). RETURN VALUES
Upon successful completion, 0 is returned; otherwise, a non-zero value indicates an error. ERRORS
These functions will fail if: EINVAL The sp argument does not refer to a valid semaphore. EFAULT Either the sp or arg argument points to an illegal address. The sema_wait() function will fail if: EINTR The wait was interrupted by a signal or fork(). The sema_trywait() function will fail if: EBUSY The semaphore pointed to by sp has a 0 count. The sema_post() function will fail if: EOVERFLOW The semaphore value pointed to by sp exceeds SEM_VALUE_MAX. EXAMPLES
Example 1 The customer waiting-line in a bank is analogous to the synchronization scheme of a semaphore using sema_wait() and sema_try- wait(): /* cc [ flag ... ] file ... -lthread [ library ... ] */ #include <errno.h> #define TELLERS 10 sema_t tellers; /* semaphore */ int banking_hours(), deposit_withdrawal; void*customer(), do_business(), skip_banking_today(); ... sema_init(&tellers, TELLERS, USYNC_THREAD, NULL); /* 10 tellers available */ while(banking_hours()) pthread_create(NULL, NULL, customer, deposit_withdrawal); ... void * customer(int deposit_withdrawal) { int this_customer, in_a_hurry = 50; this_customer = rand() % 100; if (this_customer == in_a_hurry) { if (sema_trywait(&tellers) != 0) if (errno == EBUSY){ /* no teller available */ skip_banking_today(this_customer); return; } /* else go immediately to available teller and decrement tellers */ } else sema_wait(&tellers); /* wait for next teller, then proceed, and decrement tellers */ do_business(deposit_withdrawal); sema_post(&tellers); /* increment tellers; this_customer's teller is now available */ } ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |Async-Signal-Safe | +-----------------------------+-----------------------------+ SEE ALSO
mmap(2), shmop(2), sem_close(3C), sem_destroy(3C), sem_getvalue(3C), sem_init(3C), sem_open(3C), sem_post(3C), sem_unlink(3C), sem_wait(3C), attributes(5), standards(5) NOTES
These functions are also available by way of: #include <thread.h> By default, there is no defined order of unblocking for multiple threads waiting for a semaphore. SunOS 5.11 5 Feb 2008 semaphore(3C)
All times are GMT -4. The time now is 04:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy