Question: Your pstree program calls getprocs with an array of struct uproc objects and sets max to the size of that array ( in the unit

Your pstree program calls getprocs with an array of struct uproc objects and sets max to the size of that array (in the unit of struct uproc objects). For example, your program can malloc 64 struct uproc objects (assuming the returned pointer is saved in pcs) and call getprocs with getprocs(64, pcs);. The kernel stores up to max entries of the process information into your array, starting at the first slot of the array and filling it consecutively. The kernel returns the actual number of processes in existence at that point in time, or -1 if there was an error. After receiving the process information from the kernel, your pstree in the user-space formats it into the tree structure as shown in the example.
The problem with this system call is that if there are more processes than you have space for, you will miss some. But then if you use the returned integer to allocate a new struct uproc array and call getprocs again, some processes may have died or (worse!) new ones may have been created in the meantime. So youll have to be lucky to get the perfect listing for a busy system. In this assignment, lets assume the system has less than 64 processes.

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!