Home > OS >  Why lock will degrade the performance of the program?
Why lock will degrade the performance of the program?

Time:10-03

I've read that before is to reduce lock performance degradation in multiple threads for locks, switching between kernel mode and user mode, want to ask is the switch? Lock is in the kernel of management?

CodePudding user response:

Should understand, so two threads with A lock, for example, when A call first lock, lock, and then is processed, then B, if want to use the lock, it must be A unlock can use, such as B is blocked at this time,

CodePudding user response:

Linux context switching cost is very big,

CodePudding user response:

Because red and green, like the road would stop and the car ran a red light, green light to continue running

CodePudding user response:

Upstairs say well, add the second floor says, switching occurs in block B occurs, B is the current thread is CPU, happened due to obstruction, therefore is B thread switching, CPU scheduling to another thread to perform again,

CodePudding user response:

Every request to take up a single thread, for example, when the request quantity is too large, the server design rules can run 1000 threads, when developed or request and at the same time, more than 1000 thread, and the system did not finish processing the request, the threads are exclusive, all threads that are more than 1000 will be queued, inverted thread plug,

CodePudding user response:

Unlock and thread switches are to be the system overhead
  • Related