From nobody Tue Oct 31 11:17:44 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 4SKSKm6k52z4yFYm for ; Tue, 31 Oct 2023 11:17:48 +0000 (UTC) (envelope-from bacon4000@gmail.com) Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SKSKl6zmhz4VDX for ; Tue, 31 Oct 2023 11:17:47 +0000 (UTC) (envelope-from bacon4000@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20230601 header.b="m4OU/Whd"; spf=pass (mx1.freebsd.org: domain of bacon4000@gmail.com designates 2607:f8b0:4864:20::f30 as permitted sender) smtp.mailfrom=bacon4000@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-qv1-xf30.google.com with SMTP id 6a1803df08f44-66d264e67d8so35841886d6.1 for ; Tue, 31 Oct 2023 04:17:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698751066; x=1699355866; darn=freebsd.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=RL4RFg1T4NOOYj4eTGX7z/2Ywhjnlv8uI5kKMeSNzK0=; b=m4OU/WhdGJ6fwgL1BPuxfKZgQO09v/UR3DdWuYue83Ev6G7a+69u/AH4tHpLgEcMd1 i1Vymi03gq7koBuinpiTpGJGl+yd9y3RdvAtJbPg16tj9+8oyZ+709qSewPE9iQPcGK1 CTA4RpHrBPBk39p+2OuNGT/Zv/IsGaIriYoa4RUlDe8Lnuo1FSHPcOtTyJTMbwTrHTNu cPHg5olxloxmu8egiRSoqlAMAN/fK+6ZaWLgEqMYROC5ZbSU2KVU84leOE64VfvecRiF TotA97LpJOr028VfJooRex5j/8Cu1AeaTVARZo8EbH1/L1ys6+WZdehXTAE6qT8WH79D Rqow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698751066; x=1699355866; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RL4RFg1T4NOOYj4eTGX7z/2Ywhjnlv8uI5kKMeSNzK0=; b=hxL9yfXDS6hnugNwkA+9Lxv5HmP95zi+hMUjNEtPWbDbLn2xSfTDqQ2sg8MWfvnTb4 9Oy9Uu0bwz/vKiflCnTTFYlHslCzd/abvxGqeuLbLTydtwa06EJBDDFWH8+sXRZjMmw6 n219q167g7b4Cf8wE3XdCmv635aOlCLfjQg//3owrHhXsY03sYnf8GasZmEG6arD/eTW lvPjPWYyy+vaeByaPtx+D9bxREoFs26u2uyN8Jjir4rKMcdNLYvG7oFG62V7ieoTuXc5 CdxZd1vtiuDPBs7xYUG24aeBvM9MsjnYxlUSuHCvcipMhAY+OBV8GeMTKcMmS18GADdL wnGA== X-Gm-Message-State: AOJu0Yy/CQw+rYzZL4cke3J2ePFepiaVfvMvF9kqOYWkKxF0+zRIVfdw lGXZvp84vdrluXnhNC4UoBQIVcvdgMs= X-Google-Smtp-Source: AGHT+IEbwaG8XqCgGkUl2BQbLgztuxueXsT698X5xsLzPwExTZHqmC+CrCpHq5vQ+ocxSxSm7+Dy0g== X-Received: by 2002:a05:6214:260c:b0:66d:37bc:bb91 with SMTP id gu12-20020a056214260c00b0066d37bcbb91mr17149578qvb.56.1698751066139; Tue, 31 Oct 2023 04:17:46 -0700 (PDT) Received: from [192.168.0.3] (cpe-184-58-230-200.wi.res.rr.com. [184.58.230.200]) by smtp.gmail.com with ESMTPSA id ek16-20020ad45990000000b0065d051fc445sm432352qvb.55.2023.10.31.04.17.45 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 31 Oct 2023 04:17:45 -0700 (PDT) Message-ID: <39f7e2aa-c0fd-4d8d-af1b-f71d6a079c9e@gmail.com> Date: Tue, 31 Oct 2023 04:17:44 -0700 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 User-Agent: Mozilla Thunderbird Subject: Re: system calls on FreeBSD To: freebsd-hackers@freebsd.org References: Content-Language: en-US From: Jason Bacon In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spamd-Result: default: False [-2.05 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-0.999]; NEURAL_SPAM_SHORT(0.94)[0.944]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20230601]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; MIME_GOOD(-0.10)[text/plain]; XM_UA_NO_VERSION(0.01)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::f30:from]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; BLOCKLISTDE_FAIL(0.00)[2607:f8b0:4864:20::f30:server fail,184.58.230.200:server fail]; RCPT_COUNT_ONE(0.00)[1]; RCVD_VIA_SMTP_AUTH(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; MLMMJ_DEST(0.00)[freebsd-hackers@freebsd.org]; DKIM_TRACE(0.00)[gmail.com:+]; FROM_EQ_ENVFROM(0.00)[]; TO_DN_NONE(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; ARC_NA(0.00)[]; RCVD_TLS_LAST(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; MIME_TRACE(0.00)[0:+]; MID_RHS_MATCH_FROM(0.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_COUNT_TWO(0.00)[2] X-Rspamd-Queue-Id: 4SKSKl6zmhz4VDX X-Spamd-Bar: -- 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.