We could add the function do_mygetpid to the misc.c file.
PUBLIC int do_mygetpid() { /** * Global mp will point to the caller's process table entry. * Lookup information in the process table. * Insert this information in the reply message (also * in the process table entry) */ return OK; }
This needs explanation, but for the moment note that do_mygetpid should do 2 things:
- fill in the reply message that will be sent back to the user process.
- return a value which will also be placed into the m_type part of the reply message.
If the return value is negative, say -E, the _syscall function treats this as an error and returns -1 to the user and sets the the user global variable errno to E.
Otherwise, _syscall just returns the value your do_mygetpid function returned.