From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <199801031857.TAA25376@kotter.atko.at> Date: Sat, 3 Jan 1998 19:57:03 +0100 From: Stefan Traby Subject: Re: Man 2 POLL Hi ! > does anyone know where i kan find some info on the > > system call called poll(). poll is the System V version of BSD's "select" call. For Linux, use select. (see man 2 select) Poll and select blocks until some or more specified fid's change their status, or there are data available or it's possible to send nonblocking to a specific fid. if it returns < -1 it's good idea to check errno for EINTR (interrupted system call) select is also often used to sleep for a very short time. We call this "I/O-multiplexing" here in Austria... :-) The name for poll is really bad. In reality the process (or thread) goes for sleep until the kernel wakes it up. Under Linux, this may be done by device events if the driver has a non NULL "select"-field in struct file_operations. The kernel supports select_wait to wake up sleeping threads. You can make very fast event-driven kernel/userspace interfaces with select on both sides. To see select under heavy load with checking hundreds of fid's try: "strace emacs" (no joke) If you want really work with emacs while doing this (Ctrl-L does not really help) try "strace emacs 2>strace.out ; emacs strace.out" Another hint: There is maybe no man-page for poll. Maybe you want a simple prototype for poll: int poll(struct pollfd fdarray[], unsigned long nfds, int timeout); struct pollfd { int fd; /* file descriptors to check */ short events; /* events you want to look for */ short revents; /* returned events */ } Events are something like "POLLIN", "POLLRDNORM", "POLLRDBAND", "POLLPRI", "POLLOUT", "POLLWRNORM", "POLLWRBAND", "POLLERR", "POLLHUP", "POLLNVAL". The last three of them are returned only (revents). Timeout field: "INFTIM" for forever, 0 for "fast check", and > 0 for a timeout in ms. To get "INFTIM" you must include on some (or all System-V) systems. That should be enough to port a poll to select. (execpt for a async sig like POLLHUP, but who want a real working port under linux...) -- ciao - Stefan Stefan Traby phone: +43-3133-6107-2 Mitterlasznitzstr. 13 fax: +43-3133-6107-9 8302 Nestelbach mailto://stefan@sime.com Austria -- To unsubscribe: send e-mail to axp-list-request@redhat.com with 'unsubscribe' as the subject. Do not send it to axp-list@redhat.com