Re: System calls parameter restrictions
- From: phil-news-nospam@xxxxxxxx
- Date: 27 Oct 2006 22:10:32 GMT
On Fri, 27 Oct 2006 16:54:36 -0300 Rafael Almeida <rafaelc@xxxxxxxxxxx> wrote:
| On 26 Oct 2006 01:54:12 -0700
| "David Schwartz" <davids@xxxxxxxxxxxxx> wrote:
|
|> Obviously, nobody would design a system that had a system call that
|> required a parameter you couldn't pass the value for. You can always
|> pass pointers, otherwise 'read' and 'write' wouldn't work. A struct
|> would be passed by address.
|>
| Obviously you can pass pretty much anything through a pointer, but what
| I didn't understand was whether you could pass a struct by value or not.
C is capable of passing a struct by value. But in the past it was not,
and thus traditional Unix system calls would pass a struct by pointer.
In cases where the struct might be changed and the called needs to see
those changes, then either passing by pointer is needed or the syscall
would need to return the struct value.
I've never heard of any syscall that passes or returns a struct by value.
That doesn't mean there couldn't be one in the future.
| Yeah, I couldn't find any system call that gets a struct as a parameter.
| That's why I thought it was a restriction on the possible parameter
| types. And I want to know the reason of that restriction. Not because I
| want to pass a struct as a parameter so bad, but because I want to learn
| what I'm missing that would make passing a struct by value a bad idea.
It's not that bad of an idea for application programs. I've done it many
times. As for passing to and from a kernel, that might be another issue.
Passing by value is actually a kind of abstraction, anyway. Literally,
the struct is copied or loaded in registers, depending on architecture.
The register starved i386 is probably going to have to copy.
--
|---------------------------------------/----------------------------------|
| Phil Howard KA9WGN (ka9wgn.ham.org) / Do not send to the address below |
| first name lower case at ipal.net / spamtrap-2006-10-27-1704@xxxxxxxx |
|------------------------------------/-------------------------------------|
.
- References:
- System calls parameter restrictions
- From: Rafael Almeida
- Re: System calls parameter restrictions
- From: David Schwartz
- Re: System calls parameter restrictions
- From: Rafael Almeida
- System calls parameter restrictions
- Prev by Date: Re: System calls parameter restrictions
- Next by Date: Re: Problems with server shutdown
- Previous by thread: Re: System calls parameter restrictions
- Next by thread: Re: System calls parameter restrictions
- Index(es):
Relevant Pages
|