函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\kthread.c Create Date:2022-07-27 10:30:46
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:kthread_worker_fn - kthread function to process kthread_worker*@worker_ptr: pointer to initialized kthread_worker* This function implements the main cycle of kthread worker. It processes* work_list until it is stopped with kthread_stop()

函数原型:int kthread_worker_fn(void *worker_ptr)

返回类型:int

参数:

类型参数名称
void *worker_ptr
635  worker等于worker_ptr
642  WARN_ON(task && task != 当前进程)
643  task等于当前进程
645  如果flags按位与KTW_FREEZABLEset_freezable()
648  repeat :
649  set_current_state(睡眠态)
651  如果kthread_should_stop - should this kthread return now?* When someone calls kthread_stop() on your kthread, it will be woken* and this will return true. You should then return, and your return* value will be passed through to kthread_stop().
652  set_current_state() includes a barrier so that the write of current->state* is correctly serialised wrt the caller's subsequent test of whether to* actually sleep:* for (;;) {* set_current_state(TASK_UNINTERRUPTIBLE);* if (!need_sleep)* break;* (就绪态)
653  关闭本地中断,获取所要保护的运行队列(runqueue)的自旋锁(spinlock),为查找可运行进程做准备。( & lock)
654  task = NULL
655  raw_spin_unlock_irq( & lock)
656  返回:0
659  work = NULL
660  关闭本地中断,获取所要保护的运行队列(runqueue)的自旋锁(spinlock),为查找可运行进程做准备。( & lock)
661  如果非链表为空
662  work等于list_first_entry - get the first element from a list*@ptr: the list head to take the element from.*@type: the type of the struct this is embedded in.*@member: the name of the list_head within the struct.* Note, that list is expected to be not empty.( & work_list, structkthread_work, node)
664  删除链表项并重新初始化
666  current_work等于work
667  raw_spin_unlock_irq( & lock)
669  如果work
670  set_current_state() includes a barrier so that the write of current->state* is correctly serialised wrt the caller's subsequent test of whether to* actually sleep:* for (;;) {* set_current_state(TASK_UNINTERRUPTIBLE);* if (!need_sleep)* break;* (就绪态)
671  func(work)
672  否则如果非freezing(当前进程)则schedule()
675  try_to_freeze()
676  cond_resched()
677  转到:repeat