52 lines
1.2 KiB
Markdown
52 lines
1.2 KiB
Markdown
# Kernel Queue (kqueue) Utilization
|
|
|
|
This is your lame attempt to understand how those Network Virtual Functions sofware works as well to sharpen your understanding on C++ and C programming language.
|
|
|
|
## Why not [epoll]() or [select]()
|
|
|
|
Using epoll or select would make your system spend most of its time looking at and fiddling sith the data structures and has very little time for anything else.
|
|
|
|
|
|
## Notes
|
|
|
|
|
|
|
|
- Compile using `g++` for the file watcher
|
|
|
|
To trace the function calls on FreeBSD based system use `truss()` instead of `strace`.
|
|
|
|
The `kqueue_socket.c` is my attempt on create a socket watcher timer program using `kevent`.
|
|
|
|
- [KQUEUE NETBSD GUIDE](https://wiki.netbsd.org/tutorials/kqueue_tutorial/)
|
|
|
|
```C
|
|
// --------------------------------------------
|
|
struct kevent my_event;
|
|
struct kevent my_change;
|
|
|
|
EV_SET(&my_change, ...); // Initialize the kevent
|
|
|
|
for(;;){
|
|
|
|
...;
|
|
}
|
|
|
|
```
|
|
|
|
### TCP 01
|
|
|
|
- Pointer of kevent
|
|
|
|
### TCP 02
|
|
|
|
- Array of kevent
|
|
|
|
## Goal
|
|
|
|
- Understand the difference between c++ and C
|
|
- Understand how strcuct works and the difference between it on c++ and C
|
|
- Understand
|
|
|
|
## Issues
|
|
- Modification to target file only detected after 2 or more interrupt
|