Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming language:C; Programming environment: minix 3(Linux like system); Please include a README.txt file containing a detailed report about your work (describe every change you made

Programming language:C;

Programming environment: minix 3(Linux like system);

Please include a README.txt file containing a detailed report about your work (describe every change you made to the system code and where you made it)

Please use exercise2 as ;

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.

Here is the instruction but is not necessary to follow;

1. In the following, all file names are given relative to that path /usr/src. 2. Declare your system call in a new header file that you put in the directory /include/. 3. List the name of your file in the in file /usr/src/include/Makefile. 4. Define your system call in that you put in the directory /minix/lib/libc/sys/. 5. List the name of your file in the file minix/lib/libc/sys/Makefile.inc. 6. Define your system call number in the file /minix/include/minix/callnr.h. 7. Declare a function in file /minix/servers/pm/proto.h. 8. Register the function into the call vector in /minix/servers/pm/table.c, that has been reserved in file /minix/include/minix/callnr.h. 9. Define the function in the directory /minix/servers/pm.

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

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

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

7. How might you go about testing these assumptions?

Answered: 1 week ago