I am working on user space for an embedded Linux project using the 2.6.24.3 kernel. My application transfers data between two file nodes, creating 2 pthreads, each of which falls asleep until the asynchronous I / O operation completes, after which it wakes up and starts the completion handler.
Completion handlers should keep track of how many hypotheses are waiting and supporting multiple linked lists that one thread will add and the other will be deleted.
for(;;) {
no_of_events = io_getevents(ctx, 1, num_events, events, &timeout);
for (i=0; i<no_of_events; i++) {
io_complete = (io_callback_t) events[i].data;
iocb = (struct iocb *) events[i].obj;
io_complete(ctx, iocb, events[i].res, events[i].res2);
}
}
My question is ...
Is there an easy way to prevent interference in the current active thread while it starts the completion handler, instead of lowering the mutex / spin route?
, , Linux , pthread mutex/spin?