在include/linux/kthread.h里有如下的宏定义,用来创建和唤醒一个线程
/**
18 * kthread_run - create and wake a thread.
19 * @threadfn: the function to run until signal_pending(current).
20 * @data: data ptr for @threadfn.
21 * @namefmt: printf-style name for the thread.
22 *
23 * Description: Convenient wrapper for kthread_create() followed by
24 * wake_up_process(). Returns the kthread or ERR_PTR(-ENOMEM).
25 */
26#define kthread_run(threadfn, data, namefmt, ...) \
27({ \
28 struct task_struct *__k \
29 = kthread_create(threadfn, data, namefmt, ## __VA_ARGS__); \
30 if (!IS_ERR(__k)) \
31 wake_up_process(__k); \
32 __k; \
33})
本文详细介绍了Linux内核中kthread_run宏的作用及使用方法。该宏用于创建并唤醒一个内核线程,简化了kthread_create和wake_up_process两个步骤。文章提供了宏的具体定义,帮助读者理解其内部实现。
1292

被折叠的 条评论
为什么被折叠?



