Hi, in the LCDproc project we have a driver which uses pthread_create to spin off a new thread. For a reason I don't understand, that call does never returns neither success nor any error.
Even threading code that does work well as a standalone program does not work when copied into the driver, which is a shared library.
The file in question can be found here: http://lcdproc.cvs.sourceforge.net/viewvc/lcdproc/lcdproc/server/drivers/lis.c
The thread's start_routine is at line 290 (lis_read_thread) and the thread creation is at line 514, copied here for reference (but please look at the complete file linked to above):
The start_routine should probably use pthread_exit and may be wrong by trying to return an int, but that's not the question here.
Please, have a look at it and help us getting this to work on FreeBSD. Thank you!
System is FreeBSD 7.3-RELEASE.
Additionally I found that other drivers linked against pthread do not work, e.g. xosd:
http://lcdproc.cvs.sourceforge.net/viewvc/lcdproc/lcdproc/server/drivers/xosdlib_drv.c
Even threading code that does work well as a standalone program does not work when copied into the driver, which is a shared library.
The file in question can be found here: http://lcdproc.cvs.sourceforge.net/viewvc/lcdproc/lcdproc/server/drivers/lis.c
The thread's start_routine is at line 290 (lis_read_thread) and the thread creation is at line 514, copied here for reference (but please look at the complete file linked to above):
Code:
int
lis_read_thread(void *arg)
{
Driver *drvthis;
PrivateData *p;
char unsigned buffer[64];
int size;
drvthis = (Driver *)arg;
p = (PrivateData *) drvthis->private_data;
while(! p->child_flag) {
for (size = ftdi_read_data(&p->ftdic, buffer, 64); size > 0; size = ftdi_read_data(&p->ftdic, buffer, 64))
;
if (size < 0) {
p->parent_flag = 0;
return size;
}
}
p->parent_flag = 0;
return 0;
}
// Later in init...
// create a thread to keep a read up on the device
err = pthread_create( &read_thread,
NULL,
(void *) lis_read_thread,
drvthis
);
if (err) {
report(RPT_ERR, "%s: pthread_create() - %s", drvthis->name, strerror(err));
goto err_framebuf;
}
report(RPT_INFO, "%s: read thread created");
p->parent_flag = 1; // show we're now a happy parent, birth successful.
The start_routine should probably use pthread_exit and may be wrong by trying to return an int, but that's not the question here.
Please, have a look at it and help us getting this to work on FreeBSD. Thank you!
System is FreeBSD 7.3-RELEASE.
Additionally I found that other drivers linked against pthread do not work, e.g. xosd:
http://lcdproc.cvs.sourceforge.net/viewvc/lcdproc/lcdproc/server/drivers/xosdlib_drv.c