Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this exercise, you implement a new system call with signature: int -getdpids

ID: 3879346 • Letter: I

Question

In this exercise, you implement a new system call with signature: int -getdpids (pidt top, pidt dpids[], int len); It finds process IDs (PIDs) of descendant processes of a given process, in breath first search order. The system call takes three arguments: the PID of the top process (top), a array to store the PIDs (dpids []) and an integer that indicates the size of the array (1en), in PIDs. Test your system call with the following programs (must be updated with your 1st ame Test program 1 #include #include #include #include #define LEN 14 /* buffer size, int main(int argc, char** args) f in PIDs (can't be > 14) */ pid_t pid, cpid; PIDs / pid_t dpids [LEN]; /* buffer for descendant PIDs/ int i, r; /* control vars / printf("Test 1 - Single child "); /* get the PID/ pid = getpid(); /* print the PID/ printf ("My PID is %d ", pid); cpid-forkO if (cpid!=0) { /* in parent ! */ printf ("Child PID is %d ", cpid); /*get and print all descendants/ r-michel-getdpids (pid, dpids, LEN);

Explanation / Answer

Please find the below code. This is as per my understanding of what is asked in the question.

Save the below function in a separate file and save it as "michel_getpids.h" (i.e., with .h extension). And execute your test programs with your header file as already included.


int michel_getdpids(pid_t top, pid_t dpids[], int len)
{
int r1=0,t=top;

r1 = write(t, &dpids, len);
// printf("Michel it is executed and r1 is : %d", r1); // This I had written to check whether it is executing or not.
return r1;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote