]> bbs.cooldavid.org Git - net-next-2.6.git/blame - include/linux/kthread.h
[PATCH] kthread: move kernel-doc and put it into DocBook
[net-next-2.6.git] / include / linux / kthread.h
CommitLineData
1da177e4
LT
1#ifndef _LINUX_KTHREAD_H
2#define _LINUX_KTHREAD_H
3/* Simple interface for creating and stopping kernel threads without mess. */
4#include <linux/err.h>
5#include <linux/sched.h>
6
1da177e4
LT
7struct task_struct *kthread_create(int (*threadfn)(void *data),
8 void *data,
9 const char namefmt[], ...);
10
11/**
9e37bd30 12 * kthread_run - create and wake a thread.
1da177e4
LT
13 * @threadfn: the function to run until signal_pending(current).
14 * @data: data ptr for @threadfn.
15 * @namefmt: printf-style name for the thread.
16 *
17 * Description: Convenient wrapper for kthread_create() followed by
9e37bd30
RD
18 * wake_up_process(). Returns the kthread or ERR_PTR(-ENOMEM).
19 */
1da177e4
LT
20#define kthread_run(threadfn, data, namefmt, ...) \
21({ \
22 struct task_struct *__k \
23 = kthread_create(threadfn, data, namefmt, ## __VA_ARGS__); \
24 if (!IS_ERR(__k)) \
25 wake_up_process(__k); \
26 __k; \
27})
28
1da177e4 29void kthread_bind(struct task_struct *k, unsigned int cpu);
1da177e4 30int kthread_stop(struct task_struct *k);
61e1a9ea 31int kthread_stop_sem(struct task_struct *k, struct semaphore *s);
1da177e4
LT
32int kthread_should_stop(void);
33
34#endif /* _LINUX_KTHREAD_H */