Can I prevent the use of pythread for a Linux user in critical code?

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.

// sleep here until events arrive or time out expires
for(;;) {
    no_of_events = io_getevents(ctx, 1, num_events, events, &timeout);
    // Process each aio event that has completed or thrown an error
    for (i=0; i<no_of_events; i++) {
        // Get pointer to completion handler
        io_complete = (io_callback_t) events[i].data;
        // Get pointer to data object
        iocb = (struct iocb *) events[i].obj;
        // Call completion handler and pass it the data object
        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?

+5
3

sched_setscheduler(), SCHED_FIFO, . sched_setscheduler() man:

A SCHED_FIFO , -, , sched_yield(2).

( "" "" ).

. , ? , - . , , , .

+4

, /, . , , . , .

+1

, Linux , .

The correct solution is to use a mutex to prevent parallel execution handlers from working. Let the planner do the work.

+1
source

All Articles