Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Jun 2000 22:09:06 +0200
From:      Bernd Walter <ticso@cicely8.cicely.de>
To:        "G.B.Naidu" <gbnaidu@sasi.com>
Cc:        hackers@FreeBSD.ORG, net@FreeBSD.ORG
Subject:   Re: [REPOST]  Re: How do I get port inside kernel.... (fwd)
Message-ID:  <20000607220906.A98783@cicely8.cicely.de>
In-Reply-To: <Pine.LNX.4.21.0006071011570.763-100000@pcd75.sasi.com>; from gbnaidu@sasi.com on Wed, Jun 07, 2000 at 10:13:26AM %2B0530
References:  <Pine.LNX.4.21.0006071011570.763-100000@pcd75.sasi.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Jun 07, 2000 at 10:13:26AM +0530, G.B.Naidu wrote:
> 
> Thanks a lot for your reply. It's quite useful. But I have some more
> questions generated of this study of nfs code and sendfile(2) code. The
> question is about getting a proc structure. Here it is.
> 
> As you all know that every system call in side kernel needs a process
> structure to be passed. So to call socreate, sobind or getsocket we need a
> proc structure. My doubt is which process structure to pass?
> 
> In nfs code, at some places it is passing the curproc structure which is
> nothing but currently running process. At other places example for
> socreate() and sobind(), it is using proc0 structure which is nothing but
> of the swap process. So when I am executing the kernel, what is the
> current process? Is it safe if I use proc0 to pass the proc structure to
> call socreate() and sobind()? How safe it is to use curproc
> structure? Somebody mentioned that it will not work in interrupt
> handlers.

Sockets depend on a specific process.
Interrupt handlers can interrupt any process, so you don't know to which
curproc points to.
In general it is best to use proc0 as long as you don't need to share
the socket with any application.
If you need to - you can use it only when called from this process.
Remembering the process won't help much, because it will invalidate if the
process it belongs to dies.

-- 
B.Walter                  COSMO-Project              http://www.cosmo-project.de
ticso@cicely.de             Usergroup                info@cosmo-project.de



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




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