16Tasks_2 - while we are executing the spin • We can use...

Info icon This preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Tasks: Advanced COMP106 The Problem You have set up a killer robot to patrol around the front door of your house. If the robot detects a visitor, it kills without mercy! Obviously, you don’t want the robot to veer off into different directions (or you’ll have very unhappy neighbours!)
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Solution 1 Looks reasonable Will this work? What’s Wrong? Routines interrupting each other, competing for resources (motors). Need a way to stop Patrol from running
Image of page 2
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: while we are executing the spin. • We can use start / stop. Solution 2 Not Ideal • Our robot will not patrol the same area. • We don’t want to start Patrol from the beginning every time. Solution 3 Semaphore • A semaphore is a global variable that indicates if a shared resource is being used • Other routines must wait until the shared resource is available • This is a standard technique used when dealing with shared resources....
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern