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

Info iconThis 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!)
Background image of page 1

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

View Full DocumentRight 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
Background image of page 2
Background image of page 3

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

View Full DocumentRight Arrow Icon
Background 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 dont 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

Page1 / 4

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

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online