Hello everybody.I have an exercise (kiwi engine) in university (OS course) and I have to use thread.
The code is big (10.000 lines) and I only have to use threads to make it faster.
In the following code if you can see a comment like: // <<<<<<<<<<<<<<<
it means that I have added this line(the other lines already exists).
So,as you can see below,I make an array of threads given in command line
If 2nd string is "readwrite" the program runs only this if statement.
So, I create a these threads to call _readwrite(...) function.
The _readwrite_test(...) lock a mutex to call function _write_test(...) ,unlock it and the do the same thing for _read_test(...)
These 2 functions write and read data from a data base
Do not pay attention what these function do.
Anyway,when I run gdb ,I recieve
Thread
2
"
kiwi-bench"
received signal SIGSEGV, Segmentation fault.
[Switching to Thread
0x7ffff78b1700
(LWP
53813
)]
__memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:306
306
../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S: No such file
or
directory.
Do not run the code(nothing will happen).
If I run only read_test or write_test all works fine.I think the problem is in the lock/unlock of mutex.
What can I do?What do you think?
I hope you understand what I want to do.
I need your help!!
Thank you very much.
What I have tried:
struct
vars
_readwrite_test, so you probably need to add the lock at the very beginning of the function, and the unlock at the very end. However, you still need to use the debugger to find out exactly where the segv occurs, as there is always the possibility that there is another cause.