From nobody Tue Oct 31 00:45:20 2023 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SKBJ73rmyz4ycV1 for ; Tue, 31 Oct 2023 00:45:27 +0000 (UTC) (envelope-from kib@freebsd.org) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4SKBJ72036z4cmC for ; Tue, 31 Oct 2023 00:45:27 +0000 (UTC) (envelope-from kib@freebsd.org) Authentication-Results: mx1.freebsd.org; none Received: from tom.home (kib@localhost [127.0.0.1] (may be forged)) by kib.kiev.ua (8.17.1/8.17.1) with ESMTP id 39V0jK6J005356; Tue, 31 Oct 2023 02:45:23 +0200 (EET) (envelope-from kib@freebsd.org) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 39V0jK6J005356 Received: (from kostik@localhost) by tom.home (8.17.1/8.17.1/Submit) id 39V0jKoG005355; Tue, 31 Oct 2023 02:45:20 +0200 (EET) (envelope-from kib@freebsd.org) X-Authentication-Warning: tom.home: kostik set sender to kib@freebsd.org using -f Date: Tue, 31 Oct 2023 02:45:20 +0200 From: Konstantin Belousov To: Alexander Cc: freebsd-hackers@freebsd.org Subject: Re: system calls on FreeBSD Message-ID: References: List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-14) on tom.home X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US] X-Rspamd-Queue-Id: 4SKBJ72036z4cmC 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.