Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Feb 2013 09:16:23 +0000 (UTC)
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r247186 - in user/dchagin/lemul/sys: kern sys
Message-ID:  <201302230916.r1N9GNAE035854@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dchagin
Date: Sat Feb 23 09:16:22 2013
New Revision: 247186
URL: http://svnweb.freebsd.org/changeset/base/247186

Log:
      In preparation for switching linuxulator to the use the native 1:1 threads
      add hook for cleaning thread resources before the thread die.

Modified:
  user/dchagin/lemul/sys/kern/kern_thread.c
  user/dchagin/lemul/sys/sys/sysent.h

Modified: user/dchagin/lemul/sys/kern/kern_thread.c
==============================================================================
--- user/dchagin/lemul/sys/kern/kern_thread.c	Sat Feb 23 09:14:28 2013	(r247185)
+++ user/dchagin/lemul/sys/kern/kern_thread.c	Sat Feb 23 09:16:22 2013	(r247186)
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/smp.h>
 #include <sys/sched.h>
 #include <sys/sleepqueue.h>
+#include <sys/sysent.h>
 #include <sys/selinfo.h>
 #include <sys/turnstile.h>
 #include <sys/ktr.h>
@@ -801,6 +802,12 @@ thread_suspend_check(int return_instead)
 		 */
 		if ((p->p_flag & P_SINGLE_EXIT) && (p->p_singlethread != td)) {
 			PROC_UNLOCK(p);
+			/*
+			 * Let thread to do cleanup work before die.
+			 */
+			if (__predict_false(p->p_sysent->sv_thread_detach != NULL))
+				(p->p_sysent->sv_thread_detach)(td);
+
 			tidhash_remove(td);
 			PROC_LOCK(p);
 			tdsigcleanup(td);

Modified: user/dchagin/lemul/sys/sys/sysent.h
==============================================================================
--- user/dchagin/lemul/sys/sys/sysent.h	Sat Feb 23 09:14:28 2013	(r247185)
+++ user/dchagin/lemul/sys/sys/sysent.h	Sat Feb 23 09:16:22 2013	(r247186)
@@ -130,6 +130,7 @@ struct sysentvec {
 	uint32_t	sv_timekeep_gen;
 	void		*sv_shared_page_obj;
 	void		(*sv_schedtail)(struct thread *);
+	void		(*sv_thread_detach)(struct thread *);
 };
 
 #define	SV_ILP32	0x000100



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201302230916.r1N9GNAE035854>