COMP 346

Tip for taking the course with Todd Eavis:

The multiple choice questions are not trick questions. They are very straightforward. Your first instinct is probably the correct answer (don’t overthink it). Be sure to read each slide carefully – many questions will be based on small relatively obscure (but not useless) facts.

Cram Flashcard for this course (created by me. You’re welcome):

How test_and_set works

test_and_set is really simple but presented in a confusing way. The test_and_set function simply always changes a global value (call it flag) to True, and returns what it was before it changed it to True. If it was already True, great, it stays True. The beauty of this is that you can create a while loop that is waiting for flag to be False so it can move out of the while loop. The test_and_set function detects that flag is false, immediately changes it to True so other processes will see it is claimed and stay in their lousy while loops, and our process can break out of its while loop and move on. Of course, when our process is done, it sets flag to False so another test_and_set can report that it is was False.

From Around The Web:

Midterms from NYU

Leave a comment