[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] chicken and threads (can they be disabled)
From: |
Peter Bex |
Subject: |
Re: [Chicken-users] chicken and threads (can they be disabled) |
Date: |
Fri, 22 Jan 2010 09:48:02 +0100 |
User-agent: |
Mutt/1.4.2.3i |
On Thu, Jan 21, 2010 at 06:30:57PM -0800, Dru Nelson wrote:
> hi,
>
> For this particular application, it is really important that I can get
> access to the raw Unix/Posix API for I/O handling.
> This is the problem I've run into with many languages over the years. They
> attempt to provide support for thread systems which invariably taints how IO
> is handled. I just need to be able to cleanly perform IO, fork, select etc.
> without concern that the system call is being abstracted or wrapped with
> additional logic.
First off, I'd like to say it's a little strange to expect to be able to
use a highlevel programming language without it "getting in the way". Isn't
that the point of using a highlevel language?
Having said that, Chicken's threading model is cooperative. That means if
you call the procedures you need via the FFI, you can assume one invocation
of such a procedure is uninterrupted.
However, keep in mind that on the Scheme side, threads are automatically
yielded for you unless you disable interrupts.
Also, I think you will need to disable signals, or Chicken will still might
in your way.
> Some languages have support for this via a compilation step (--no-threads).
> Does Chicken have this capability?
I don't think it should cause issues if you don't create any threads, but
there is a (disable-interrupts) declaration that allow you to make all
code in a compilation unit entirely uninterrupted:
http://chicken.wiki.br/man/4/Declarations#disable-interrupts
You can also set the thread quantum to a very high value, see
http://chicken.wiki.br/man/4/Unit%20srfi-18
> Should I use the existing eggs/units for Posix and Socket IO or use the ffi?
Use the FFI (see above).
Cheers,
Peter
--
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
is especially attractive, not only because it can be economically
and scientifically rewarding, but also because it can be an aesthetic
experience much like composing poetry or music."
-- Donald Knuth