Updated: 11/5/2005; 6:05:40 PM.
Chris Double's Radio Weblog
        

Wednesday, March 24, 2004

Patrick Logan is writing about a Kali-like mechanism for Stackless Python. Mention is made of being able to migrate tasks to a different machine where they can be unpacked and resumed.

I've updated my previous Sisc Scheme example of sending continuations to another machine to include migrating tasks. The 'ping-pong' example looks like:

(define (ping-pong)
  (let loop ()
    (display "ping\n")
    (sleep 1000)
    (migrate-thread "127.0.0.1" 9002)
    (display "pong\n")
    (sleep 1000)
    (migrate-thread "127.0.0.1" 9003)
    (loop)))

This starts on one machine, displays 'ping', migrates the thread to another machine, writes 'pong' then goes back to the original machine and continues forever. This can be started on a machine with:

  (spawn-thread-on "127.0.0.1" 9003 ping-pong)

You can download the code from file remote-send.scm. This updated code also includes optionally compressing the continuation as it is serialized (turned on by default).

What 'migrate-thread' does is capture a continuation and sends that continuation over to the other machine where is is restarted. The running thread on the original machine is then terminated:

(define (migrate-thread host port)
  (call/cc
   (lambda (k)
     (send host port k)
     ((exit-function)))))

10:26:59 AM      

© Copyright 2005 Chris Double.
 
March 2004
Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Feb   Apr



Click here to visit the Radio UserLand website.

Listed on BlogShares

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.