Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing to multiple file-descriptors

Tags:

c++

c

linux

gcc

Is there any OS-level (Linux) speedup when writing one fixed byte buffer to many file-descriptors? When writing many buffers to one file-descriptor one can use writev(2), so I wonder if there's any analogue to this or it must be done by multiple sys-calls.

like image 598
Cartesius00 Avatar asked Jan 20 '12 08:01

Cartesius00


People also ask

Can a file have multiple file descriptors?

One process can have multiple file descriptors point to the same entry (e.g., as a result of a call to dup() ) Multiple processes (e.g., a parent and child) can have file descriptors that point to the same entry.

How many file descriptors can a process have?

The number of file descriptors that can be allocated to a process is governed by a resource limit. The default value is set in the /etc/security/limits file and is typically set at 2000. The limit can be changed by the ulimit command or the setrlimit subroutine.

Do threads share the same file descriptors?

Threads in the same process share an address space and file descriptor table, so we do not need to save the page-table root pointer or the fd table.

What are the 3 standard file descriptors?

Stdin, stdout, and stderr On a Unix-like operating system, the first three file descriptors, by default, are STDIN (standard input), STDOUT (standard output), and STDERR (standard error).


2 Answers

I know no such syscall on Linux. Their exhaustive list is given in the syscalls(2) man page.

And I won't bother that much. For file access, the real bottleneck is the disk...

like image 72
Basile Starynkevitch Avatar answered Oct 15 '22 19:10

Basile Starynkevitch


I haven't used it but this might work: lio_listio

http://linux.die.net/man/3/lio_listio

like image 33
dsb124 Avatar answered Oct 15 '22 20:10

dsb124