Mmpdflushc

struct pdflush_work {

struct task_struct *who; void (*fn)(unsigned long); unsigned long arg0; struct list_head list; unsigned long when_i_went_to

/* The thread */ /* A callback function */ /* An argument to the callback */ /* On pdflush_list, when idle */ leep;

As usual, the fact that the data structure is defined in a C header file instead of a header file indicates to the kernel that the structure may be used only by internal code. Generic code uses other mechanisms to access the kernel synchronization capabilities that are examined below:

□ who is a pointer to the kernel thread task_struct instance used to represent the specific pdflush instance in the process table.

□ Several instances of pdflush_work can be grouped together in a doubly linked standard list using the list list head. The kernel uses the global variable pdflush_list (defined in mm/pdflush.c) to draw up a list of the work still to be done.

□ The extraordinarily long when_i_went_to_sleep element stores the time in jiffies when the thread last went to sleep. This value is used to remove superfluous pdflush threads from the system (i.e., threads that are still in memory but have been idle for a longer period).

□ The fn function pointer (in conjunction with arg0) is the backbone of the structure. It holds the function in which the actual work to be done is implemented. arg0 is passed as an argument when the function is invoked.

By using different function pointers for fn, the kernel is able to incorporate a variety of synchronization routines in the pdflush framework so that the right routine can be selected for the job in hand.

Continue reading here: Thread Initialization

Was this article helpful?

0 0