lock up if VVP is run concurrently
ink1 opened this issue · 0 comments
When two or more VVP processes are run concurrently they may all need to open the same background for memory mapping. For some reason the background is opened for read and write rather than for read only and this locks up the processes so everything just hangs.
I've identified the relevant bits of code here
https://github.com/Yandell-Lab/VVP-pub/blob/master/search_binary_bkgrnd.c#L20
https://github.com/Yandell-Lab/VVP-pub/blob/master/search_binary_bkgrnd.c#L24
and here
https://github.com/Yandell-Lab/VVP-pub/blob/master/search_binary_bkgrnd.c#L61
https://github.com/Yandell-Lab/VVP-pub/blob/master/search_binary_bkgrnd.c#L64
I've made a patch which seems to be working although I must admit I have not looked deep into the code.
20c20
< int fdSrc = open(bin_file, O_RDONLY, 0);
---
> int fdSrc = open(bin_file, O_RDWR, 0);
24c24
< mm_bin = (unsigned char *)mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE | MAP_POPULATE, fdSrc, 0);
---
> mm_bin = (unsigned char *)mmap(NULL, st.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fdSrc, 0);
61c61
< int fdSrc = open(bit_file, O_RDONLY, 0);
---
> int fdSrc = open(bit_file, O_RDWR, 0);
64c64
< mm_bits = (unsigned char *)mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE | MAP_POPULATE, fdSrc, 0);
---
> mm_bits = (unsigned char *)mmap(NULL, st.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fdSrc, 0);
Is write access really necessary?