kthread: implement kthread_data()
Implement kthread_data() which takes @task pointing to a kthread and returns @data specified when creating the kthread. The caller is responsible for ensuring the validity of @task when calling this function. Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
Родитель
7bc465605f
Коммит
82805ab77d
|
@ -30,6 +30,7 @@ struct task_struct *kthread_create(int (*threadfn)(void *data),
|
||||||
void kthread_bind(struct task_struct *k, unsigned int cpu);
|
void kthread_bind(struct task_struct *k, unsigned int cpu);
|
||||||
int kthread_stop(struct task_struct *k);
|
int kthread_stop(struct task_struct *k);
|
||||||
int kthread_should_stop(void);
|
int kthread_should_stop(void);
|
||||||
|
void *kthread_data(struct task_struct *k);
|
||||||
|
|
||||||
int kthreadd(void *unused);
|
int kthreadd(void *unused);
|
||||||
extern struct task_struct *kthreadd_task;
|
extern struct task_struct *kthreadd_task;
|
||||||
|
|
|
@ -37,6 +37,7 @@ struct kthread_create_info
|
||||||
|
|
||||||
struct kthread {
|
struct kthread {
|
||||||
int should_stop;
|
int should_stop;
|
||||||
|
void *data;
|
||||||
struct completion exited;
|
struct completion exited;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -56,6 +57,19 @@ int kthread_should_stop(void)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(kthread_should_stop);
|
EXPORT_SYMBOL(kthread_should_stop);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* kthread_data - return data value specified on kthread creation
|
||||||
|
* @task: kthread task in question
|
||||||
|
*
|
||||||
|
* Return the data value specified when kthread @task was created.
|
||||||
|
* The caller is responsible for ensuring the validity of @task when
|
||||||
|
* calling this function.
|
||||||
|
*/
|
||||||
|
void *kthread_data(struct task_struct *task)
|
||||||
|
{
|
||||||
|
return to_kthread(task)->data;
|
||||||
|
}
|
||||||
|
|
||||||
static int kthread(void *_create)
|
static int kthread(void *_create)
|
||||||
{
|
{
|
||||||
/* Copy data: it's on kthread's stack */
|
/* Copy data: it's on kthread's stack */
|
||||||
|
@ -66,6 +80,7 @@ static int kthread(void *_create)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
self.should_stop = 0;
|
self.should_stop = 0;
|
||||||
|
self.data = data;
|
||||||
init_completion(&self.exited);
|
init_completion(&self.exited);
|
||||||
current->vfork_done = &self.exited;
|
current->vfork_done = &self.exited;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче