Answered step by step
Verified Expert Solution
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 struct uproc objects assuming the returned pointer is saved in pcs and call getprocs with getprocs 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 if there was an error. After receiving the process information from the kernel, your pstree in the userspace 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 processes.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started