pkgsrc-Bugs archive

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

Re: pkg/41603 (Making ECL work with threads)



The following reply was made to PR pkg/41603; it has been noted by GNATS.

From: mmondor%pulsar-zone.net@localhost
To: gnats-bugs%netbsd.org@localhost
Cc: asau%netbsd.org@localhost
Subject: Re: pkg/41603 (Making ECL work with threads)
Date: Wed, 17 Jun 2009 03:06:56 -0400

 Updated diff to replace the initially proposed patch-aa against
 pkgsrc-2009Q1 and -current lang/ecl.  This also fixes the problem
 where non-joined threads were not being created in detached state,
 as well as unnecessary frequent attribute object creation/destruction.
 I'll look at the current ecl cvs code and also provide a diff for
 the ecl mailing list when I can.
 
 
 --- ./src/c/package.d.orig     2008-12-17 10:41:52.000000000 -0500
 +++ ./src/c/package.d  2009-06-16 10:26:24.000000000 -0400
 @@ -179,7 +179,7 @@
        {
        pthread_mutexattr_t attr;
        pthread_mutexattr_init(&attr);
 -      pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK_NP);
 +      pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
        pthread_mutex_init(&x->pack.lock, &attr);
        pthread_mutexattr_destroy(&attr);
        }
 --- ./src/c/threads.d.orig     2008-12-17 10:41:52.000000000 -0500
 +++ ./src/c/threads.d  2009-06-17 02:35:52.000000000 -0400
 @@ -36,6 +36,8 @@
  #endif
  
  static pthread_t main_thread;
 +static pthread_attr_t pthreadattr;
 +static pthread_mutexattr_t mutexattr_error, mutexattr_recursive;
  
  extern void ecl_init_env(struct cl_env_struct *env);
  
 @@ -231,7 +233,8 @@
        if (mp_process_active_p(process) != Cnil)
                FEerror("Cannot enable the running process ~A.", 1, process);
        THREAD_OP_LOCK();
 -      code = pthread_create(&process->process.thread, NULL, 
thread_entry_point, process);
 +      code = pthread_create(&process->process.thread, &pthreadattr,
 +          thread_entry_point, process);
        if (!code) {
                /* If everything went ok, add the thread to the list. */
                cl_core.processes = CONS(process, cl_core.processes);
 @@ -307,23 +310,19 @@
   */
  
  @(defun mp::make-lock (&key name ((:recursive recursive) Ct))
 -      pthread_mutexattr_t attr;
        cl_object output;
  @
 -      pthread_mutexattr_init(&attr);
        output = cl_alloc_object(t_lock);
        output->lock.name = name;
        output->lock.holder = Cnil;
        output->lock.counter = 0;
        if (recursive == Cnil) {
 -              pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK_NP);
                output->lock.recursive = 0;
 +              pthread_mutex_init(&output->lock.mutex, &mutexattr_error);
        } else {
 -              pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
                output->lock.recursive = 1;
 +              pthread_mutex_init(&output->lock.mutex, &mutexattr_recursive);
        }
 -      pthread_mutex_init(&output->lock.mutex, &attr);
 -      pthread_mutexattr_destroy(&attr);
        si_set_finalizer(output, Ct);
        @(return output)
  @)
 @@ -401,13 +400,10 @@
  cl_object
  mp_make_condition_variable(void)
  {
 -      pthread_condattr_t attr;
        cl_object output;
  
 -      pthread_condattr_init(&attr);
        output = cl_alloc_object(t_condition_variable);
 -      pthread_cond_init(&output->condition_variable.cv, &attr);
 -      pthread_condattr_destroy(&attr);
 +      pthread_cond_init(&output->condition_variable.cv, NULL);
        si_set_finalizer(output, Ct);
        @(return output)
  }
 @@ -493,13 +489,17 @@
  {
        cl_object process;
        struct cl_env_struct *env;
 -      pthread_mutexattr_t attr;
 +
 +      pthread_mutexattr_init(&mutexattr_error);
 +      pthread_mutexattr_settype(&mutexattr_error, PTHREAD_MUTEX_ERRORCHECK);
 +      pthread_mutexattr_init(&mutexattr_recursive);
 +      pthread_mutexattr_settype(&mutexattr_recursive,
 +          PTHREAD_MUTEX_RECURSIVE);
 +      pthread_attr_init(&pthreadattr);
 +      pthread_attr_setdetachstate(&pthreadattr, PTHREAD_CREATE_DETACHED);
  
        cl_core.processes = OBJNULL;
 -      pthread_mutexattr_init(&attr);
 -      pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK_NP);
 -      pthread_mutex_init(&cl_core.global_lock, &attr);
 -      pthread_mutexattr_destroy(&attr);
 +      pthread_mutex_init(&cl_core.global_lock, &mutexattr_error);
  
        process = cl_alloc_object(t_process);
        process->process.active = 1;
 


Home | Main Index | Thread Index | Old Index