Languages and Scripting
Showing results for 
Search instead for 
Did you mean: 

Multithread mmap access problem

Bryan Strait

Multithread mmap access problem


I'm having some problems with multiple pthreads that are locked to processors accessing a file mapped with mmap() with MAP_SHARED, MAP_GLOBAL, and MAP_FILE flags. We're working with a 4 processor rx4640 system running HPUX 11.23.

The application involved has 4 total threads. Three of the threads are bound to processors 2, 3, and 4 with pset_bind. The application is also running at rtprio 0. The threads bound to processors are meant to run continuously without interruption. The fourth thread runs freely on processor 1.

The mmap'd files are large. The fourth unbound thread is mainly intended to perform the expensive unmap operations on the large files. The problem is this: When this fourth thread performs the unmap, the bound thread that was performing writes to the memory map gets kicked off the processor until the unmap is finished. Although top is not always a correct indicator, in this instance it shows this processor going to 0% until unmap is finished.

Is there a problem in the type of flags we're passing to the mmap call which is keeping the mmap from being in the global memory? The unbound thread seems to be running on the bound thread's processor in order to unmap the mapped file from that processor's address space. When this happens, the locked thread is kicked off the processor which is exactly what we're trying to prevent. Is there a way around this?

Thanks again in advance for the help. This has been a tough one.




Moved from HP-UX Technical Documentation to HP-UX > languages

Bryan Strait

Re: Multithread mmap access problem

I've given up on this issue, realizing now that with HPUX you just have to deal with the system having these huge delays. Now working with a custom memory map class which is working much better.