![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| semaphore | raguramtgr | UNIX for Dummies Questions & Answers | 7 | 06-15-2009 09:39 AM |
| Semaphore | Jaken | Shell Programming and Scripting | 2 | 04-04-2009 05:10 PM |
| Debugging the JVM Using dbx | iBot | UNIX and Linux RSS News | 0 | 03-06-2008 07:20 PM |
| Semaphore | vjsony | UNIX for Dummies Questions & Answers | 3 | 04-07-2003 02:06 PM |
| semaphore | yls177 | UNIX for Dummies Questions & Answers | 1 | 10-08-2002 11:18 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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. |
|
||||
|
If you have a decent thread aware debugger you could check the stack of each thread to see who was blocked on a pthread_mutex_lock, then depending on the operating system and implementation of pthreads on that OS you may be able to find the thread id in the "pthread_mutex_t" structure.
Personally I solve this by using my own version of a pthreads library which lets me add additional tracing and warning of potential deadlocks. |
|
||||
|
Porter,
In my application semaphores, are not created using any threading library. Semaphores (counting) are created using sema_init. Is there any system calls or functions available to get the semaphores a thread is currently having? |
|
||||
|
Quote:
Do these semaphores have to work between processes? What platform are you using? Post results of "uname -a". |
|
||||
|
If you are doing synchronisation between threads of the same process then I recommend using pthread APIs to do this. The sem APIs always involve the kernel, but the pthread APIs may be able to avoid kernel involvement for some activities.
An up/down semaphore should be able to be constructed using a pthread_mutex_t and pthread_cond_t pair. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| linux |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|