Sponsored Content
Full Discussion: Semaphore debugging
Top Forums Programming Semaphore debugging Post 302147262 by ptprabu on Monday 26th of November 2007 05:46:22 AM
Old 11-26-2007
Semaphore debugging

I'm running one multithreaded application, in that one of my thread
is waiting infinitely in a semphore. Is there a way to determine, in
which semaphore the particular thread is waiting and which thread(s)
is holding the semaphore.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

semaphore

hi, is there any command where we can monitor semaphores? (1 Reply)
Discussion started by: yls177
1 Replies

2. UNIX for Dummies Questions & Answers

Semaphore

Hi, I'm new to UNIX. I need to know what's a semaphore Do reply. Thanks VJ (3 Replies)
Discussion started by: vjsony
3 Replies

3. UNIX for Advanced & Expert Users

semaphore concept

Hi All, I am going through the semaphore concept and have a doubt regarding the same and hope to get a resolution here. I have a file which has a number of records. I want to write an application (in C) which will be able to do concurrent read/write on these records. Of what I have... (8 Replies)
Discussion started by: maverix
8 Replies

4. Shell Programming and Scripting

Semaphore

Hi, I am looking to use a semaphore for the first time in one of my scripts. I am just wondering if there are any simple examples or tutorials around? I am a beginner so the simpler the better :) Thanks -Jaken (2 Replies)
Discussion started by: Jaken
2 Replies

5. UNIX for Dummies Questions & Answers

semaphore

what is semaphore? can any body explain it in a more simple way than the manual ?? replies appreciated Regards raguram R (7 Replies)
Discussion started by: raguramtgr
7 Replies

6. Programming

Semaphore

In my server code there is a thread per client... The server call accept() and after that start the thread. So there is a thread for client that save in RAM the client's message, that will be send to other clients. Now in RAM I have created a shared memory in which thread read and write(save)... (2 Replies)
Discussion started by: italian_boy
2 Replies

7. Shell Programming and Scripting

semaphore

Control two exclusively shared resources(semaphore). The two resources are two files. The producer will write even numbers to one file, and odd numbers to another one. The consumer respectively reads from each file until it gets 5 even numbers and 5 odd numbers. Can any one help me with the... (0 Replies)
Discussion started by: gokult
0 Replies

8. Programming

Semaphore

If I create a semaphore and then I fork a number of child processes then all the child process use that same semaphore. Since the process address spaces are different rfom each other then how all the child process are able to access the same semaphore? I understand that semaphore/mutex is at os... (0 Replies)
Discussion started by: rupeshkp728
0 Replies

9. Solaris

Semaphore

Can anyone tell me abt the Semaphore concept and what is semaphore??? is semaphore id is associated in terms as in resources like semaphore id 1 indicates cpu share unit is given and semaphore id 2 will indicate abt the memore or semaphore id 3 will tell us the i/o components (1 Reply)
Discussion started by: aarjun07
1 Replies

10. UNIX for Beginners Questions & Answers

Semaphore

I was asked to add this piece of code to a c program which I will execute through the shell: for(long i = 0; i < NITER; i++) { sem_wait( &sema); count++; sem_post( &sema); } I didn't get it, which is the critical section ? if it's "count++" how would a thread wake up in order to enter it... (1 Reply)
Discussion started by: uniran
1 Replies
semaphore(9F)						   Kernel Functions for Drivers 					     semaphore(9F)

NAME
semaphore, sema_init, sema_destroy, sema_p, sema_p_sig, sema_v, sema_tryp - semaphore functions SYNOPSIS
#include <sys/ksynch.h> void sema_init(ksema_t *sp, uint_t val, char *name, ksema_type_t type, void *arg); void sema_destroy(ksema_t *sp); void sema_p(ksema_t *sp); void sema_v(ksema_t *sp); int sema_p_sig(ksema_t *sp); int sema_tryp(ksema_t *sp); INTERFACE LEVEL
Solaris DDI specific (Solaris DDI). PARAMETERS
sp A pointer to a semaphore, type ksema_t. val Initial value for semaphore. name Descriptive string. This is obsolete and should be NULL. (Non-NULL strings are legal, but they are a waste of kernel mem- ory.) type Variant type of the semaphore. Currently, only SEMA_DRIVER is supported. arg Type-specific argument; should be NULL. DESCRIPTION
These functions implement counting semaphores as described by Dijkstra. A semaphore has a value which is atomically decremented by sema_p() and atomically incremented by sema_v(). The value must always be greater than or equal to zero. If sema_p() is called and the value is zero, the calling thread is blocked until another thread performs a sema_v() operation on the semaphore. Semaphores are initialized by calling sema_init(). The argument, val, gives the initial value for the semaphore. The semaphore storage is provided by the caller but more may be dynamically allocated, if necessary, by sema_init(). For this reason, sema_destroy() should be called before deallocating the storage containing the semaphore. sema_p_sig() decrements the semaphore, as does sema_p(). However, if the semaphore value is zero, sema_p_sig() will return without decre- menting the value if a signal (that is, from kill(2)) is pending for the thread. sema_tryp() will decrement the semaphore value only if it is greater than zero, and will not block. RETURN VALUES
0 sema_tryp() could not decrement the semaphore value because it was zero. 1 sema_p_sig() was not able to decrement the semaphore value and detected a pending signal. CONTEXT
These functions can be called from user or interrupt context, except for sema_init() and sema_destroy(), which can be called from user context only. None of these functions can be called from a high-level interrupt context. In most cases, sema_v() and sema_p() should not be called from any interrupt context. If sema_p() is used from interrupt context, lower-priority interrupts will not be serviced during the wait. This means that if the thread that will eventually perform the sema_v() becomes blocked on anything that requires the lower-priority interrupt, the system will hang. For example, the thread that will perform the sema_v() may need to first allocate memory. This memory allocation may require waiting for paging I/O to complete, which may require a lower-priority disk or network interrupt to be serviced. In general, situations like this are hard to predict, so it is advisable to avoid waiting on semaphores or condition variables in an interrupt context. SEE ALSO
kill(2), condvar(9F), mutex(9F) Writing Device Drivers SunOS 5.10 7 May 1997 semaphore(9F)
All times are GMT -4. The time now is 12:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy