|
|
|
|
|
|
| Author |
Message |
MingyanGuo *nix forums beginner
Joined: 05 Jun 2006
Posts: 4
|
Posted: Mon Jun 05, 2006 5:13 pm Post subject:
Re: Why use `thread' as an argument of Syscalls?
|
|
|
On 6/5/06, Robert Watson <rwatson@freebsd.org> wrote:
| Quote: |
On Mon, 5 Jun 2006, Suleiman Souhlal wrote:
Robert Watson wrote:
On Mon, 5 Jun 2006, Daniel Eischen wrote:
They are the same questions, I think . Now would you please
explain
"why use `proc' as an argument of Syscalls" to me ? I've read
some
source code of the kernel, but no comments about it found.
I don't know. Convention? It makes sense to me.
Certainly consistency. Most system calls do actually use the argument
at
some point -- be it to look up a file descriptor, access control, or
the
like, and the calling context has it for free and in-hand anyway.
But couldn't they just use curthread/curproc?
In the past, in micro-benchmarking, I've measured a small performance hit
from
using per-cpu variables over variables already in the stack. However,
that
was quite a while ago, and I'm not entirely convinced the test results
were
valid. In the general case, it's pretty helpful to be able to pass in,
for
example, explicit credential references, as it means you can do acess
control
checks, auditing, accounting, etc, against arbitrary credentials rather
than
always against curthread->td_ucred. In a number of places, we pass
threads
down the stack where we mean to pass credentials, such as at several spots
in
the network stack. There are also places where the process is passed
around
so it can become a later argument to lockmgr() locking primitives, and
since
those are decreasingly used, the references are increasingly unnecessary.
Robert N M Watson
|
Thanks.
MingyanGuo
--
Three passions, simple but overwhelmingly strong, have governed my life:
the longing for love, the search for knowledge, and unbearable pity for
the suffering of mankind.
---------Bertrand Russell
_______________________________________________
freebsd-arch@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org" |
|
| Back to top |
|
 |
MingyanGuo *nix forums beginner
Joined: 05 Jun 2006
Posts: 4
|
Posted: Mon Jun 05, 2006 4:30 pm Post subject:
Re: Why use `thread' as an argument of Syscalls?
|
|
|
On 6/5/06, Robert Watson <rwatson@freebsd.org> wrote:
| Quote: |
On Mon, 5 Jun 2006, Daniel Eischen wrote:
They are the same questions, I think . Now would you please explain
"why
use `proc' as an argument of Syscalls" to me ? I've read some
source
code of the kernel, but no comments about it found.
I don't know. Convention? It makes sense to me.
Certainly consistency. Most system calls do actually use the argument at
some
point -- be it to look up a file descriptor, access control, or the like,
and
the calling context has it for free and in-hand anyway.
Robert N M Watson
|
Thanks for your reply. And any more reasons?
I have browsed some OpenSolaris and Linux source,
and find that they get the `proc'/`thread'/`task'
by `curproc'/`curthread'/`current' like macros
when needed, which are different from FreeBSD.
So I wanna know why FreeBSD do it in this way,
has some mysterious reasons;-)? or not.
Thanks
Regards,
MingyanGuo
--
Three passions, simple but overwhelmingly strong, have governed my life:
the longing for love, the search for knowledge, and unbearable pity for
the suffering of mankind.
---------Bertrand Russell
--
Three passions, simple but overwhelmingly strong, have governed my life:
the longing for love, the search for knowledge, and unbearable pity for
the suffering of mankind.
---------Bertrand Russell
_______________________________________________
freebsd-arch@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org" |
|
| Back to top |
|
 |
Robert Watson *nix forums Guru Wannabe
Joined: 22 Mar 2002
Posts: 218
|
Posted: Mon Jun 05, 2006 3:56 pm Post subject:
Re: Why use `thread' as an argument of Syscalls?
|
|
|
On Mon, 5 Jun 2006, Suleiman Souhlal wrote:
| Quote: | Robert Watson wrote:
On Mon, 5 Jun 2006, Daniel Eischen wrote:
They are the same questions, I think . Now would you please explain
"why use `proc' as an argument of Syscalls" to me ? I've read some
source code of the kernel, but no comments about it found.
I don't know. Convention? It makes sense to me.
Certainly consistency. Most system calls do actually use the argument at
some point -- be it to look up a file descriptor, access control, or the
like, and the calling context has it for free and in-hand anyway.
But couldn't they just use curthread/curproc?
|
In the past, in micro-benchmarking, I've measured a small performance hit from
using per-cpu variables over variables already in the stack. However, that
was quite a while ago, and I'm not entirely convinced the test results were
valid. In the general case, it's pretty helpful to be able to pass in, for
example, explicit credential references, as it means you can do acess control
checks, auditing, accounting, etc, against arbitrary credentials rather than
always against curthread->td_ucred. In a number of places, we pass threads
down the stack where we mean to pass credentials, such as at several spots in
the network stack. There are also places where the process is passed around
so it can become a later argument to lockmgr() locking primitives, and since
those are decreasingly used, the references are increasingly unnecessary.
Robert N M Watson
_______________________________________________
freebsd-arch@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org" |
|
| Back to top |
|
 |
Poul-Henning Kamp *nix forums Guru
Joined: 21 Mar 2002
Posts: 436
|
Posted: Mon Jun 05, 2006 3:48 pm Post subject:
Re: Why use `thread' as an argument of Syscalls?
|
|
|
In message <448450FD.4030709@FreeBSD.org>, Suleiman Souhlal writes:
| Quote: | Robert Watson wrote:
On Mon, 5 Jun 2006, Daniel Eischen wrote:
They are the same questions, I think . Now would you please
explain "why use `proc' as an argument of Syscalls" to me ? I've
read some source code of the kernel, but no comments about it found.
I don't know. Convention? It makes sense to me.
Certainly consistency. Most system calls do actually use the argument
at some point -- be it to look up a file descriptor, access control, or
the like, and the calling context has it for free and in-hand anyway.
But couldn't they just use curthread/curproc?
|
Yes, mostly.
It's a good question how much, if anything, it helps.
--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
_______________________________________________
freebsd-arch@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org" |
|
| Back to top |
|
 |
Garrett Wollman *nix forums addict
Joined: 08 May 2002
Posts: 59
|
Posted: Mon Jun 05, 2006 3:42 pm Post subject:
Re: Why use `thread' as an argument of Syscalls?
|
|
|
Robert Watson writes:
| Quote: | Certainly consistency. Most system calls do actually use the argument at some
point -- be it to look up a file descriptor, access control, or the like, and
the calling context has it for free and in-hand anyway.
|
I believe it was the intention of the 4.4BSD developers to completely
eliminate "curproc" (as they had already successfully eliminated "u"),
on the theory that with a modern (RISC) processor architecture,
passing the current process as a parameter wouldn't cost anything
(since it would stay in a register for the life of the system call)
whereas making a context-switched "curproc" would be expensive.
-GAWollman
_______________________________________________
freebsd-arch@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org" |
|
| Back to top |
|
 |
Suleiman Souhlal *nix forums beginner
Joined: 17 Sep 2003
Posts: 12
|
Posted: Mon Jun 05, 2006 3:42 pm Post subject:
Re: Why use `thread' as an argument of Syscalls?
|
|
|
Robert Watson wrote:
| Quote: |
On Mon, 5 Jun 2006, Daniel Eischen wrote:
They are the same questions, I think . Now would you please
explain "why use `proc' as an argument of Syscalls" to me ? I've
read some source code of the kernel, but no comments about it found.
I don't know. Convention? It makes sense to me.
Certainly consistency. Most system calls do actually use the argument
at some point -- be it to look up a file descriptor, access control, or
the like, and the calling context has it for free and in-hand anyway.
|
But couldn't they just use curthread/curproc?
-- Suleiman
_______________________________________________
freebsd-arch@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org" |
|
| Back to top |
|
 |
Robert Watson *nix forums Guru Wannabe
Joined: 22 Mar 2002
Posts: 218
|
Posted: Mon Jun 05, 2006 3:36 pm Post subject:
Re: Why use `thread' as an argument of Syscalls?
|
|
|
On Mon, 5 Jun 2006, Daniel Eischen wrote:
| Quote: | They are the same questions, I think . Now would you please explain "why
use `proc' as an argument of Syscalls" to me ? I've read some source
code of the kernel, but no comments about it found.
I don't know. Convention? It makes sense to me.
|
Certainly consistency. Most system calls do actually use the argument at some
point -- be it to look up a file descriptor, access control, or the like, and
the calling context has it for free and in-hand anyway.
Robert N M Watson
_______________________________________________
freebsd-arch@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org" |
|
| Back to top |
|
 |
Daniel Eischen *nix forums addict
Joined: 20 Sep 2002
Posts: 68
|
Posted: Mon Jun 05, 2006 3:19 pm Post subject:
Re: Why use `thread' as an argument of Syscalls?
|
|
|
On Mon, 5 Jun 2006, MingyanGuo wrote:
| Quote: | On 6/5/06, Daniel Eischen <deischen@freebsd.org> wrote:
On Mon, 5 Jun 2006, MingyanGuo wrote:
Hi all,
I find that FreeBSD Syscalls always have an `thread'
argument, for example, preadv(/sys/kern/sys_generic.c)
has a `td' argument. But some Syscalls may rarely use
this argument, and thay ( and functions they invoke) can
get the `thread' who make the Syscall _easily_ via
`curthread' macro if needed. So the `thread' argument
seems not needed.
Can anybody tell me why use `thread' as an argument
of Syscalls?
You could have asked "why use 'proc' as an argument of Syscalls"
12 years ago (or more). When the kernel became thread-aware
(almost 5 years ago), most 'struct proc' arguments were changed
to 'struct thread'.
--
DE
They are the same questions, I think . Now would
you please explain "why use `proc' as an argument
of Syscalls" to me ? I've read some source code
of the kernel, but no comments about it found.
|
I don't know. Convention? It makes sense to me.
--
DE
_______________________________________________
freebsd-arch@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org" |
|
| Back to top |
|
 |
MingyanGuo *nix forums beginner
Joined: 05 Jun 2006
Posts: 4
|
Posted: Mon Jun 05, 2006 1:08 pm Post subject:
Re: Why use `thread' as an argument of Syscalls?
|
|
|
On 6/5/06, Daniel Eischen <deischen@freebsd.org> wrote:
| Quote: |
On Mon, 5 Jun 2006, MingyanGuo wrote:
Hi all,
I find that FreeBSD Syscalls always have an `thread'
argument, for example, preadv(/sys/kern/sys_generic.c)
has a `td' argument. But some Syscalls may rarely use
this argument, and thay ( and functions they invoke) can
get the `thread' who make the Syscall _easily_ via
`curthread' macro if needed. So the `thread' argument
seems not needed.
Can anybody tell me why use `thread' as an argument
of Syscalls?
You could have asked "why use 'proc' as an argument of Syscalls"
12 years ago (or more). When the kernel became thread-aware
(almost 5 years ago), most 'struct proc' arguments were changed
to 'struct thread'.
--
DE
|
They are the same questions, I think . Now would
you please explain "why use `proc' as an argument
of Syscalls" to me ? I've read some source code
of the kernel, but no comments about it found.
Thanks.
Regards,
--
Three passions, simple but overwhelmingly strong, have governed my life:
the longing for love, the search for knowledge, and unbearable pity for
the suffering of mankind.
---------Bertrand Russell
_______________________________________________
freebsd-arch@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org" |
|
| Back to top |
|
 |
Daniel Eischen *nix forums addict
Joined: 20 Sep 2002
Posts: 68
|
Posted: Mon Jun 05, 2006 11:50 am Post subject:
Re: Why use `thread' as an argument of Syscalls?
|
|
|
On Mon, 5 Jun 2006, MingyanGuo wrote:
| Quote: | Hi all,
I find that FreeBSD Syscalls always have an `thread'
argument, for example, preadv(/sys/kern/sys_generic.c)
has a `td' argument. But some Syscalls may rarely use
this argument, and thay ( and functions they invoke) can
get the `thread' who make the Syscall _easily_ via
`curthread' macro if needed. So the `thread' argument
seems not needed.
Can anybody tell me why use `thread' as an argument
of Syscalls?
|
You could have asked "why use 'proc' as an argument of Syscalls"
12 years ago (or more). When the kernel became thread-aware
(almost 5 years ago), most 'struct proc' arguments were changed
to 'struct thread'.
--
DE
_______________________________________________
freebsd-arch@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org" |
|
| Back to top |
|
 |
MingyanGuo *nix forums beginner
Joined: 05 Jun 2006
Posts: 4
|
Posted: Mon Jun 05, 2006 7:44 am Post subject:
Why use `thread' as an argument of Syscalls?
|
|
|
Hi all,
I find that FreeBSD Syscalls always have an `thread'
argument, for example, preadv(/sys/kern/sys_generic.c)
has a `td' argument. But some Syscalls may rarely use
this argument, and thay ( and functions they invoke) can
get the `thread' who make the Syscall _easily_ via
`curthread' macro if needed. So the `thread' argument
seems not needed.
Can anybody tell me why use `thread' as an argument
of Syscalls?
Thanks.
Regards,
--
Three passions, simple but overwhelmingly strong, have governed my life:
the longing for love, the search for knowledge, and unbearable pity for
the suffering of mankind.
---------Bertrand Russell
_______________________________________________
freebsd-arch@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org" |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Thu Dec 04, 2008 12:09 am | All times are GMT
|
|
Loans | Internet Advertising | Free Advertising | Loan | Remortgages
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|