chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fwd: Re: [Chicken-users] Question]


From: F. Wittenberger
Subject: [Fwd: Re: [Chicken-users] Question]
Date: Tue, 10 Jan 2006 12:15:10 +0100

Am Donnerstag, den 29.12.2005, 12:32 -0500 schrieb Raffael Cavallaro:
        
        > 
        > > but
        > > 
        > > separate processes might actually be a working alternative.
        ...
        > Gauche (gosh) does threads this way, as separate unix
        processes, which
        > is why I suggested it.
        
        I would be interested to read that code, but I'm unable to
        locate the
        spot.  All I found in the gauche code was the pthread-stuff.
        
        
        > > What we need
        > > 
        > > is some efficient method of exchanging data between
        processes.
        > > Perhaps
        > > 
        > > serialization over shared memory?
        
        It might depend on concern:  If you are behind SMP friendly
        threads that
        seems about the only way.  But if all you need is a way to call
        library
        which has synchronous  API's without blocking all other Scheme
        threads,
        it might more efficient to export some way to call back to
        Scheme from
        system threads.
        
        RScheme has such a feature: you pass some procedure to C code,
        which
        will pthread_create and run whatever eventually calling that
        procedure.
        I'm calling synchronous API's from a pool of pthreads like this:
        
        static void *
        worker_thread_loop(void *arg)
        {
          struct request_queue *q = arg;
          request_function_t function;
          void *data;
          obj callback;
          int result;
        
          while (1) {
        
            queue_receive(q, &function, &data, &callback);
            result = (*function)(data);
            pthread_mutex_lock(&rscheme_callback_mutex);
            rscheme_intr_call1(callback, int2fx(result));
            pthread_mutex_unlock(&rscheme_callback_mutex);
        
          }
          return NULL;
        }
        
        




reply via email to

[Prev in Thread] Current Thread [Next in Thread]