static int construct_AtSpiScreen (void) { sem_t SPI_init_sem; sem_init(&SPI_init_sem,0,0); XInitThreads(); if (asyncCreateThread("driver-screen-AtSpi", &SPI_main_thread, NULL, asOpenScreenThread, (void *)&SPI_init_sem)) { logMessage(LOG_ERR,"main SPI thread failed to be launched"); return 0; } do { errno = 0; } while (sem_wait(&SPI_init_sem) == -1 && errno == EINTR); if (errno) { logSystemError("SPI initialization wait failed"); return 0; } logMessage(LOG_DEBUG,"SPI initialized"); return 1; }
static int serialStartFlowControlThread (SerialDevice *serial) { if (!serial->flowControlRunning && serial->currentFlowControlProc) { pthread_t thread; pthread_attr_t attributes; pthread_attr_init(&attributes); pthread_attr_setdetachstate(&attributes, PTHREAD_CREATE_DETACHED); serial->flowControlStop = 0; if (asyncCreateThread("serial-input-cts", &thread, &attributes, serialFlowControlThread, serial)) { logSystemError("pthread_create"); return 0; } serial->flowControlThread = thread; serial->flowControlRunning = 1; } return 1; }