<div dir="ltr"><div>Good afternoon, <br></div><div>I have some questions:</div><div>1) What happens when a thread calls thread finish in the middle of the entry function? Do we need to make the currently running thread run until it actually finishes it's entry function or do we just terminate it then and there? In case we terminate it, do just set retval to null?</div><div><br></div><div>(2) and (3) are concerning thread_join retval.<br></div><div>2) "EBUSY Some other thread is already joining this one"<br></div><div>By 'this one' do you mean the caller thread or the argument thread? If the argument thread, we don't see the issue, however there is an issue if someone is waiting for the caller thread since there might be a waiting cycle.</div><div>3) "EINVAL" Invalid thread</div><div>Can you please define 'Invalid thread'? We have some thoughts about this one, but we want to know for sure.<br></div><div><br></div><div>4) I'm not sure how we can determine that an entry function has finished by some thread? I had some thoughts of maybe recording the starting value of the sp register, so once sp goes back to it, we know that the stack frame has been popped and that means that the entry function is done, but that seems kinda janky.<br></div><div><br></div><div>5) When a thread executes return from the entry function, it pops the stack frame and ordinarily it should jump to the return address that was placed by some other function on the stack, but what is even there? We didn't place anything there.</div><div><br></div><div>6)  Can you please explain the $ra register. I get the concept of the return address of a function calling another function, in which case the return address is placed on the stack for the calle to jump to. But I'm a bit confused by this register. What is its purpose?<br></div><div><br></div><div><br></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Georgii Ekserdzhian</div></div></div></div></div>