Question: Testing your System Call To test your system call, write a simple program which creates a few child processes and a few child threads before

Testing your System Call

To test your system call, write a simple program which creates a few child processes and a few child threads before it calls the new pinfo system call.Your program should print all the process state information for the calling process. Run the program several times. Which fields in the pinfo structure change? Which ones do not? For each field in the pinfo structure, discuss how frequently it changes and why as part of your experiments and document in your learning report.

Although system calls are generally accessed through a library (glibc), your test program should access your system call directly. This is accomplished by utilizing the syscall() function. See man syscall. Your test program may include code like the following:

#include

#include

#include pinfo.h

Int main()

{

struct pinfo p_info;

int status;

/* create child processes and keep em active */

/* create child threads and keepem active */

/* If this is the parent process, call new system call */

status = syscall (327, &p_info); //NOTE: use proper system call number designated in the system call table file (/usr/src/linux/arch/x86/syscalls/syscall_64.tbl)

/* and output to standard output the info returned by new system call */

printf("p_info: ");

printf(

"pid = %d "

"state = %ld "

"nice = %ld "

"parent_pid = %d "

"children = %d "

"youngest_child_pid = %d "

"younger_sibling_pid = %d "

"older_sibling_pid = %d "

"start_time = %lu "

"user_time = %ld "

"sys_time = %ld "

"uid = %ld "

"comm = %s ",

p_info.pid, p_info.state, p_info.nice, p_info.parent_pid, p_info.children,

p_info.youngest_child_pid, p_info.younger_sibling_pid, p_info.older_sibling_pid,

p_info.start_time, p_info.user_time, p_info.sys_time, p_info.uid, p_info.comm);

exit(0);

}

Consider setting up a shell script from which you start several background processes (i.e. sleep x) prior to launching your testing C program so as to register siblings with a common parent. The child processes and child threads created from within your testing C program should block or sleep long enough to allow the new system call to collect statistics for their parent.

The output of the program should be easy to read. The ps and top commands will provide valuable help in verifying the accuracy of information printed by your program. You can access detailed information on these commands on the man pages.

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!