В SDK производителя есть такая фукция:
Код: Выделить всё
Int Fifo_get(Fifo_Handle hFifo, Ptr ptrPtr)
{
printf("Starting %s\n", __FUNCTION__);
Int flush;
Int numBytes;
assert(hFifo);
assert(ptrPtr);
pthread_mutex_lock(&hFifo->mutex);
flush = hFifo->flush;
printf("Flush = %d\n", flush);
pthread_mutex_unlock(&hFifo->mutex);
if (flush) {
return Dmai_EFLUSH;
}
printf("numBytes = %d, size Ptr = %d\n", numBytes, sizeof(Ptr));
printf("read from fd %d\n", hFifo->pipes[0]);
numBytes = read(hFifo->pipes[0], ptrPtr, sizeof(Ptr));
printf("after read: numBytes = %d, size Ptr = %d\n", numBytes, sizeof(Ptr));
if (numBytes != sizeof(Ptr)) {
pthread_mutex_lock(&hFifo->mutex);
flush = hFifo->flush;
printf("Flush = %d\n", flush);
if (flush) {
hFifo->flush = FALSE;
}
pthread_mutex_unlock(&hFifo->mutex);
if (flush) {
return Dmai_EFLUSH;
}
return Dmai_EIO;
}
printf("numBufs = %d\n", hFifo->numBufs);
pthread_mutex_lock(&hFifo->mutex);
hFifo->numBufs--;
printf("numBufs = %d\n", hFifo->numBufs);
pthread_mutex_unlock(&hFifo->mutex);
return Dmai_EOK;
}
Описание фукции - Blocking call to receive a buffer pointer from a fifo.
Вызов printf вставил я для отладки, так как на вызове данной фукции программа "зависает".
Результат использование фукции:
# ./prog
Starting Fifo_get
Flush = 0
numBytes = 1074548884, size Ptr = 4
read from fd 5
Вопрос - что может вызыватать "зависание" read, думаю на read т.к. не вижу дальнейшей работы фукции, и как это можно решить?
Спасибо.