Linux threading performance is very fast under GDB but very slow otherwise

I am working on an embedded C ++ application running on Linux. I recently ran into some really weird performance issues with pthreads.

My system has 8 threads transmitting information back and forth, protected by mutex pthread lock. When running my application autonomously, thread performance is extremely difficult when locking a mutex. Mutex locking and unlocking ~ 200 times takes 2.4 seconds on a 500 MHz ARM board and longer on my 200 MHz board.

The strange thing is that when I run my application under GDB, the application runs very fast. The same block of code, which took 2.4 seconds autonomously, takes about 2 ms when starting GDB.

I tested this behavior on two different ARM-based servers: one that works with Linux 2.4.26 with gcc 3.4.4 and glibc 2.3.2, and the other with Linux 2.6.21 also with gcc 3.4.4 and glibc 2.3.2 .

After extensive testing, I suspect that the problem is with the pthreads library, which, as it turned out, is the same version on the tool chains of both boards. This would be unsuccessful since my SBC provider does not offer a very wide range of tools for its board, and I am afraid that everyone will have a problem. Does anyone have an idea of ​​what might lead to poor performance when working in GDB?

+3
source share
3 answers

pthreads ARM, , . , . , , .

, select

LinuxThreads NPTL ( "" )? , .

+3

, , - . , , ARM Intel.

"pthread_mutex_trylock()", "sched_yield()", , , . , - .

, , , "pthread_mutex_lock", .

+1

, , ? ? , gdb , - .

0

Source: https://habr.com/ru/post/1727308/


All Articles