Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upOS I/O: Raw Devices #272
Conversation
vyzo
added some commits
Jun 6, 2017
vyzo
referenced this pull request
Jun 8, 2017
Closed
OS I/O: Raw Devices and Dynamically sized fdsets #271
vyzo
referenced this pull request
Jun 8, 2017
Merged
OS I/O: Dynanically sized fdsets for poll and select #273
This comment has been minimized.
This comment has been minimized.
@feeley any progress with the generic port hierarchy? |
This comment has been minimized.
This comment has been minimized.
I discovered a bug in the |
This comment has been minimized.
This comment has been minimized.
Halfway done... |
This comment has been minimized.
This comment has been minimized.
Waitable ports are now implemented by commit 05cec0e. |
This comment has been minimized.
This comment has been minimized.
Excellent! I will merge and update the raw-device-ports to be descendants of waitable-ports. By the way, how do you generate the type-ids for the structs? Is it a random uuid or something structured? |
This comment has been minimized.
This comment has been minimized.
btw,
|
This comment has been minimized.
This comment has been minimized.
unless the process is just a pipe in userland, in which case it's ok:
|
vyzo
added some commits
Jun 11, 2017
This comment has been minimized.
This comment has been minimized.
Ok, merged! I'll do some casual testing and update #273 as well. |
This comment has been minimized.
This comment has been minimized.
seems like my implementation of wait is not correct - |
This comment has been minimized.
This comment has been minimized.
ok, verified that all port operations work as intended, this should be ready for merge! |
This comment has been minimized.
This comment has been minimized.
Updates for review comments in #273. The only sticking point left is the utility of We can drop the function altogether if you think the caller should be doing the actual opening of the device (ie if you think it's too POSIX specific) |
This comment has been minimized.
This comment has been minimized.
Updated per review comments. |
This comment has been minimized.
This comment has been minimized.
small brainfart in usage of id field, fixing. |
feeley
requested changes
Jun 12, 2017
return ___FIX(___NO_ERR); | ||
} | ||
|
||
___HIDDEN ___SCMOBJ ___device_raw_select_virt |
This comment has been minimized.
This comment has been minimized.
feeley
Jun 12, 2017
Member
Please make a copy of ___device_file_select_raw_virt
including the WIN32 part, because then it will probably work as-is on Windows.
|
||
fd = ___INT(index); | ||
|
||
if ((e = ___device_raw_setup_from_fd |
This comment has been minimized.
This comment has been minimized.
feeley
Jun 12, 2017
Member
Indent properly... open paren for parameters should be 2 spaces indented from the ___device_...
.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
!= ___FIX(___NO_ERR)) | ||
return e; | ||
|
||
if ((e = ___NONNULLPOINTER_to_SCMOBJ |
This comment has been minimized.
This comment has been minimized.
} | ||
#endif | ||
|
||
___SCMOBJ ___os_device_raw_open |
This comment has been minimized.
This comment has been minimized.
feeley
Jun 12, 2017
Member
I keep thinking that it is wrong to expose this function in Scheme since is is POSIX specific. It is OK however to make it available to C code, so that a device can be constructed from a fd using the FFI. The "index" parameter should be "fd" because that's what it is. The function should be called ___os_device_raw_open_from_fd
.
@@ -4279,6 +4279,12 @@ end-of-code | |||
scheme-object ;; device | |||
"___os_device_stream_open_process")) | |||
|
|||
(define-prim ##os-device-open-raw |
This comment has been minimized.
This comment has been minimized.
feeley
Jun 12, 2017
Member
See comment below. This functionality should not be exposed to the Scheme level.
vyzo
added some commits
Jun 12, 2017
This comment has been minimized.
This comment has been minimized.
Seems like |
This comment has been minimized.
This comment has been minimized.
ok, will rename. |
vyzo
added some commits
Jun 12, 2017
This comment has been minimized.
This comment has been minimized.
ok, updated! Sorry for the indentation mismatch, i tend to just follow emacs in GNU style. |
This comment has been minimized.
This comment has been minimized.
actually there is an accident from the copy paste and it's a wrong cast in |
vyzo
force-pushed the
vyzo:os-io-raw-devices
branch
from
ee7da5b
to
49aa0bf
Jun 12, 2017
This comment has been minimized.
This comment has been minimized.
ok, now we should be good -- waiting for the build to finish to run some tests, but it looks good to me. |
This comment has been minimized.
This comment has been minimized.
testing successful. |
feeley
merged commit babd59d
into
gambit:master
Jun 12, 2017
1 check passed
vyzo
deleted the
vyzo:os-io-raw-devices
branch
Jun 12, 2017
This comment has been minimized.
This comment has been minimized.
adam-7
commented
Jul 25, 2017
@vyzo , what's a raw device, what are their usecases? Can you provide a short example script that illustrates their utility here? |
This comment has been minimized.
This comment has been minimized.
Things like sockets, epoll, inotify and kquque file descriptors. |
This comment has been minimized.
This comment has been minimized.
adam-7
commented
Jul 25, 2017
Ah! By "raw device", do you just mean that you have created a facility whereby the user can allocate his own OS file descriptor of any type that the OS can produce, (I have not studied epoll/inotify/kqueue so it's not in my awareness that they produce their own FD:s, but I understand that's what you're saying, so they fit the picture too;) and, what you have done here is to provide a facility where the user can create a Gambit port object that functions only to represent such a file descriptor, so that the user may do |##device-port-wait-for-input!| and |##device-port-wait-for-output!| on that port object? I guess such a raw port object is actually totally passive, as in, Gambit will not do any operations on it such as OS write, read, close operations, but they function only to make Gambit include that FD in Gambit's select/poll() call, during the ##device-port-wait-for-input/output! call? Are any other operations than ##device-port-wait-for-input/output! supported on those raw ports? Are the raw ports documented in the manual now or do you keep these out of the manual due to being too low level? Probably the raw ports will be used for pretty low level stuff, right? Except for this and making Gambit's epoll() support unlimited number of ports (whereas previously there was an ~8000 FD:s limit and exceeding that led to SIGSEGV), have you done any other major addition now? Looks great! :) Thanks |
This comment has been minimized.
This comment has been minimized.
This is just a heads up that the API for Vyzo, here is how the old API can be emulated:
To access the "device" from the port, use |
This comment has been minimized.
This comment has been minimized.
adam-7
commented
Nov 18, 2017
Like what types? |
This comment has been minimized.
This comment has been minimized.
thanks marc! |
This comment has been minimized.
This comment has been minimized.
I'm implementing UDP ports and it is convenient to build them on top of raw-device ports. By the way, the API has changed again to: |
This comment has been minimized.
This comment has been minimized.
Can the kind be an arbitrary object (eg a symbol) and not just a numeric kind in the new API? |
vyzo commentedJun 8, 2017
Cherry picked from #271.
Adds raw devices, currently implemented for POSIX only, so that special devices can be used to perform userland read/write operations while integrating with the Gambit scheduler.