xiaoxiang781216 commented on pull request #1009: URL: https://github.com/apache/incubator-nuttx/pull/1009#issuecomment-647422156
Yes, the SP modification need adjust for each host, @sebastianene07 can reference state-thread which implement user mode thread by setjmp/longjmp: https://github.com/ossrs/state-threads/blob/srs/md.h#L317 But there is a portable way to modify PC like this: ``` void up_initial_state(struct tcb_s *tcb) { if (tcb->pid == 0) { tcb->adj_stack_size = CONFIG_IDLETHREAD_STACKSIZE; tcb->stack_alloc_ptr = (void *)((uintptr_t)host_get_topstackaddr() - CONFIG_IDLETHREAD_STACKSIZE); } if (setjmp((&tcb->xcp)) { tcb->start(); } else { tcb->xcp.regs[JB_SP] = (xcpt_reg_t)tcb->adj_stack_ptr - sizeof(xcpt_reg_t); } } ``` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org