Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Stefan Traby <stefan@sime.com>
Subject: Re: Man 2 POLL
Date: Sat, 3 Jan 1998 19:57:03 +0100	[thread overview]
Message-ID: <199801031857.TAA25376@kotter.atko.at> (raw)

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 <stropts.h> 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

             reply	other threads:[~1998-01-03 18:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-01-03 18:57 Stefan Traby [this message]
  -- strict thread matches above, loose matches on Subject: below --
1998-01-05 18:55 Man 2 POLL Uncle George
1998-01-05 17:11 Miguel de Icaza
     [not found] <34AE5A68.42D84C5@voicenet.com>
1998-01-03 23:36 ` Tom Linden
1998-01-03 15:34 Uncle George
     [not found] <34AE3315.2DBD560C@voicenet.com>
1998-01-03 15:04 ` Tom Linden
1998-01-03 12:46 Uncle George
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox