Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch for makecontext, swapcontext, getcontext and setcontext required for lk/lib/libc #148

Closed
rkbug opened this issue Jul 26, 2016 · 2 comments

Comments

@rkbug
Copy link

rkbug commented Jul 26, 2016

I am porting an x86 SW code into ARM based system. The SW has implemented threading functions using (makecontext, swapcontext, getcontext and setcontext) routines. These routines are missing in the ~/lk/lib/libc code. Can anyone help me with the patch for these routines?

@rkbug rkbug closed this as completed Jan 10, 2018
@travisg
Copy link
Member

travisg commented Jan 10, 2018

Ah guess I lost track of this one. Not entirely sure what those do. Are they like setjmp/longjmp?

@M1cha
Copy link
Contributor

M1cha commented Jan 10, 2018

http://man7.org/linux/man-pages/man3/makecontext.3.html
https://linux.die.net/man/2/setcontext

Basically it's setjmp/longjmp with an API optimized for threading because you can easily return to the old context, change the stack pointer and the entrypoint, etc.

On Unix systems it actually does more than setjmp/longjmp because it saves more data like the signal mask so you can set that from within a signal handler to allow external/timed scheduling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants