[Openmcl-devel] using pthreads from openmcl

Taoufik Dachraoui taoufik.dachraoui at wanadoo.fr
Wed Mar 26 17:22:50 UTC 2003


Hi,

I tried process-run-function but the process blocks at XNextEvent, and this is not what I am looking for.

So I decided to use pthreads from openmcl. I did the following:

? (setq y nil)
? (defcallback xmain () (setq y t))
? (setq thread (ccl::make-record :pthread_t))
? (#_pthread_create thread (%null-ptr) xmain (%null-ptr))
0
? Trace/BPT trap
>

Why do I get the Trace/BPT trap? 

The Trace/BPT trap do not occur all the times, sometimes the callback function is called by the pthread and sets y to t.

The idea is to define a callback xmain function that uses xlib functions. xmain will use XNextEvent (a blocking function).

The reason I am not using CLX is that I feel that I will learn more by trying from scratch to implement a framework for developing X Window programs using openmcl, this way I feel that I am learning more about common lisp and openmcl in particular.

/////////////////////////////////////////////////////////////
Function: pthread_create() 
#include <pthread.h>

int pthread_create(pthread_t * thread, const pthread_attr_t * attr,
        void * (*start_routine)(void *), void * arg); 

The pthread_create() routine creates a new thread within a process. The new thread starts in the start routine start_routine which has a start argument arg . The new thread has attributes specified with attr , or default attributes if attr is NULL. 

If the pthread_create() routine succeeds it will return 0 and put the new thread id into thread , otherwise an error number shall be  returned indicating the error. 


_______________________________________________
Openmcl-devel mailing list
Openmcl-devel at clozure.com
http://clozure.com/cgi-bin/mailman/listinfo/openmcl-devel



More information about the Openmcl-devel mailing list