[NSWI004] Questions

Georgii Ekserdzhian gxrjan at gmail.com
Fri Nov 6 15:45:13 CET 2020


Good afternoon,
I have some questions:
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?

(2) and (3) are concerning thread_join retval.
2) "EBUSY Some other thread is already joining this one"
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.
3) "EINVAL" Invalid thread
Can you please define 'Invalid thread'? We have some thoughts about this
one, but we want to know for sure.

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.

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.

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?


Georgii Ekserdzhian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://d3s.mff.cuni.cz/pipermail/nswi004/attachments/20201106/1a62ed70/attachment.htm>


More information about the NSWI004 mailing list