Sponsored Content
Full Discussion: select vs poll
Special Forums IP Networking select vs poll Post 302115859 by porter on Saturday 28th of April 2007 05:18:59 PM
Old 04-28-2007
Quote:
Originally Posted by smanu
Do you by any chance have any idea about how much performance improvement can be achieved by replacing poll with Asynchronous I/O framework.
Alternatively consider pthreads. If your application takes advantage of threads for concurrent activity it will scale better on SMP hardware.
 

7 More Discussions You Might Find Interesting

1. Programming

How to convert the "select" function into a "poll" function

i have a program using the select function but i want to convert it to poll... how can i do this? thanks in advance... :) (1 Reply)
Discussion started by: rbolante
1 Replies

2. UNIX for Dummies Questions & Answers

Replace select/poll with kqueue/kevent

Hi, As far as I known, kqueue/kevent model can be used to improve the efficiency of systems event dispatching. I m wondering whether kqueue/kevent is same as the real-time OS event model. I also want to know when writing multiplexing app in real-time OS, what APIs need to be used for... (1 Reply)
Discussion started by: bsderss
1 Replies

3. Programming

select/poll and Signal Safety

Hi I am struggling to understand why one should use pselect()/ppoll() instead of wrapping an ordinary select() or poll() call around sigprocmask(). The linux man page talks about “race conditions”, but how would such dangers occur? I plan to use poll() for an application (since ppoll() isn't... (0 Replies)
Discussion started by: nopcoder
0 Replies

4. UNIX for Dummies Questions & Answers

Poll data from a file

I have to write a script where I poll a txt file for data (30 min interval) Dependent on the data read, the script should return a message. It should look something like the "code" below: -- do while <data recived> sleep 30m read data from file Done If <data> x return "A" If... (1 Reply)
Discussion started by: ioniCoder
1 Replies

5. Shell Programming and Scripting

how to poll for new files?

Hi , i have a requirement in which i have to ftp files to unix from windows and vice versa. I have to encrypt files in windows which will then be decrypted in unix and vice versa. Now the process needs to be automated ..therefore when windows server or unix server recieves the files a shell... (5 Replies)
Discussion started by: lifzgud
5 Replies

6. Shell Programming and Scripting

How to use poll() for I/O multiplex

Hi, guys: I want to write my own shell using C. I am confused about the usage of I/O multiplex. Does anyone know some examples or explain it to me ? Thanks so much (1 Reply)
Discussion started by: tomlee
1 Replies

7. What is on Your Mind?

Powerhouses and mainstream poll

This not a joke but a quite serious question to maybe have your point of view about this very topic of content on the net. So I start this poll to ask the users if they can imagine that the so called content industry of former times sooner or later or anyway will regain lost ground or not? Do you... (1 Reply)
Discussion started by: 1in10
1 Replies
LIBDLM(3)						     Library Functions Manual							 LIBDLM(3)

NAME
libdlm - dlm_get_fd, dlm_dispatch, dlm_pthread_init, dlm_ls_pthread_init, dlm_cleanup SYNOPSIS
#include <libdlm.h> int dlm_pthread_init(); int dlm_ls_pthread_init(dlm_lshandle_t lockspace); int dlm_pthread_cleanup(); int dlm_get_fd(void); int dlm_dispatch(int fd); link with -ldlm DESCRIPTION
libdlm provides the programmatic userspace interface to the Distributed Lock manager. It provides all the calls you need to manipulate locks & lockspaces libdlm can be used in pthread or non-pthread applications. For pthread applications simply call the following function before doing any lock operations. If you're using pthreads, remember to define _REENTRANT at the top of the program or using -D_REENTRANT on the compile line. pthreads is the normal way of using the DLM. This way you simply initialize the DLM's thread and all the AST routines will be delivered in that thread. You just call the dlm_lock() etc routines in the main line of your program. If you don't want to use pthreads or you want to handle the dlm callback ASTs yourself then you can get an FD handle to the DLM device and call dlm_dispatch() on it whenever it becomes active. That was ASTs will be delivered in the context of the thread/process that called dlm_dispatch(). int dlm_pthread_init() Creates a thread to receive all lock ASTs. The AST callback function for lock operations will be called in the context of this thread. If there is a potential for local resource access conflicts you must provide your own pthread-based locking in the AST routine. int dlm_ls_pthread_init(dlm_lshandle_t lockspace) As dlm_pthread_init but initializes a thread for the specified lockspace. int dlm_pthread_cleanup() Cleans up the default lockspace threads after use. Normally you don't need to call this, but if the locking code is in a dynamically load- able shared library this will probably be necessary. For non-pthread based applications the DLM provides a file descriptor that the program can feed into poll/select. If activity is detected on that FD then a dispatch function should be called: int dlm_get_fd() Returns a file-descriptor for the DLM suitable for passing in to poll() or select(). int dlm_dispatch(int fd) Reads from the DLM and calls any AST routines that may be needed. This routine runs in the context of the caller so no extra locking is needed to protect local resources. libdlm_lt There also exists a "light" version of the libdlm library called libdlm_lt. This is provided for those applications that do not want to use pthread functions. If you use this library it is important that your application is NOT compiled with -D_REENTRANT or linked with libpthread. EXAMPLES
Create a lockspace and start a thread to deliver its callbacks: dlm_lshandle_t ls; ls = dlm_create_lockspace("myLS", 0660); dlm_ls_pthread_init(ls); ... status = dlm_ls_lock(ls, ... ); Using poll(2) to wait for and dispatch ASTs static int poll_for_ast(dlm_lshandle_t ls) { struct pollfd pfd; pfd.fd = dlm_ls_get_fd(ls); pfd.events = POLLIN; while (!ast_called) { if (poll(&pfd, 1, 0) < 0) { perror("poll"); return -1; } dlm_dispatch(dlm_ls_get_fd(ls)); } ast_called = 0; return 0; } SEE ALSO
libdlm(3), dlm_lock(3), dlm_unlock(3), dlm_open_lockspace(3), dlm_create_lockspace(3), dlm_close_lockspace(3), dlm_release_lockspace(3) libdlm functions July 5, 2007 LIBDLM(3)
All times are GMT -4. The time now is 10:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy