GDHP g Distributed Hanoi Protocol NIIBE Yutaka - - PowerPoint PPT Presentation

gdhp g distributed hanoi protocol
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

GDHP — ‘g’ Distributed Hanoi Protocol

NIIBE Yutaka

<gniibe@fsij.org>

The Free Software Initiative of Japan

2005-11-08 IWFST 2005 – p. 1

slide-2
SLIDE 2

Towers of Hanoi

  • In 1893, invented by Édouard Lucas (Professor N. CLAUS).
  • Good example to explain RECURSION.
  • With N disks, it requires 2N − 1 steps.

⇓ 127 ⇒ 128 ⇓ 255

2005-11-08 IWFST 2005 – p. 2

slide-3
SLIDE 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).

2005-11-08 IWFST 2005 – p. 3

slide-4
SLIDE 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.

2005-11-08 IWFST 2005 – p. 4

slide-5
SLIDE 5

GDHP in fugures

2005-11-08 IWFST 2005 – p. 5

slide-6
SLIDE 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)

2005-11-08 IWFST 2005 – p. 6