RE: Do PTHREAD_PROCESS_SHARED mutexes/condvars w ork?

"Howell, David P" <[email protected]>
Newsgroups gmane.linux.ngpt.devel
Message-ID <[email protected]>
This change is already in the impending ngpt-2.2.0 that will be released
very soon.

 

Dave Howell

 

-----Original Message-----
From: Chris McFarlen [mailto:[email protected]] 
Sent: Friday, December 27, 2002 4:14 PM
To: '[email protected]'
Subject: RE: [pthreads-devel] Do PTHREAD_PROCESS_SHARED mutexes/condvars
w ork?

 

Well, I get to respond to my own question, but you guys can tell me if
this is right.  This patch fixes the problem:

 

diff -Eu -x '*\.o' ngpt-2.0.4/pth_sync.c ngpt-2.0.4-my/pth_sync.c
--- ngpt-2.0.4/pth_sync.c 2002-11-19 12:03:54.000000000 -0600
+++ ngpt-2.0.4-my/pth_sync.c 2002-12-27 14:55:36.000000000 -0600
@@ -408,7 +408,9 @@
 
 wait:
     /* already locked by caller? */
-    if (mutex->mx_owner == current && mutex->mx_count >= 1) {
+    if (mutex->mx_owner == current && 
+        mutex->mx_owner_pid == descr->pid &&
+        mutex->mx_count >= 1) {
  if (mutex->mx_type == PTH_MUTEX_RECURSIVE_NP) {
      /* recursive lock */
             mutex->mx_count++;

Chris McFarlen

T-NETIX, Inc.

	-----Original Message-----
	From: Chris McFarlen 
	Sent: Friday, December 27, 2002 2:58 PM
	To: '[email protected]'
	Subject: [pthreads-devel] Do PTHREAD_PROCESS_SHARED
mutexes/condvars work?

	I need to do some process syncronization, but the
PTHREAD_PROCESS_SHARED attribute does not seem to work. I am using NGPT
2.0.4, and I have tried a stock 2.4.19 with the futex patch, and a
2.5.43 development kernel.  Both kernel versions have the same results.
I have some test code that yields the error, and I have made one
modification to test_str03.c that also shows the error.  

	The error comes from pthread_mutex_lock() when the mutex is
locked by another process (the mutex data is shared via shared memory,
and initialized with an attribute that has PTHREAD_PROCESS_SHARED set).
The error is EDEADLK.

	I can post the test code I have and the change to get test_str03
to fail, if there is interest in helping out.  But I wanted to make sure
that NGPT tries to support PTHREAD_PROCESS_SHARED before I posted all of
that.  The documentation seems to say that NGPT does and does not
support PTHREAD_PROCESS_SHARED in different places(there is a test for
the case, test_str03, but you have to supply a -s parameter, and then
that really doesn't work anyway...).

	Thanks, 
	Chris McFarlen 
	T-NETIX, Inc.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.