Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\kthread.c Create Date:2022-07-28 09:30:25
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name: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()

Proto:int kthread_worker_fn(void *worker_ptr)

Type:int

Parameter:

TypeParameterName
void *worker_ptr
635  worker = worker_ptr
642  WARN_ON(task && task != current process)
643  task = current process
645  If flags & KTW_FREEZABLE Then set_freezable()
648  repeat :
649  set_current_state(TASK_INTERRUPTIBLE)
651  If 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(). Then
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;* (Used in tsk->state: )
653  raw_spin_lock_irq( & lock)
654  task = NULL
655  raw_spin_unlock_irq( & lock)
656  Return 0
659  work = NULL
660  raw_spin_lock_irq( & lock)
661  If Not list_empty - tests whether a list is empty*@head: the list to test. Then
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  list_del_init - deletes entry from list and reinitialize it.*@entry: the element to delete from the list.
666  current_work = work
667  raw_spin_unlock_irq( & lock)
669  If work Then
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;* (Used in tsk->state: )
671  func(work)
672  Else if Not freezing(current process) Then schedule()
675  try_to_freeze()
676  cond_resched()
677  Go to repeat