PERFORCE change 100772 for review

Roman Divacky rdivacky at FreeBSD.org
Thu Jul 6 16:21:21 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=100772

Change 100772 by rdivacky at rdivacky_witten on 2006/07/06 16:20:54

	First attempt to fix the TID handling. Restructure the proc_init() thing
	to set pid in exec case and remove proces from emuldata list in proc_exit().

Affected files ...

.. //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux_machdep.c#9 edit

Differences ...

==== //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux_machdep.c#9 (text+ko) ====

@@ -1026,11 +1026,28 @@
 	struct proc *p;
 
 	/* XXX: locking? */
-	MALLOC(em, struct linux_emuldata *, sizeof *em, M_LINUX, M_WAITOK | M_ZERO);
+	if (child != 0) {
+	   	/* non-exec call */
+   		MALLOC(em, struct linux_emuldata *, sizeof *em, M_LINUX, M_WAITOK | M_ZERO);
+		em->pid = child;
+		SLIST_INSERT_HEAD(&emuldata_head, em, emuldatas);
+	} else {
+	   	found = 0;
+		/* lookup the old one */
+   	   	SLIST_FOREACH(em, &emuldata_head, emuldatas)
+   			if (em->pid == td->td_proc->p_pid) {
+		   		found = 1;
+				break;
+			}
+		if (found == 0) {
+		   	/* this should not happen */
+#ifdef DEBUG
+		   	printf("emuldata not found in exec case.\n");
+#endif
+			return (0);
+		}
+	}
 
-	/* exec call */
-	if (child != 0)
-	   	em->pid = child;
 	em->child_clear_tid = NULL;
 	em->child_set_tid = NULL;
 
@@ -1045,22 +1062,11 @@
 	if (found) {
    		em->clear_tid = p_em->clear_tid;
 		em->set_tid = p_em->set_tid;
-   	}
-
-	/* we have to free the old emuldata */
-	if (child == 0) {
-	   	found = 0;
-		/* lookup the old one */
-   	   	SLIST_FOREACH(p_em, &emuldata_head, emuldatas)
-   			if (em->pid == td->td_proc->p_pid) {
-		   		found = 1;
-				break;
-			}
-		if (found)
-   		   	FREE(em, M_LINUX);
+   	} else {
+	   	em->clear_tid = NULL;
+		em->set_tid = NULL;
 	}
 
-   	SLIST_INSERT_HEAD(&emuldata_head, em, emuldatas);
 
 	/* XXX: sched_lock locking? */
 
@@ -1095,6 +1101,8 @@
 		/* TODO: futexes stuff */
 	}
 
+	SLIST_REMOVE(&emuldata_head, em, linux_emuldata, emuldatas);
+
 	/* clean the stuff up */
 	FREE(em, M_LINUX);
 	


More information about the p4-projects mailing list