09-01-2008
mmap and select
I'm using select() to monitor multiple file descriptors (inet sockets) in application. But this application must also collaborate with other applications on the same host via shared memory (mmap'ed file) due to performance reasons. How can I become notification that mmaped memory is changed or semaphore state changed when the application is blocked in select()? For instance, can I perform select() (or epoll()) on the file descriptor that is mapp'ed to memory or should I use signals or something else?
10 More Discussions You Might Find Interesting
1. Filesystems, Disks and Memory
Hello. I'm writing some random access i/o software on Solaris 8 using mmap64 to memory map large files (my test file is ~25 GB).
The abbreviated code fragment is:
fd = open(cbuf,O_RDONLY|O_LARGEFILE);
struct stat statbuf;
fstat(fd,&statbuf);
off_t len =... (0 Replies)
Discussion started by: gusm
0 Replies
2. HP-UX
We recently have been seeing the following type of error on our development server. Being somewhat new to HP-UX I was hoping to get some insight. Here is what I have found.
I have been doing some research.
/usr/lib/dld.sl: Call to mmap() failed - TEXT /u07/mdev/lib/libCLEND.sl... (2 Replies)
Discussion started by: scotbuff
2 Replies
3. Solaris
Dear Experts,
i have a problem related to mmap(), when i run my program on sun for 64 bit which is throwing SIGBUS when it encounters mmap() function, what is the reason how to resolve this one, because it is working for 32 bit.
with regards,
vidya. (2 Replies)
Discussion started by: vin_pll
2 Replies
4. UNIX for Dummies Questions & Answers
how to use mmap() to map a file to memory space. Do you have any simple program???? Because I have to implement lot of concepts into it. (3 Replies)
Discussion started by: gokult
3 Replies
5. Programming
how to use mmap() to map a file to memory space. Do you have any simple program???? Because I have to implement lot of concepts into it. (5 Replies)
Discussion started by: gokult
5 Replies
6. Homework & Coursework Questions
Descriptions:
Develop a program that uses mmap() to map a file to memory space. Prepare such a file by yourself and do the follows.
<LI class=MsoNormal>Display the content of the file after mapping; <LI class=MsoNormal>Output how many digits included in the file; <LI class=MsoNormal>Replace... (1 Reply)
Discussion started by: gokult
1 Replies
7. Programming
hai,
How do we map 'n' number of files into memory by using mmap system call??
Thanks in advance...... (5 Replies)
Discussion started by: andrew.paul
5 Replies
8. UNIX for Advanced & Expert Users
Hi
I want to lock or prevent a portion of memory which I allocated. So I tried MLOCK, MPROTECT and some like this. But all these functions works only on page border. Can I know why that so.
Is that possible to protect a portion of memory which is in middle of the page.
Example.
int A;
... (1 Reply)
Discussion started by: jionnet
1 Replies
9. Emergency UNIX and Linux Support
I want to know whether this is possile or ever been tried out.
I want to obtain a chuck of memory using mmap()
I do it so :
n = mmap(0, 8000, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
And hold on to that memory, when a process requests for memory, some memory is... (2 Replies)
Discussion started by: xerox
2 Replies
10. BSD
I'm new to kernels and C, and I am tinkering around trying to understand OpenBSD's secure memory management. I'm stumped on a couple points.
I've read up on malloc() which was apparently modified years ago to allocate memory using mmap. First question, that would be this here, right?
... (4 Replies)
Discussion started by: dcicc
4 Replies
LEARN ABOUT DEBIAN
curl_multi_fdset
curl_multi_fdset(3) libcurl Manual curl_multi_fdset(3)
NAME
curl_multi_fdset - extracts file descriptor information from a multi handle
SYNOPSIS
#include <curl/curl.h>
CURLMcode curl_multi_fdset(CURLM *multi_handle,
fd_set *read_fd_set,
fd_set *write_fd_set,
fd_set *exc_fd_set,
int *max_fd);
DESCRIPTION
This function extracts file descriptor information from a given multi_handle. libcurl returns its fd_set sets. The application can use
these to select() on, but be sure to FD_ZERO them before calling this function as curl_multi_fdset(3) only adds its own descriptors, it
doesn't zero or otherwise remove any others. The curl_multi_perform(3) function should be called as soon as one of them is ready to be read
from or written to.
If no file descriptors are set by libcurl, max_fd will contain -1 when this function returns. Otherwise it will contain the higher descrip-
tor number libcurl set. When libcurl returns -1 in max_fd, it is because libcurl currently does something that isn't possible for your
application to monitor with a socket and unfortunately you can then not know exactly when the current action is completed using select().
When max_fd returns with -1, you need to wait a while and then proceed and call curl_multi_perform anyway. How long to wait? I would sug-
gest 100 milliseconds at least, but you may want to test it out in your own particular conditions to find a suitable value.
When doing select(), you should use curl_multi_timeout to figure out how long to wait for action. Call curl_multi_perform even if no activ-
ity has been seen on the fd_sets after the timeout expires as otherwise internal retries and timeouts may not work as you'd think and want.
If one of the sockets used by libcurl happens to be larger than what can be set in an fd_set, which on POSIX systems means that the file
descriptor is larger than FD_SETSIZE, then libcurl will try to not set it. Setting a too large file descriptor in an fd_set implies an out
of bounds write which can cause crashes, or worse. The effect of NOT storing it will possibly save you from the crash, but will make your
program NOT wait for sockets it should wait for...
RETURN VALUE
CURLMcode type, general libcurl multi interface error code. See libcurl-errors(3)
SEE ALSO
curl_multi_cleanup(3), curl_multi_init(3), curl_multi_timeout(3), curl_multi_perform(3)
libcurl 7.16.0 2 Jan 2006 curl_multi_fdset(3)