YouTube

Got a YouTube account?

New: enable viewer-created translations and captions on your YouTube channel!

English subtitles

← 03-26 Synchronization Coverage

03-26 Synchronization Coverage

Get Embed Code
1 Language

Showing Revision 2 created 07/16/2014 by Udacity Robot.

  1. Another kind of coverage that we might look for is going to be inspired by what happened
  2. after we fix this x fer function and so the likely fixed for the bug that we had in this x fer function
  3. is to lock both of the bank accounts that we're processing, transfer
  4. the balance between them, and then unlock the accounts.
  5. And what this will do is make sure that no other threads in the system are messing
  6. with the two accounts that we're updating while in the middle of the messing with them.
  7. Now one thing that people are found is while testing this concurrent software.
  8. If this often the case, you can delete all of the locks out of a code,
  9. run it through some tests, and often it passes.
  10. This is really a sort of a scary and depressing thing because what this means is that
  11. during the test suite the locks weren't doing anything.
  12. This is in spite of the test coverage metric called synchronization coverage.
  13. What synchronization coverage is going to do is ensure that
  14. during testing this lock actually does something.
  15. In other words, during testing, the x fer function is going to be called to transfer
  16. money between accounts when the accounts are already locked and what this does is ensure that
  17. we're stressing the system to a level that the synchronization code is actually firing.
  18. It's actually having some effect on the execution and if that's happening what that means is
  19. we're probably doing a reasonable job stress testing the system.
  20. So that was really quick and like I said we're not getting into some detail.
  21. In summary, if we're testing concurrent software, we want to be looking at
  22. concurrency-specific coverage metrics such as interleaving coverage which meant
  23. if you recall functions which accessed shared data are actually called and in a truly
  24. concurrent fashion that is by multiple threads at the same time.
  25. And also synchronization coverage which ensures
  26. that the locks that we put into our code actually do something.