Presentation is loading. Please wait.

Presentation is loading. Please wait.

DS420 Case study – a reference counting problem 1.0 Clark Elliott Instructor.

Similar presentations


Presentation on theme: "DS420 Case study – a reference counting problem 1.0 Clark Elliott Instructor."— Presentation transcript:

1 DS420 Case study – a reference counting problem 1.0 Clark Elliott Instructor

2 The Game Multi-player first-person shooter game. Interact with the Avatars of others Magical objects, such as dragons, can be created by the actions of one player, but interact with everyone. Users A,B,…Zn; Machines 1, 2, …n Objects reside on machine where they are created. Users “live” on one machine.

3 The Dragon Big green dragon with detailed graphics, complex physics, and full history-of- interaction: Expensive object When no one needs the dragon, make her go away to conserve resources

4 Scenario One (Users) A, B, C are playing the game on machines 1,2,3 B creates dragon. Dragon count is one, for B. A discovers dragon; dragon count is two. B cuts off dragon’s hind foot. A sees dragon with three feet.

5 One, cont. A gets roasted by dragon, and starts dying. A (on 1) sends message to dragon (on 2) “I am dead” Dragon count is one. A dies. B continues to interact with dragon All is well with scenario one.

6 Scenario Two (Users) A, B, C are playing the game on machines 1,2,3 B creates dragon. Dragon count is one, for B. A discovers dragon; dragon count is two, for A and B B cuts off dragon’s hind foot. A sees dragon with three feet.

7 Two, cont. A gets roasted by dragon, starts dying. A (on 1) sends message to dragon (on 2) “I am dead” but message gets lost Dragon count remains two. A dies. B gets killed by a falling anvil, and starts dying. B (on 2) sends message to dragon “I am dead” Dragon count is one. All users are dead, but dragon remains active – ouch!

8 Solution for two… Before dying, A waits for acknowledgment of death message. Message gets lost. No acknowledgment comes. A resends death message Dragon is decremented; sends ACK A gets ACK, dies.

9 But, suppose… Second message gets lost? Acknowledgment gets lost, so… –Second message is sent saying “I am dead” –Both first and second messages are received and the dragon is decremented twice. – Dragon count is set to zero, and dragon object is destroyed while B still has a reference to it…”Hey, where’s my dragon?”

10 Scenario Three (Users) A, B, C are playing the game on machines 1,2,3 B creates dragon. Dragon count is one, for B. A discovers dragon; dragon count is two, for A and B B cuts off dragon’s hind foot. A sees dragon with three feet.

11 Three – cont. A “tells” C about the dragon (passes the reference), but does not tell the dragon that C knows about the dragon. A and B die, dragon is decremented to zero, dragon object is destroyed to save resources. C says, “Hey, where’s my dragon?”

12 Some techniques Weighted reference counting, so know about someone being “told” about you. Messages have counters, and sender IDs. Never respond to a message with a lesser ID. Use a reliable message protocol. Do global, independent, garbage collection


Download ppt "DS420 Case study – a reference counting problem 1.0 Clark Elliott Instructor."

Similar presentations


Ads by Google