Question: Programming language:C; Programming environment: minix 3(Linux like system); I only ask for how to write this function in C. Please use exercise2 as ; Thx!

Programming language:C;

Programming environment: minix 3(Linux like system);

I only ask for how to write this function in C.

Please use exercise2 as ;

Thx!

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

int getdpids(pid t top, pid t 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 (len), in PIDs.

Just get an idea you do not have to test ur file.

Test your system call with the following programs (must be updated with your 1st name). Test program 1: #include #include #include #include #define LEN 14 /* buffer size, in PIDs (cant be > 14) */ int main(int argc, char** args) { 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 = fork(); if (cpid!=0) { /* in parent! */ printf("Child PID is %d ", cpid); /* get and print all descendants */ r = michel_getdpids(pid, dpids, LEN); 1 printf("Tree has %d process(es) ", r); for (i=0;i #include #include #include #include #define LEN 14 /* buffer size, in PIDs (cant be > 14) */ #define N 5 /* number of forked children */ int main(int argc, char** args) { pid_t pid, cpid; /* PIDs */ pid_t dpids[LEN]; /* buffer for descendant PIDs */ int i, j, r; /* control vars */ printf("Test 2 - Fan of children "); /* get the PID */ pid = getpid(); /* print the PID */ printf("My PID is %d ", pid); /* fork N children */ for (j=0; j #include #include #include #include #define LEN 14 /* buffer size, in PIDs (cant be > 14) */ #define N 3 /* max number of forked children per parent */ int main(int argc, char** args) { pid_t pid, cpid; /* PIDs */ pid_t dpids[LEN]; /* buffer for descendant PIDs */ int i, r; /* control vars */ /* get the PID */ pid = getpid(); /* print the PID */ printf("My PID is %d ", pid); printf("Test 3 - Tree of children "); /* fork a tree of descendants */ for (i=0; i

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!