[gambit-list] res_query in the FFI

Lang Martin lang-gb at coptix.com
Fri Oct 13 12:39:45 EDT 2006


quoth Christian:

> and calling into C without any further 
> help will block other scheme threads for the duration of the call.

ah. That sucks. I think I was under the impression that since you can
call/cc around C functions, the thread scheduler would be able to do
the same trick it does to interrupt scheme continuations.

> So unless you're going to build such a dispatcher, there's no point
> in making the C library reentrant, since everything is actually
> running in one single OS thread.

Well, Bernsteins library has an asychronous mode -- his preferred way
of dealing w/ threads.

> - create said dispatcher, using either pthreads underneath (and 
> probably pipes for synchronisation), or pipes and fork.

The pthreads thing kind of scares me -- the folks who grok unix best
(DJB being close to foremost) avoid them in favor of processes and
pipes. My temporary solution does (run-process ...).

> - look at what the Gambit host-info.. builtins are missing, and try 
> to improve on that by patching Gambit.

So far seems to only use gethostbyname(), which is a level of
abstraction too high.

> - port the DNS client library from "scheme underground" to Gambit
>   (http://www.scsh.net/resources/sunet.html)
> The second option is probably the best for us all :).

I might argue that this way is best.

Actually, I'd probably argue that we should do an s-expr C syntax, and
compile down the FFI stuff. And then make new backends for other
schemes. And then tell the python folks to kiss it.

> The first one may be the 
> easiest if you don't like to delve into too many lowlevel details.

Alas, I might punt, and do just that.

> I guess you mean EBCDIC. Why would this play a role with DNS, is DNS 
> using EBCDIC, or are you on a mainframe?

I do, and I thought that the OS 10.4 res_query might return it. Not
working on a mainframe, unless you count the macbook, which would be
cheeky. Wikipedia to the rescue! Whoa, I must have been looking at
entirely the wrong page.

> >Should I create a port? If so, can someone point me to a bit of the
> >source code that'll get me started with that?
> 
> ("No". But you may need ports to communicate readyness (and the 
> address of some struct) to another pthread when implementing 
> concurrency with pthreads.)

seems to be a good interface if I go for the DJB async query. Can
someone point me to the contruction of a port?

> For converting between UTF-8 encoded byte arrays and Scheme strings 
> just use the |utf8-string| type with c-lambda.

brilliant. Thanks.

Thanks very much, that was a thoughtful response.



More information about the Gambit-list mailing list