Home > Back-end >  The operating system
The operating system

Time:09-15

There are two concurrent execution process, the procedure is as follows, can perform well? If not, why?

CodePudding user response:

For help, you great spirit is a small life

CodePudding user response:

X is the critical resource, each process add a protection lock

CodePudding user response:

I the most headache is multithreaded, but, according to common sense, a variable two processes used at the same time, you make me once, what it must, I think it is a problem for certain,

CodePudding user response:

1, the concurrent execution of process, can be performed at the same time, no problem!

2, the concurrent execution of thread, can also be performed at the same time, is x may be random

CodePudding user response:

First question is whether correct, shows that it is impossible to perform correctly (in the case of parallel execution),
Correct word is critical resources, thread lock,

CodePudding user response:

Is upstairs said several, x has a problem, cannot obtain reliable results

CodePudding user response:

The answer is obviously not, because at the same time use the public variables X, (in the case of abnormal queuing system error) such as execution of public variables X into the lock, when operating P1 to X, P2 unable to X, if not to lock the X when the execution, P1, P2 value assigned to X will influence each other, the inside of the solution is to change the X to local variables, or add a X1 P2 use,

And, of course, so long didn't knot stick, estimate answered also useless,
  • Related