Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

Students also viewed these Databases questions