Question: Modify this system call to print the information for an arbitrary process. The system call takes a process pid (process id) as its argument and

 Modify this system call to print the information for an arbitrary

Modify this system call to print the information for an arbitrary process. The system call takes a process pid (process id) as its argument and outputs the above information of this process.

HINT: You can start from the init process and iterate over all the processes. For each process, compare its pid with the target pid. If there is a match, return the pointer to this task_struct. A better approach is to use the pidhash table to look up the process in the process table. Linux provides many functions to find a task by its pid.

other useful methods:

1. for_each_process()

2. pid_task()

#include #include #include #include #include "processinfo.h" asmlinkage long sys_listProcessInfo(void) struct task struct *proces; for each process (proces) printk( "Process%s utime : %ld \ start time : %ld \ Process state: %ld " \ proces->comm, (long)task pid nr(proces), (long)proces->utime, \ (long)proces->start time, (long)proces->state, I \ if (proces->parent) printk( "Parent \ %s, \ process: %ld", PID Number: proces->parentComm, (long)task pid nr(proces->parent) printk("n ") return ; #include #include #include #include #include "processinfo.h" asmlinkage long sys_listProcessInfo(void) struct task struct *proces; for each process (proces) printk( "Process%s utime : %ld \ start time : %ld \ Process state: %ld " \ proces->comm, (long)task pid nr(proces), (long)proces->utime, \ (long)proces->start time, (long)proces->state, I \ if (proces->parent) printk( "Parent \ %s, \ process: %ld", PID Number: proces->parentComm, (long)task pid nr(proces->parent) printk("n ") return

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!