Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(a) (3 points) On line 15 of the C code, in the argint function, why do we add 4 to proc - >tf - >esp
(a) (3 points) On line 15 of the C code, in the argint function, why do we add 4 to
proc - >tf - >esp ?
(b) On that same line, why do we multiply n by 4?
(c) What could go wrong if xv6 didn't have the check at line 5 in fetchint ?
2. The following is the code that implements the kill system call in xv6 Assembly Code 1 kill 3 int $0x40 4 ret C code 1// Fetch the int at addr from the current process 2 int fetchint uint addr ,int *ip) 5 if addr proc ->z I addr +4 > proc ->z) 7 *ip = *( int *) ( addr ); return1 8 return 0 10 11 // Fetch the nth 32-bit system call argument 12 int 13 argint (int n, int *ip) 14 15 return fetchint (proc ->tf ->esp 4 + 4*n, ip 16 17 18 int 19 sys_kil1 ( void ) 20 21 int pid 23 if ( argint (0, &pid) z I addr +4 > proc ->z) 7 *ip = *( int *) ( addr ); return1 8 return 0 10 11 // Fetch the nth 32-bit system call argument 12 int 13 argint (int n, int *ip) 14 15 return fetchint (proc ->tf ->esp 4 + 4*n, ip 16 17 18 int 19 sys_kil1 ( void ) 20 21 int pid 23 if ( argint (0, &pid)
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