Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Aug 2006 16:42:34 +0100 (BST)
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Alexander Leidinger <netchild@FreeBSD.org>
Cc:        cvs-src@FreeBSD.org, rdivacky@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/sys/compat/linux linux_misc.c
Message-ID:  <20060819162526.D49007@fledge.watson.org>
In-Reply-To: <20060819170544.118d2c2b@Magellan.Leidinger.net>
References:  <200608172121.k7HLLUY5095480@repoman.freebsd.org> <20060818184107.B47942@fledge.watson.org> <20060819170544.118d2c2b@Magellan.Leidinger.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 19 Aug 2006, Alexander Leidinger wrote:

> Quoting Robert Watson <rwatson@FreeBSD.org> (Fri, 18 Aug 2006 18:47:12 +0100 (BST)):
>
>> On Thu, 17 Aug 2006, Alexander Leidinger wrote:
>>
>>>  - protect td->td_proc->p_pid with the proc lock in linux_getpid
>>>    in the amd64 (= non i386) case [1]
>>
>> Is this necessary?  In principle, td->td_proc is static for a live thread 
>> bound to a process (i.e., in a system call, which the current thread 
>> presumable is, as long as td == curthread), p_pid is static for a live 
>> process that isn't exiting (so in a system call is not generally exiting). 
>> The native FreeBSD getpid() only acquires the process lock when following 
>> p_pptr, since this can change during a system call (i.e., as a result of 
>> the parent dying, and the child being re-parented to init(8)).
>
> Now that you tell me this, I have the impression that I have mixed up p_pid 
> with p_pptr here... I have to have a look at the code again.

In the general case, following many p->p_foo fields does require the process 
lock, as the process might exit, etc, while you're accessing the fields.  The 
exception for curthread->td_proc relates to fields that are static as long as 
the process isn't exiting.  Fields with this property are marked with (b) in 
the locking guide in proc.h.

Robert N M Watson
Computer Laboratory
University of Cambridge



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060819162526.D49007>