Subject: Re: Threads in ECoLisp

From: Giuseppe Attardi <[email-masked]>
Date: Thu, 7 May 1998 12:16:29 +0200

Date: Tue, 28 Apr 1998 14:41:11 -0700 (PDT)
   Reply-To: [email-masked]
   Originator: [email-masked]
   From: François GIRAULT <[email-masked]>

   Hi,

   I am usng the threads for the first time, also I have some problems.
   (I am using the ECoLisp implementation of CLisp.)

   I want to create a class foo with two fields :
	   <num> : the label of the object
	   <cpt> : an integer increase regulary

   And I want to put the method "executer" in thread. 

   Here is the program :

   |
   |(defclass foo ()
   |  ((num :initform 0 :initarg :num)
   |   (cpt :initform 0 :initarg :cpt))
   |  )
   |
   |(defmethod executer ((oself foo))
   |  (loop
   |   (format t "num : ~a     cpt : ~a~%" (slot-value oself 'num)
   |(slot-value oself 'cpt))
   |   (setf (slot-value oself 'cpt) (+ 1 (slot-value oself 'cpt)))
   |   ))
   |
   |
   |(defun test ()
   |  (setf t1 (make-instance 'foo :num 1))
   |  (setf t2 (make-instance 'foo :num 2))
   | 
   |  (setf th1 (make-thread #'executer))
   |  (setf th2 (make-thread #'executer))  
   |
   |  (setf cont1 (make-continuation th1))
   |  (setf cont2 (make-continuation th2))
   |
   |  (resume cont1 t1)
   |  (resume cont2 t2)
   |)

   And this is the error message

   |> (test)
   |#<thread #<dispatch-function EXECUTER> 08251aa8>
   |> Error: Segmentation violation.
   |       Wrong type argument to a compiled function.
   |       Signalled by an anonymous function.
   |;;; Warning: Clearing input from *debug-io*
   |Error: 1 is an illegal ihs index.
   |       Signalled by an anonymous function.
   |Broken at NIL.
   |>> 

   Could anyone help me ?

You should tell me which machine and OS you are using.
Your example works for me on Linux 2.0.32 and Solaris 5.3.

-- Beppe