Re: system calls on FreeBSD

From: Konstantin Belousov <kib_at_freebsd.org>
Date: Tue, 31 Oct 2023 00:45:20 UTC
On Tue, Oct 31, 2023 at 12:33:35AM +0200, Alexander wrote:
> Greetings !
> 
> I am a newbie FreeBSD user, and I want to write one or two system calls on
> FreeBSD.
> 
> I have a question, please :
> 
> Why FreeBSD system calls take as an argument struct thread *t, en lieu de
> struct proc *p ?

Because sometimes we need to know context which called the syscall, and
passing process instead of thread means loosing this information. For
instance, SIGSYS must be delivered exactly to the thread that called
non-existing syscall, not to the process.

More reasonable question is why do we pass the context argument at all,
since it can be reconstructed by the curthread expression.