patch-1.3.94 linux/kernel/exit.c

Next file: linux/kernel/fork.c
Previous file: linux/init/main.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.93/linux/kernel/exit.c linux/kernel/exit.c
@@ -17,6 +17,8 @@
 #include <linux/malloc.h>
 
 #include <asm/segment.h>
+#include <asm/pgtable.h>
+
 extern void sem_exit (void);
 extern void acct_process (long exitcode);
 extern void kerneld_exit(void);
@@ -423,21 +425,26 @@
 
 void exit_sighand(struct task_struct *tsk)
 {
-  __exit_sighand(tsk);
+	__exit_sighand(tsk);
 }
 
 static inline void exit_mm(void)
 {
 	struct mm_struct * mm = current->mm;
 
+	/* Set us up to use the kernel mm state */
+	flush_cache_mm(mm);
+	flush_tlb_mm(mm);
+	init_mm.count++;
+	current->mm = &init_mm;
 	current->swappable = 0;
-	if (mm) {
-		if (!--mm->count) {
-			exit_mmap(mm);
-			free_page_tables(current);
-			kfree(mm);
-		}
-		current->mm = NULL;
+	SET_PAGE_DIR(current, swapper_pg_dir);
+
+	/* free the old state - not used any more */
+	if (!--mm->count) {
+		exit_mmap(mm);
+		free_page_tables(mm);
+		kfree(mm);
 	}
 }
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this