Re: system calls on FreeBSD

From: Jason Bacon <bacon4000_at_gmail.com>
Date: Tue, 31 Oct 2023 11:17:44 UTC
On 10/30/23 17:45, Konstantin Belousov wrote:
> 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.
> 

If you're coming from Linux, note that processes and threads are the 
same thing to the Linux kernel, while in FreeBSD they are distinct. 
Hence the separation of 'struct thread' and 'struct proc'.

-- 
Life is a game.  Play hard.  Play fair.  Have fun.