C kthread_run——最后一条语句(_k;)的用途
我正在阅读linux内核,特别是在查看进程创建时,偶然发现了以下宏[1]C kthread_run——最后一条语句(_k;)的用途,c,linux-kernel,C,Linux Kernel,我正在阅读linux内核,特别是在查看进程创建时,偶然发现了以下宏[1] /** * kthread_run - create and wake a thread. * @threadfn: the function to run until signal_pending(current). * @data: data ptr for @threadfn. * @namefmt: printf-style name for the thread. * * Description: C
/**
* kthread_run - create and wake a thread.
* @threadfn: the function to run until signal_pending(current).
* @data: data ptr for @threadfn.
* @namefmt: printf-style name for the thread.
*
* Description: Convenient wrapper for kthread_create() followed by
* wake_up_process(). Returns the kthread or ERR_PTR(-ENOMEM).
*/
#define kthread_run(threadfn, data, namefmt, ...) \
({ \
struct task_struct *__k \
= kthread_create(threadfn, data, namefmt, ## __VA_ARGS__); \
if (!IS_ERR(__k)) \
wake_up_process(__k); \
__k; \
})
我的问题很简单:最后一行的目的是什么代码>
[1] 该宏是一个__k是返回值(线程指针)。
语句表达式是clang也支持的GCC扩展。谢谢你,我不知道这个C扩展,我稍后会接受你的回答!