Questions tagged [kqueue]

Kqueue is a scalable event notification interface introduced in FreeBSD 4.1,[1] also supported in NetBSD, OpenBSD, DragonflyBSD, and Mac OS X.

Kqueue provides efficient input and output event pipelines between the kernel and userland. Thus, it is possible to modify event filters as well as receive pending events while using only a single system call to kevent per main event loop iteration. This contrasts with older traditional polling system calls such as poll and select which are less efficient, especially when polling for events on a large number of file descriptors.

Kqueue does not only handle file descriptor events but is also used for various other notifications such as file modification monitoring, signals, asynchronous I/O events (AIO), child process state change monitoring and timers which support nanosecond resolution.

129 questions
0
votes
0 answers

How do asynchronous calls à la `epoll` or `kqueue` work at the CPU (assembly) level?

I've recently been trying to wrap my brain around asynchronous I/O, that is, epoll() on Linux and kqueue() on FreeBSD; instead of creating multiple threads and using something like select(), you can create only one thread and still respond to many…
Fredrick Brennan
  • 7,079
  • 2
  • 30
  • 61
0
votes
1 answer

why epoll accepted new fd and spawn new thread doesn't scale well?

I have seen a lot of argument about epoll accepted new fd and spawn new thread for read and write on it's own thread doesn't scale well? But how it doesn't scale well? What if every connection has heavy processing like:- doing database…
Oktaheta
  • 606
  • 5
  • 21
0
votes
1 answer

What action does Kqueue dir extended watch?

I'm playing around with rb-kqueue on OS X and I can't work out how to get the extend flag to fire. From the OpenBSD kqueue man page (which also matches the OS X man page): NOTE_EXTEND The file referenced by the descriptor was extended Which is…
ian
  • 12,003
  • 9
  • 51
  • 107
0
votes
1 answer

Understanding kqueue in TCP

I am following tutorials about kqueue (specifically http://eradman.com/posts/kqueue-tcp.html and https://wiki.netbsd.org/tutorials/kqueue_tutorial/), and there are parts I don't understand. Here's my (edited) code: // assume internal_socket is…
sudo rm -rf slash
  • 1,156
  • 2
  • 16
  • 27
0
votes
1 answer

for range to send post request by using requests.Session(), it alert 'module' object has no attribute 'kqueue'

macOS 10.12.3 python 2.7.13 requests 2.13.0 I use requests package to send post request.This request need to login before post data.So I use request.Session() and load a logined cookie. Then I use this session to send post data in cycle mode. It is…
3Chimenea
  • 3
  • 3
0
votes
2 answers

Is there any way to emulate epoll_wait with kqueue/kevent?

I have a list of a bunch of file descriptors that I have created kevents for, and I'm trying to figure out if there's any way to get the number of them that are ready for read or write access. Is there any way to get a list of "ready" file…
clee
  • 10,943
  • 6
  • 36
  • 28
0
votes
0 answers

fileno errors when calling kevent function

I was using kqueue in Python 2.7 to build a file monitor. Initially, it kept outputting 0x4000 in flags and 0x1 in data, which turns out to be an error occurred. Then I found one example given by LaclefYoshi, and it works! My code, giving…
xh4n3
  • 1
  • 1
0
votes
1 answer

kqueue NOTE_EXIT doesn't work

I am trying to use Apple's example of using kqueue but the callback is never called unless I start observing the kqueue after the process starts. But the lifetime of the process is short and i need the code to work if the process starts before or…
Alex Zielenski
  • 3,591
  • 1
  • 26
  • 44
0
votes
0 answers

kevent & USB serial ports

I'm having trouble using kevent on mac with a USB serial console. I've narrowed it down to: #include
0
votes
1 answer

kqueue watch size change on directory

I'm trying to watch for size change on directory using kqueue, is this possible? The reason for this because I am watching directories and whenever an event triggers, I stat the directory and compare last mod times etc to figure out if…
Noitidart
  • 35,443
  • 37
  • 154
  • 323
0
votes
1 answer

kqueue on directory not trigger when file within is modified

I have used kquque to monitor desktop with: flags - EV_ADD | EV_CLEAR fflags - NOTE_DELETE | NOTE_WRITE | NOTE_EXTEND | NOTE_ATTRIB | NOTE_LINK | NOTE_RENAME | NOTE_REVOKE filter - EVFILT_VNODE However when I edit a .js file on desktop with…
Noitidart
  • 35,443
  • 37
  • 154
  • 323
0
votes
1 answer

Kqueue udata field changing

On mac I am using kqueue, it states that udata is unchanged. However the array returned in event_data of kevent call is being modified somewhat. What could cause this? I am passing in the pointer to string casted to void*, and when i read after…
Noitidart
  • 35,443
  • 37
  • 154
  • 323
0
votes
3 answers

Epoll, kqueue, user specified pointer: how to safely deallocate it in a multithreaded envinronment?

The facilities we can use in Unices systems for asynchronous I/O alerts, such as epoll on Linux, kqueue on BSD systems and Solaris /dev/poll or I/O Ports, all let the user to specify a pointer to be associated to the file descriptor the user want to…
Marco Pagliaricci
  • 1,366
  • 17
  • 31
0
votes
1 answer

What the most efficient way to monitor really large directories on FreeBSD

I have a FreeBSD installation and a very large directory structure with 10TiB of small files. I want to programmatically monitor and handle events such as a new file created or existing modified. I have tried to use kqueue() but it requires to open…
Dení
  • 183
  • 1
  • 9
0
votes
0 answers

wifi connection failure iPad

I am developing an app which communicates with server. Often communication drops and works again only when i terminate the app and relaunch it. from the device logs i found this error message : tcp_connection_destination_setup_socket_events…
vishnuvarthan
  • 492
  • 1
  • 6
  • 23
1 2 3
8
9