pussuw edited a comment on pull request #5731:
URL: https://github.com/apache/incubator-nuttx/pull/5731#issuecomment-1081012244
> Yes, but it isn't reliable since we can't control how C compiler generate
the machine code which may insert push/pop operation between
group_addrenv<->riscv_switchcontext and riscv_switchcontext<->riscv_swint in
the new version or different compiler options.
Yes only option is to make sure interrupt or kernel stack is in use. I'm not
even sure how the old implementation seemingly works for me. If the return
address is put into stack, the SW should get lost when it attempts to return
from group_addrenv(), as the memory pointed to by SP is no longer the same.
Unless the next task is always a kernel task when a user task is being
suspended, then the address is still mapped, like you already said. I must have
gotten lucky in my testing or something.
I guess this is what saves it
```
/* Does the group have an address environment? */
if ((group->tg_flags & GROUP_FLAG_ADDRENV) == 0)
{
/* No... just return perhaps leaving a different address environment
* intact.
*/
return OK;
}
```
So when a kernel task is resumed and a user task is suspended, the user
task's environment is left in place, I guess..
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]