[114] in Pthreads mailing list archive

home help back first fref pref prev next nref lref last post

Patches for pthreads-1.60 beta3

daemon@ATHENA.MIT.EDU (NIIBE Yutaka)
Wed Sep 6 22:59:38 1995

Date: Thu, 7 Sep 1995 11:48:53 +0900
From: NIIBE Yutaka <gniibe@mri.co.jp>
To: pthreads@MIT.EDU
In-Reply-To: <199509060344.MAA00784@megatherium.mri.co.jp>

Well, I modified my report.  I removed changes of fd.c, it's my
misunderstanding.  And I changed the patch of engine-i386-linux-1.0.c
so that it is compiled with old kernels.

Thank you.
-- 
NIIBE Yutaka

====================================== Start of REPORT ===============
(1) is deleted.

(2) pthread_sig_process() assumes that pthread_kernel is locked, but
acutually there are cases that it is called unlocked.  Here is fix.

--- pthreads/pthreads/signal.c.orig	Wed Jun 14 16:28:37 1995
+++ pthreads/pthreads/signal.c	Wed Sep  6 11:46:49 1995
@@ -454,7 +454,9 @@
 			sig_handler(0);
 		} else {
 			if (pthread_run && pthread_run->sigcount) {
+				pthread_kernel_lock++;
 				pthread_sig_process();
+				pthread_kernel_lock--;
 			}
 			break;
 		}
@@ -479,7 +481,9 @@
 			sig_handler(0);
 		} else {
 			if (pthread_run && pthread_run->sigcount) {
+				pthread_kernel_lock++;
 				pthread_sig_process();
+				pthread_kernel_lock--;
 			}
 			break;
 		}
@@ -498,7 +502,9 @@
 			sig_handler(0);
 		} else {
 			if (pthread_run && pthread_run->sigcount) {
+				pthread_kernel_lock++;
 				pthread_sig_process();
+				pthread_kernel_lock--;
 			}
 			break;
 		}


(3) PREVENT/RESUME mismatch

pthread_sched_prevent() and pthread_resched_resume()/pthread_sched_resume()
must be matched.  But there are some mismatches, here is fix.

--- pthreads/pthreads/cond.c.orig	Wed Jun 14 16:28:28 1995
+++ pthreads/pthreads/cond.c	Wed Sep  6 11:46:49 1995
@@ -173,6 +173,7 @@
 		pthread_mutex_lock(&pthread_cond_debug_mutex);
 		if (pthread_cond_is_debug(cond) == NOTOK) {
 			pthread_mutex_lock(&pthread_cond_debug_mutex);
+			pthread_sched_resume();
 			return(EINVAL);
 		}
 		pthread_mutex_lock(&pthread_cond_debug_mutex);
@@ -217,6 +218,7 @@
 		pthread_mutex_lock(&pthread_cond_debug_mutex);
 		if (pthread_cond_is_debug(cond) == NOTOK) {
 			pthread_mutex_lock(&pthread_cond_debug_mutex);
+			pthread_sched_resume();
 			return(EINVAL);
 		}
 		pthread_mutex_lock(&pthread_cond_debug_mutex);
@@ -273,6 +275,7 @@
 		pthread_mutex_lock(&pthread_cond_debug_mutex);
 		if (pthread_cond_is_debug(cond) == NOTOK) {
 			pthread_mutex_lock(&pthread_cond_debug_mutex);
+			pthread_sched_resume();
 			return(EINVAL);
 		}
 		pthread_mutex_lock(&pthread_cond_debug_mutex);
@@ -313,6 +316,7 @@
 		pthread_mutex_lock(&pthread_cond_debug_mutex);
 		if (pthread_cond_is_debug(cond) == NOTOK) {
 			pthread_mutex_lock(&pthread_cond_debug_mutex);
+			pthread_sched_resume();
 			return(EINVAL);
 		}
 		pthread_mutex_lock(&pthread_cond_debug_mutex);

--- pthreads/pthreads/schedparam.c.orig	Sun Apr  2 19:45:00 1995
+++ pthreads/pthreads/schedparam.c	Wed Sep  6 11:46:49 1995
@@ -124,6 +124,7 @@
 			} else {
 				pthread->attr.schedparam_policy = new_policy;
 				pthread->pthread_priority 		= prio;
+				pthread_sched_resume();
 			}
 			return(OK);
 			break;


(4) Select

(4-1) When timeout, it should not return error.
(4-2) When first machdep_sys_select returns >OK, it shouldn't set errno.

--- pthreads/pthreads/select.c.orig	Fri May 19 02:44:26 1995
+++ pthreads/pthreads/select.c	Wed Sep  6 12:04:01 1995
@@ -167,8 +167,12 @@
 				/* We're awake */
 				CLEAR_PF_DONE_EVENT(pthread_run);
 				if (sleep_cancel(pthread_run) == NOTOK) {
+#if 0
 					SET_ERRNO(ETIMEDOUT);
 					ret = -ETIMEDOUT;
+#else
+				       ret = OK;
+#endif
 				} else {
 					ret = data.nfds;
 				}
@@ -177,8 +181,9 @@
 				CLEAR_PF_DONE_EVENT(pthread_run);
 				ret = data.nfds; /* XXX ??? snl */
 			}
-		} else {
+		} else if (ret < 0) {
 			SET_ERRNO(-ret);
+			ret = NOTOK;
 		}
 	}

(5) Not implemented.
(5-1) As Alan Cox introduces sendmsg/recvmsg around Linux 1.3.20, 
      we now have those system calls.

--- pthreads/machdep/engine-i386-linux-1.0.c.orig	Tue May 30 23:39:40 1995
+++ pthreads/machdep/engine-i386-linux-1.0.c	Thu Sep  7 10:23:02 1995
@@ -390,7 +390,17 @@
  */
 int machdep_sys_sendmsg(int a, char * b, int c)
 {
+#ifdef SYS_SENDMSG
+	int array[3];
+
+	array[0] = (int)a;
+	array[1] = (int)b;
+	array[2] = (int)c;
+
+	return(machdep_sys_socketcall(SYS_SENDMSG, array));
+#else
 	return(-ENOSYS);
+#endif
 }
 
 /* ==========================================================================
@@ -436,7 +446,17 @@
  */
 int machdep_sys_recvmsg(int a, char * b, int c)
 {
+#ifdef SYS_RECVMSG
+	int array[3];
+
+	array[0] = (int)a;
+	array[1] = (int)b;
+	array[2] = (int)c;
+
+	return(machdep_sys_socketcall(SYS_RECVMSG, array));
+#else
 	return(-ENOSYS);
+#endif
 }
 
 /* ==========================================================================
====================================== END of REPORT =====================


home help back first fref pref prev next nref lref last post