Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions