setcontext syscall

From: George Fankhauser
Date: Thu Nov 20 2003 - 02:31:23 EST


Hi there!

I wonder why linux i386 does not implement setcontext as a syscall. Instead it's in in glibc in userspace.

The problem that one may run into is with asynchronous signals such as SIGALRM, VTALRM, and IO: Let's say you have good reason to block such signals because your handling one of them and want to restore another user context which has them enabled in its sigmask. What sigcontext simply does is
1. trap into sigprocmask
2. restore all regs and jump
after exit of 1) until jump in 2) there is plenty of time to run into another asynchronous signal which must be detected in the nested handler etc. This is rather ugly.
I see this as a main reason to put setcontext into the kernel. Another one is performance: since we use sigprocmask, a syscall is used anyway.
And BTW: All SysV implementations use indeed syscalls for set/getcontext for these reasons.

What do you think?

regards
George
--
Sensaco GmbH
mailto:gfa@xxxxxxxxxxx

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/