z****g 发帖数: 5 | 1 Consider this case,
....;
....;
p(semaphore);//Entering waiting state
How can I make sure the last line is executed immediately after preceding
lines?
Sometimes, OS will preempt the program just before the p(..) is executed and
resume the program later. This may cause bad race condition.
I appreciate any clues for solving this problem. Thanks a lot. | x******g 发帖数: 3952 | 2 I tend to think for a users mode app, there is no chance for you to
do this. Otherwise every user has the potential of locking up the
whole system.
If you can shorten your code and make sure they can be finished within
1 timeslice, you will very less likly be preempted.
【在 z****g 的大作中提到】 : Consider this case, : ....; : ....; : p(semaphore);//Entering waiting state : How can I make sure the last line is executed immediately after preceding : lines? : Sometimes, OS will preempt the program just before the p(..) is executed and : resume the program later. This may cause bad race condition. : I appreciate any clues for solving this problem. Thanks a lot.
| c*****t 发帖数: 1879 | 3
Huh? That means your code is not protected for critical conditions.
Re-write your code.
【在 z****g 的大作中提到】 : Consider this case, : ....; : ....; : p(semaphore);//Entering waiting state : How can I make sure the last line is executed immediately after preceding : lines? : Sometimes, OS will preempt the program just before the p(..) is executed and : resume the program later. This may cause bad race condition. : I appreciate any clues for solving this problem. Thanks a lot.
|
|