Question: II . Reading from the / proc File System Once the process identifier has been stored, any reads from / proc / pid will return
II Reading from the proc File System
Once the process identifier has been stored, any reads from procpid will return the name of the command, its process identifier, and its state. As illustrated in Section the PCB in Linux is represented by the structure taskstruct, which is found in the include file. Given a process identifier, the function pidtask returns the associated taskstruct. The signature of this function appears as follows:
struct taskstruct pidtaskstruct pid pid
enum pidtype type
The kernel function findvpidint pid can be used to obtain the struct pid, and PIDTYPEPID can be used as the pidtype.
For a valid pid in the system, pidtask will return its taskstruct. You can then display the values of the command, pid, and state. You will probably have to read through the taskstruct structure in to obtain the names of these fields.
If pidtask is not passed a valid pid, it returns NULL. Be sure to perform appropriate error checking to check for this condition. If this situation occurs, the kernel module function associated with reading from procpid should return
In the source code download, we give the C program pid.c which provides some of the basic building blocks for beginning this project.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
