Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

Advertisement
[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Advertisement

Kernel v2.6.5 /kernel/kthread.c

Filename:/kernel/kthread.c
Lines Added:21
Lines Deleted:2
Also changed in: (Previous) 2.6.5-rc3  2.6.5-rc2  2.6.5-rc1-bk4  2.6.5-rc1-bk3  2.6.5-rc1-bk2  2.6.5-rc1-bk1 
(Following) 2.6.7-rc2-bk3  2.6.7-rc2-bk4  2.6.7-rc2-bk5  2.6.7-rc2-bk6  2.6.7-rc2-bk7  2.6.7-rc2-bk8 

Location
[  2.6.5
  [  kernel
     o  kthread.c

Patch

diff -Nru a/kernel/kthread.c b/kernel/kthread.c
--- a/kernel/kthread.c   Sat Apr  3 19:38:55 2004
+++ b/kernel/kthread.c   Sat Apr  3 19:38:55 2004
@@ -10,6 +10,7 @@
 #include <linux/completion.h>
 #include <linux/err.h>
 #include <linux/unistd.h>
+#include <linux/file.h>
 #include <asm/semaphore.h>
 
 struct kthread_create_info
@@ -41,6 +42,21 @@
    return (kthread_stop_info.k == current);
 }
 
+
+static void kthread_exit_files(void)
+{
+   struct fs_struct *fs;
+   struct task_struct *tsk = current;
+
+   exit_fs(tsk);      /* current->fs->count--; */
+   fs = init_task.fs;
+   tsk->fs = fs;
+   atomic_inc(&fs->count);
+    exit_files(tsk);
+   current->files = init_task.files;
+   atomic_inc(&tsk->files->count);
+}
+
 static int kthread(void *_create)
 {
    struct kthread_create_info *create = _create;
@@ -50,6 +66,8 @@
    int ret = -EINTR;
    cpumask_t mask = CPU_MASK_ALL;
 
+   kthread_exit_files();
+
    /* Copy data: it's on keventd's stack */
    threadfn = create->threadfn;
    data = create->data;
@@ -91,7 +109,6 @@
    } else {
       wait_for_completion(&create->started);
       create->result = find_task_by_pid(pid);
-      wait_task_inactive(create->result);
    }
    complete(&create->done);
 }
@@ -131,7 +148,9 @@
 void kthread_bind(struct task_struct *k, unsigned int cpu)
 {
    BUG_ON(k->state != TASK_INTERRUPTIBLE);
-   k->thread_info->cpu = cpu;
+   /* Must have done schedule() in kthread() before we set_task_cpu */
+   wait_task_inactive(k);
+   set_task_cpu(k, cpu);
    k->cpus_allowed = cpumask_of_cpu(cpu);
 }
 


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.