Syscall: void exit(int exitcode) All user programs end by calling the_exit system call, even if your main) function does not end with the C library exit) function. Ever wonder what calls main in the...

Syscall: void exit(int exitcode) All user programs end by calling the_exit system call, even if your main) function does not end with the C library exit) function. Ever wonder what calls main in the first place or where it goes when it returns? Have a look at userland/lib/crt0/mips/crto.S-this is where your user-level C programs really start executing. You should be able to find the call to main) and the call to_exit after main returns. Without an implementation of_exit, the threads created to handle user programs just hang around forever, executing an infinite loop in user space and taking up a lot of the CPU time. You should be able to locate that loop in mips/crtO.S as well. Handle_exit so that the thread calling_exit is fully destroyed and all memory is returned to the system. You should be able to implement this system call with a few lines of code in syscall.c HINT: Find an existing function that is an ideal handler for the exit system call. Modify this function to receive the exit code parameter. You will also have to modify all other uses of this function to pass an exit code. You should pass an appropriate exit code to this function, based on the exit value supplied by the user-level process, using the macros supplied in kern/include/kern/wait.h. Use a DEBUGO statement in this function to print out the exit code if the DB SYSCALL messages are enabled. The exit code would ordinarily need to be stored in some data structure associated with the thread, so that another thread could check its exit status However, it turns out that cleaning up threads is a complex process, so for this assignment you don't need to store the exit code anywhere
Nov 25, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here