Re: [PATCH] make rwlocks SHAREABLE + cleanups

"Saurabh Desai" <[email protected]>
Newsgroups gmane.linux.ngpt.devel
Message-ID <[email protected]>

I have a question regarding the following changes in pth_mutex_release():

+    if (!mutex->mx_shared.pshared && mutex->mx_owner != current) return
EPERM;

Why this check is not needed for the pshared case? The mx_owner is always
set to
current in pth_mutex_acquire() for both normal and pshared mutexes.

Also,  if (!(mutex->mx_state & PTH_MUTEX_INITIALIZED)) return EINVAL;
is not needed, because the caller always check for valid mx_mutex.

Thanks,
- - - - -
Saurabh Desai
POSIX Threading for Linux
IBM  Linux Technology Center
e-mail: [email protected] OR [email protected]
phone: 512-838-2655, T/L: 678-2655
http://oss.software.ibm.com/developerworks/opensource/pthreads



[email protected]@www-124.southbury.usf.ibm.com on 08/29/2002 12:13:14 PM

Sent by:    [email protected]


To:    [email protected]
cc:
Subject:    [pthreads-devel] [PATCH] make rwlocks SHAREABLE + cleanups


a) I made a patch to support PROCESS_SHARED rwlocks.

b) while doing this I had to supply the patch in pth_sched.c and the
dopoll flag
             - therefore it's included:
@@ -840,7 +840,7 @@
                             this_occurred = FALSE;

                             /* Filedescriptor I/O */
-                            if (ev->ev_type == PTH_EVENT_FD && !dopoll &&
(ds == descr)) {
+                            if (ev->ev_type == PTH_EVENT_FD && (ds ==
descr)) {
                                     /* filedescriptors are checked later
all at once.
                                        Here we only assemble them in the
fd sets */
                                     if (ev->ev_goal &
PTH_UNTIL_FD_READABLE)
@@ -1035,7 +1035,7 @@
      FD_SET(descr->sigpipe[0], &rfds);

      /* If dopoll is set, handle the thread from ready queue... */
-    if (dopoll)
+    if (dopoll && m_to_n)
             return;


c) declaration pthread_kill_all_threads() removed from td_manager.c but
still
             does not compile when configuring --enable-thread_db

d) fixed a memory leak in pthread_cond_init()
-            rc = pth_cond_init(cn);
+            if (!(rc = pth_cond_init(cn)))
+                        pth_free(cn);

e) replaced EDEADLK with EPERM or EINVAL
             pthread_mutex_lock or pthread_rwlock_*lock should return
EDEADLK
             when the same thread already holds the lock (and it's not
recursive)

             the checking has to be improved on this (i.e. when pshared)
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.