0

When locking and unlocking mutexes ( Im using pthread mutexes ) will there be any context switch to kernel which degrades the performance.

Chandu
  • 1,837
  • 7
  • 30
  • 51
  • heres a lot of information: http://stackoverflow.com/questions/8639150/is-pthread-library-actually-a-user-thread-solution – fredcrs Feb 18 '13 at 11:50
  • 1
    Maybe. There may also be context switches to the kernel that improve performance. Depends on lock time, contention-chance, number of cores etc. Design/code/environment dependent. We have no code or typical data, so we cannot know. If you're that bothered, you should do some testing. – Martin James Feb 18 '13 at 12:45

1 Answers1

0

About all you can count on is that the implementation will likely try to make the overhead as little as possible. The better thing to worry about in your code is to make sure you keep lock contention to a minimum so that Mutex overhead is not a bottleneck in your code.

Randy Howard
  • 2,165
  • 16
  • 26