Re: Proposal: merged system calls

Koyama Tadayoshi (koyama@infocity.co.jp)
Wed, 22 May 1996 00:01:44 +0900


From: Ingo Molnar <mingo@kaliban.csoma.elte.hu>
Subject: Proposal: merged system calls
Date: Sun, 19 May 1996 23:03:32 -0400 (EDT)

>
>[Some Line Deleted]
>
> a HTTP server reads data from a file and sends it to another machine
> through a socket. These two system calls could be merged:
>
> the old method:
>
> read( 4, buffer, 100 );
> send( 5, buffer, 100, 0 );
>
> the proposed method:
>
> read_send( 4, 5, 100, 0 );
>
> (note that there is no user space buffer in the second call)

As you mentioned, I think it is mmap which to be used to do this kind
of job.

How about:

mem_buffer = mmap(0, length, PROT_READ, MAP_FILE, fd, 0);
while (length)
size_t chunk_size = length > 500 ? 500 : length;
send(5, buffer, chunk_size, 0);
length -= chunk_size; buffer += chunk_size;
}
munmap(mem_buffer, saved_length);

It is simple enough, isn't it?

# Is this work on Linux? My OLD man page says:
# " This is a BSD man page. Linux 0.99.11 can't map files,
# and can't do other things documented here."

>(note that there is no user space buffer in the second call)
>
>Thus the overhead of one empty system call, and the copying of the buffer
>between user and kernel space could be avoided. Windows NT solves this
>particular problem with kernel bloat: system calls that do exactly this
>
> [Some Lines Deleted]
>
>-- mingo

It may useful if you time three method, read-send, mmap, merged-syscall.
merged-syscall may be the fastest, but it may not be such fast enough to
make people add new syscall and use it (to kernel and libc).

koyama