gdhp g distributed hanoi protocol
play

GDHP g Distributed Hanoi Protocol NIIBE Yutaka - PowerPoint PPT Presentation

GDHP g Distributed Hanoi Protocol NIIBE Yutaka <gniibe@fsij.org> The Free Software Initiative of Japan p. 1 2005-11-08 IWFST 2005 Towers of Hanoi In 1893, invented by douard Lucas (Professor N. CLAUS). Good


  1. GDHP — ‘g’ Distributed Hanoi Protocol NIIBE Yutaka <gniibe@fsij.org> The Free Software Initiative of Japan – p. 1 2005-11-08 IWFST 2005

  2. Towers of Hanoi • In 1893, invented by Édouard Lucas (Professor N. CLAUS). • Good example to explain RECURSION . • With N disks, it requires 2 N − 1 steps. 0 ⇓ ⇒ 127 128 ⇓ 255 – p. 2 2005-11-08 IWFST 2005

  3. GDHP — ‘g’ Distributed Hanoi Protocol (1) • Three tasks correspond to three towers ( Source , Destination , and Auxiliary ), respectively. • Each task has a state: one of two directions ( Left or Right ). • Initially, all disks are on Source . • Initial direction of each towers: ◦ Destination faces to Source ◦ Auxiliary faces to Source ◦ Depending numbers of disks, Source faces to Destination (odd), or Auxiliary (even). – p. 3 2005-11-08 IWFST 2005

  4. GDHP — ‘g’ Distributed Hanoi Protocol (2) Main Routine: • Two tasks which face each other exchange a disk. ◦ Compare top of disks (No disk means ∞ ). ◦ The one with bigger disk wins, receives a disk from loser, and puts it onto the top. ◦ Two tasks change directions. Terminate condition: • Both of two tasks which face each other have no disk. – p. 4 2005-11-08 IWFST 2005

  5. GDHP in fugures – p. 5 2005-11-08 IWFST 2005

  6. Implementations of GDHP • POSIX Thread version with TTY ◦ http://www.gniibe.org/code/towers-of-hanoi.c • TCP/IP version with GTK+ ◦ http://www.gniibe.org/code/gtk-toh.scm • Friendly Game by Human Being ◦ Hanoi (March 2004) ◦ Tokyo (November 2004) ◦ Seoul (December 2004) ◦ Beijin (March 2005) ◦ Shanghai (November 2005) – p. 6 2005-11-08 IWFST 2005

Recommend


More recommend