Question: Programming Project #2 Linux Kernel Module for Listing Tasks In this project, you will write a kernel module that lists all current tasks in a

Programming Project #2 Linux Kernel Module for Listing Tasks In this project, you will write a kernel module that lists all current tasks in a Linux system. You will iterate through the tasks both linearly and depth first. Part IIterating over Tasks Linearly In the Linux kernel, the for_each_process() macro easily allows iteration over all current tasks in the system:

#include

struct task_struct *task; for_each_process(task) {

/* on each iteration task points to the next task */

}

The various fields in task_struct can then be displayed as the program loops through the for_each_process() macro. Assignment Design a kernel module that iterates through all tasks in the system using the for_each_process() macro. In particular, output the task command, state, and process id of each task. (You will probably have to read through the task_struct structure in to obtain the names of these fields.) Write this code in the module entry point so that its contents will appear in the kernel log buffer, which can be viewed using the dmesg command. To verify that your code is working correctly, compare the contents of the kernel log buffer with the output of the following command, which lists all tasks in the system: ps -el The two values should be very similar. Because tasks are dynamic, however, it is possible that a few tasks may appear in one listing but not the other.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!