SlideShare ist ein Scribd-Unternehmen logo
1 von 82
Downloaden Sie, um offline zu lesen
Using Python 3 to Build a
Cloud Computing Service for
      my Superboard II
           David Beazley
     (http://www.dabeaz.com)

     Presented at PyCon 2011
             Atlanta
Note: This talk involves a number of live
demonstrations. You will probably enjoy
 it more by watching the PyCon 2011
           video presentation

    http://pycon.blip.tv/file/4878868/
It Begins

            (Drumroll...)
Byte Magazine, January, 1979
Personal History

• Superboard II was my family's first computer
• What I first learned to program (~1979)
• It had everything that a kid could want
Easy Setup!
Peripherals!
Potentially Lethal Suggestions!
Schematics!
You could get
                an electric
                  shock
 You could
look inside!
Pure Awesome!
           You could program
Pure Awesome!
            You could hack!




                   Note the
                encouragement
Backstory

• 1982-2010. Superboard sits in mom's basement
• July 2010. Eric Floehr mentions SB at Scipy
• August 2010. Brother brings SB to Chicago
• It still works! (to my amazement)
Question
• What do you do with an old Superboard II
   • 1 Mhz 6502 CPU
   • 8K RAM
   • 8K Microsoft Basic (vers. 1.0)
   • 300 Baud Cassette Audio Interface
   • 1K Video Ram (24x24 visible characters)
• Not a modern powerhouse
TO THE CLOUD!
HOW?
(with Python 3 awesomeness of course)
     (plus some ØMQ and Redis)
     (and some 6502 assembler)
Getting to the Cloud
        This is the only I/O
         A pair of RCA audio jacks
         Used for cassette tape storage
         Not too promising
A Possible Solution
Cassette Interface
         • Behind the RCA jacks,
           sits a real serial "port"
         • Motorola 6850 ACIA
         • Ports are a 300 baud
           audio stream encoded
           via Kansas City Standard
         • Might be able to hack it
Byte, Feb. 1976
Python Audio Processing

• pyaudio
• http://http://people.csail.mit.edu/hubert/pyaudio/
• A Python interface to the portaudio C library
• Allows real-time access to audio line in/out
• I ported it to Python 3
Reading Audio Input
import pyaudio
p = pyaudio.PyAudio()
stream = p.open(format=pyaudio.paInt8,
                channels=1,
                rate=9600,
                chunksize=1024,
                input=True)
while True:
    sample = stream.read(1024)
    process_sample(sample)
Building a Python Modem
               writer thread
             pyaudio    byte
              writer   encoder
                                  TCP
                                              client
                                 socket
             pyaudio    byte
             reader    decoder
               reader thread

• A network socket bridged to two real-time
  audio encoding/decoding threads
KCS Audio Encoding
            0=                   1=

 (4 cycles @ 1200 Hz)           (8 cycles @ 2400 Hz)

                 'A' = 0x41 (01000001)

  0     0    1     0    0   0      0     0   1   1     1


start                    data                     stop
KCS Audio Decoding

                                      samples (8-bit)
89, 103, 117, 151, 194, 141, 99, 64, 89, 112, 141, 203, 152, 107, 88, ...

                                      sign bits (0 = neg, 1= pos)
000111000111000111000111000111111000000111111000000111111000000111111...

                                      sign changes (XOR adjacent bits)
0001001001001001001001001001000001000001000001000001000001000001000001...



Idea: Each 1 bit represents a 0-crossing
Example Code
def generate_sign_change_bits(stream):
    previous = 0
    while True:
       samples = stream.read(CHUNKSIZE)
        # Emit a stream of sign-change bits
        for byte in samples:
            signbit = byte & 0x80
            yield 1 if (signbit^previous) else 0
            previous = signbit
KCS Bit Decoding
            idle (constant 1)                    1 0 11 0 0 0 0



                                            start        data byte       stop
Sign Change Bits               push
1001001001001001001001001001          1001001001001001       discard
                                      Sample buffer (size = audio samples for 1 bit)

                   ~ 8 sign changes                 ~ 16 sign changes

                          0                                 1
Example Code
from collections import deque

# Sample buffer
sample = deque(maxlen=SAMPLES_PER_BIT)

for b in generate_sign_change_bits(stream):
    sample.append(b)
    nchanges = sum(sample)
    if nchanges < 10:
         # Detected a start bit
         # Sample next 8 data bits
         ...

  (The actual code is more optimized)
Demo
  My Mac (linked via audio)
Interlude
• It's Alive!




• Basic communication is just the start!
This is uploading machine code
~500 lines of 6502 assembler
   ...
   getvar_copy_string:
   !   ;; Move the variable address to INDIRECT where we c
   !   LDA![0x95, Y]! ; Length
   !   STA!%MEM_LENGTH
   !   INY
   !   LDA![0x95, Y]! ; address (low)
   !   STA!%INDIRECT
   !   INY
   !   LDA![0x95, Y]! ; address (high)
   !   STA!%INDIRECT+1
   !   LDY!#0x00
   ...



 Wrote a 6502 assembler
 ~500 lines of Python 3
Under the covers
This is uploading machine code
    msgdrv.asm
~500 lines of 6502 .1C00/20
                    assembler
 asm6502.py                   05
     ...                      AE
     getvar_copy_string:      EE
     !   ;; Move the variable address to INDIRECT where we c
                              1E
     ! msgdrv.hex Y]! ; Length
         LDA![0x95,           1E
     !   STA!%MEM_LENGTH      AD
     !   INY                  1E
     !   LDA![0x95, Y]! ; address (low)
                              1E
     !   STA!%INDIRECT        8D
     !   INY
     ! pymodem Y]! ; address (high)
         LDA![0x95,
     !   STA!%INDIRECT+1
     !   LDY!#0x00
     ...



 Wrote a 6502 assembler
 ~500 lines of Python 3
Messaging Driver code
           Under the covers
This is uploading machine
                       request
      msgdrv.asm
~500 lines of 6502 .1C00/20 Client
 Superboard II   control assembler

 asm6502.py                   05
     ...                      AE

• Superboard issues requests
     getvar_copy_string:
     !
     ! msgdrv.hex Y]! ; Length
         LDA![0x95,
                              EE
         ;; Move the variable address to INDIRECT where we c
                              1E
                              1E

• Client responds and gets control
     !
     !
     !
         STA!%MEM_LENGTH
         INY
                              AD
                              1E
         LDA![0x95, Y]! ; address (low)
                              1E


• Driver coexists with BASIC
     !   STA!%INDIRECT        8D
     !   INY
     ! pymodem Y]! ; address (high)
         LDA![0x95,
     !   STA!%INDIRECT+1
    1024LDY!#0x00 message driver
     !    bytes
     ...



 Wrote a 6502 Workspace
  7168 bytes BASIC
                   assembler
 ~500 lines of Python 3
Example of makingcovers
              Messaging Driver code
               Under the a request
This is uploading machine
                        request
           10 A = 96
       msgdrv.asm
~500 lines
  Superboard II of 6502 assembler
                        control          Client
 asm6502.py
           20 B = 42            .1C00/20
                                05
     ...                        AE

• SuperboardY]!issues1Erequests
     getvar_copy_string: = "FOO"
     !
     !
           30 the variable address to INDIRECT where we c
         ;; Move
       msgdrv.hex
                  C$
           40 S =; Length
         LDA![0x95,
                                EE


                             USR(37)
                                1E

• Client responds and gets control
     !
  Client
     !
     !
         STA!%MEM_LENGTH
         INY

          control
                             1E
                                AD

         LDA![0x95, Y]! ; address (low)
                             1E


• Driver coexists- Get a BASIC region
     !   STA!%INDIRECT       8D
     !   INY
      PEEK         with memory
     ! pymodem Y]! ; address (high)
         LDA![0x95,
     !
     !   POKE      - Set a memory region
         STA!%INDIRECT+1
    1024LDY!#0x00 message driver
          bytes
     ...
         GET       - Get a BASIC variable
         SET       - Set a BASIC variable
  Wrote a 6502 -Workspace to BASIC
         RETURN assembler
   7168 bytes BASIC Return

  ~500 lines of shared memory!
   Distributed Python 3
Messaging Architecture
• There are two parts (driver and a client)
   superboard                                             message client
    message
     driver             audio                    socket
                                       pymodem

  BASIC                                                   Python 3


• Uses a binary message protocol
    USR(37) : x20 x06 x01 x25 x00 x02

          Command Size Seq      Data       LRC

 • Protocol details not so interesting
Message Driver
• Interacts directly with Microsoft BASIC
   • Uses "Undocumented" ROM routines
   • Accesses BASIC interpreter memory
• For this, some resources online
   • http://osiweb.org
Client Architecture
• Client bridges Superboard II to the outside world
• Uses ØMQ (http://www.zeromq.com)
• And pyzmq (http://github.com/zeromq/pyzmq)
                           Message client   Services

audio             socket
        pymodem                       ØMQ

                           Python 3
Request Publishing
 • Requests are broadcast on a ØMQ PUB socket
 • Retransmitted every few seconds if no response
            Message client
USR(37)        ØMQ PUB       "37 1"   "37 1"   "37 1"   ... To the
                                                          "Cloud"


            Python 3




 • Requests include the USR code and a sequence #
Service Subscription
• Services simply subscribe to the request feed
   import zmq
   context = zmq.Context()
   requests = context.socket(zmq.SUB)
   requests.connect("tcp://msgclient:21001")
   requests.setsockopt(zmq.SUBSCRIBE,b"37 ")

• Now wait for the requests to arrive
   while True:
       request = requests.recv()


• Clients are separate programs--live anywhere
Request Response
 • Message client has a separate ØMQ REP socket
 • Used by services to respond
            Message client
USR(37)        ØMQ PUB       "37 1"

 driver        ØMQ REP                        Service
                              commands   (subscribed to 37)
            Python 3




 • Service initially acks by echoing request back
 • On success, can issue more commands
Command Connection
• Setting up the command socket
   commands = context.socket(zmq.REQ)
   commands.connect("tcp://msgclient:21002")

• Complete request/response cycle
   while True:
       request = requests.recv()
       commands.send(request)    # Echo back
       resp = commands.recv()
       if resp[:2] == b'OK':
           # In control of Superboard
           # Do evil stuff
           ...
Commands
• Commands are just simple byte strings
    b"RETURN VALUE"
    b"PEEK ADDR SIZE"
    b"POKE ADDR DATA"
    b"GET VARNAME"
    b"SET VARNAME VALUE"

• Response codes
    b"OK DATA"
    b"FAIL MSG"
    b"IGNORE"
    b"BUSY"
Interactive Demo
>>> request_sock.recv()
b'37 1'
>>> command_sock.send(b'37 1')
>>> command_sock.recv()
b'OK'
>>> command_sock.send(b'GET A')
>>> command_sock.recv()
b'OK 96.0'
>>> command_sock.send(b'GET B')
>>> command_sock.recv()
b'OK 42.0'
>>> command_sock.send(b'SET Q 2')
>>> command_sock.recv()
b'OK'
>>> command_sock.send(b'SET R 12')
>>> command_sock.recv()
b'OK'
>>> command_sock.send(b'RET 0')
>>> command_sock.recv()
b'OK'
>>>
Big Picture
               Message client
                                Up to 65536 Service IDs (N)
               ØMQ PUB
      USR(N)
                ØMQ REP




                                                       Big Iron


• Services can live anywhere
• Written in any language
• No real limit except those imposed by ØMQ
Superboard Emulation
• I dumped the BASIC and system ROMS
• Loaded them into Py65
• Py65 : A 6502 Emulator Written in Python
      https://github.com/mnaberez/py65

• Work of Mike Naberezny
• I ported it to Python 3
Emulation in 60 Seconds
               You start with the
             Superboard II memory
                map (provided)
Emulation in 60 Seconds


                  You identify
               hardware devices
Emulation in 60 Seconds
                   You read
               (about keyboards)
Emulation in 60 Seconds
                   You read
               (about video ram)
Emulation in 60 Seconds
                    You read
               (about ACIA chips)
Emulation in 60 Seconds
Then you just plug it into py65 (sic)
 def map_hardware(self,m):
         # Video RAM at 0xd000-xd400
         m.subscribe_to_write(range(0xd000,0xd400),
                              self.video_output)

         # Monitor the polled keyboard port
         m.subscribe_to_read([0xdf00], self.keyboard_read)
         m.subscribe_to_write([0xdf00], self.keyboard_write)

         # ACIA Interface
         m.subscribe_to_read([0xf000], self.acia_status)
         m.subscribe_to_read([0xf001], self.acia_read)
         m.subscribe_to_write([0xf001], self.acia_write)

         # Bad memory address to force end to memory check
         m.subscribe_to_read([0x2000], lambda x: 0)
Interactive Demo
Question


• What do you do with an emulated Superboard?
A Superboard Cloud
                         10 PRINT "I WILL THINK OF A"
                         15 PRINT "NUMBER BETWEEN 1 AND
                         100"
                         20 PRINT "TRY TO GUESS WHAT IT IS"
                         25 N = 0
                         30 X = INT(RND(56)*99+1)
                         35 PRINT
                         40 PRINT "WHATS YOUR GUESS   ";
                                                                             Program
                                                                              Storage
                         50 INPUT G



                                                    10 PRINT "HELLO WORLD"
                                                    20 END
                    10   FOR I = 1 TO 1000
                    20   PRINT I
                    30   NEXT I
                    20   END




       Cloud
                                                              Datastore
       Service



                                                                               Stored
                                                                              Instances
                                                                             (images of
                                                                               running
     Virtualized                                                             machines)
  Superboard CPUs
Building The Cloud
• I built it using Redis (http://redis.io)
• Ported py-redis to Python 3
• Redis is cool
     • Can use it as a key-value store
     • Has other data structures (sets, hashes, etc.)
     • Queuing
     • Atomic operations
Redis Example
import redis
db = redis.Redis()

# Key-value store
db.set('foo',data)
data = db.get('foo')

# Queuing
db.lpush('queue',work)
work = db.brpop('queue')
Superboard Cloud Features
  • Remote program store
     • Load/save programs
  • Instance creation
     • Creation
     • Run with input
     • Distributed shared memory
  • It must be usable from the Superboard II
Program Load/Store
BASIC
strings

               msg          cloud    set
              driver       service   get
program                                    redis
settings


• BASIC program & workspace memory
  directly manipulated by the message driver
• Stored in Python object and pickled to Redis
Instances
• Instances are a running Superboard
   • 8K Program Memory
   • 1K Video RAM
   • Stored CPU context (registers, etc.)
• Stored in a Python object
• Pickled to Redis when inactive
Instance Execution
• "Runner" programs watch a Redis queue
   import redis
   r = redis.Redis()
   ...
   while True:
        work = r.brpop("queue")    # Wait for work
        ...
        inst = load_instance() # Get instance
        run_emulation(work)     # Run emulation
        save_instance(inst)     # Save instance


• Based on supplying keyboard input to SB
• Instance runs until no more input available
Instance Concurrency
• Can have arbitrary number of runners
                       Redis



                               Runners



• Asynchronous execution (w/ Superboard)
• Uses Redis setnx() for locking
import superboard as skynet
             pymodem
                        Up to 65536 Service IDs (N)
            ØMQ PUB

            ØMQ REP



                                                             Big Iron
                                     Cloud
                                     Service
                                                                    programs
                                                    10 PRINT "I WILL THINK OF A"
                                                    15 PRINT "NUMBER BETWEEN 1 AND

      Virtualized                                   100"
                                                    20 PRINT "TRY TO GUESS WHAT IT IS"
                                                    25 N = 0


   Superboard CPUs
                                                    30 X = INT(RND(56)*99+1)
                                                    35 PRINT
                                                    40 PRINT "WHATS YOUR GUESS   ";


                                      redis
                                                    50 INPUT G



                                                                               10 PRINT "HELLO WORLD"
                                                                               20 END


             Stored                            10
                                               20
                                               30
                                                    FOR I = 1 TO 1000
                                                    PRINT I
                                                    NEXT I


            Instances
                                               20   END
WHY?!
Non-Answer


• I don't actually want to use my Superboard II
• It's awful!
• It was painful even in 1980
A Better Answer
• For fun
• Also to create a glorious mess!
• Everything a systems hacker could want!
     • Hardware, device drivers, signal
       processing, protocols, networks, message
       passing, threads, synchronization,
       debugging, software design, testing,
       deployment, etc.
• Awesome!
Real Answer : Python 3

• Can Python 3 be used for anything real?
• I needed to check it out myself
• On a non-trivial project with many moving parts
• And with a variety of library dependencies
Lessons Learned

• You can use Python 3 to do real work
• However, it’s bleeding edge
• You really have to know what you’re doing
• Especially with respect to bytes/unicode
• Must be prepared to port and/or patch
Porting Experience

• py65 (easy, some bytes issues)
• pyredis (easy, bytes/unicode issues)
• pypng (hard, really messy I/O)
• pyaudio (hard, C extensions)
• pyzmq (worked, Cython patch for Py3.2)
Finding Python 3 Code

• Every single package I used was downloaded
  from development repositories (github,
  subversion, etc, etc)
• You can often find Python 3 compatible
  libraries in project forks or issue trackers if
  you look for it
My Thoughts
• Python 3 is cool
• It keeps getting better
   >>> import numpy
   >>>

• It’s different and fun
• It might be a great language for distributed
  computing, messaging, and other applications
That’s All Folks!
• Thanks for listening!
• Look for the “Python
  Cookbook, 3rd” edition
  in late 2011!
• More info on my blog
• http://www.dabeaz.com

Weitere ähnliche Inhalte

Was ist angesagt?

pa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text Processingpa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text ProcessingRodrigo Senra
 
Pydiomatic
PydiomaticPydiomatic
Pydiomaticrik0
 
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Charles Nutter
 
Multiprocessing with python
Multiprocessing with pythonMultiprocessing with python
Multiprocessing with pythonPatrick Vergain
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?Doug Hawkins
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesCharles Nutter
 
Threads and Callbacks for Embedded Python
Threads and Callbacks for Embedded PythonThreads and Callbacks for Embedded Python
Threads and Callbacks for Embedded PythonYi-Lung Tsai
 
Python Brasil 2010 - Potter vs Voldemort - Lições ofidiglotas da prática Pyth...
Python Brasil 2010 - Potter vs Voldemort - Lições ofidiglotas da prática Pyth...Python Brasil 2010 - Potter vs Voldemort - Lições ofidiglotas da prática Pyth...
Python Brasil 2010 - Potter vs Voldemort - Lições ofidiglotas da prática Pyth...Rodrigo Senra
 
sizeof(Object): how much memory objects take on JVMs and when this may matter
sizeof(Object): how much memory objects take on JVMs and when this may mattersizeof(Object): how much memory objects take on JVMs and when this may matter
sizeof(Object): how much memory objects take on JVMs and when this may matterDawid Weiss
 
TensorFlow local Python XLA client
TensorFlow local Python XLA clientTensorFlow local Python XLA client
TensorFlow local Python XLA clientMr. Vengineer
 
Новый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоныНовый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоныTimur Safin
 
Introduction to Rust language programming
Introduction to Rust language programmingIntroduction to Rust language programming
Introduction to Rust language programmingRodolfo Finochietti
 
.NET Multithreading and File I/O
.NET Multithreading and File I/O.NET Multithreading and File I/O
.NET Multithreading and File I/OJussi Pohjolainen
 
Concurrency in Python
Concurrency in PythonConcurrency in Python
Concurrency in PythonGavin Roy
 
Programming at Compile Time
Programming at Compile TimeProgramming at Compile Time
Programming at Compile TimeemBO_Conference
 

Was ist angesagt? (20)

pa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text Processingpa-pe-pi-po-pure Python Text Processing
pa-pe-pi-po-pure Python Text Processing
 
Interpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratchInterpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratch
 
Pydiomatic
PydiomaticPydiomatic
Pydiomatic
 
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
 
Multiprocessing with python
Multiprocessing with pythonMultiprocessing with python
Multiprocessing with python
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for Dummies
 
Threads and Callbacks for Embedded Python
Threads and Callbacks for Embedded PythonThreads and Callbacks for Embedded Python
Threads and Callbacks for Embedded Python
 
Down the Rabbit Hole
Down the Rabbit HoleDown the Rabbit Hole
Down the Rabbit Hole
 
Python Brasil 2010 - Potter vs Voldemort - Lições ofidiglotas da prática Pyth...
Python Brasil 2010 - Potter vs Voldemort - Lições ofidiglotas da prática Pyth...Python Brasil 2010 - Potter vs Voldemort - Lições ofidiglotas da prática Pyth...
Python Brasil 2010 - Potter vs Voldemort - Lições ofidiglotas da prática Pyth...
 
Mastering Python 3 I/O
Mastering Python 3 I/OMastering Python 3 I/O
Mastering Python 3 I/O
 
sizeof(Object): how much memory objects take on JVMs and when this may matter
sizeof(Object): how much memory objects take on JVMs and when this may mattersizeof(Object): how much memory objects take on JVMs and when this may matter
sizeof(Object): how much memory objects take on JVMs and when this may matter
 
TensorFlow local Python XLA client
TensorFlow local Python XLA clientTensorFlow local Python XLA client
TensorFlow local Python XLA client
 
Virtual Machine Constructions for Dummies
Virtual Machine Constructions for DummiesVirtual Machine Constructions for Dummies
Virtual Machine Constructions for Dummies
 
Новый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоныНовый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоны
 
Introduction to Rust language programming
Introduction to Rust language programmingIntroduction to Rust language programming
Introduction to Rust language programming
 
.NET Multithreading and File I/O
.NET Multithreading and File I/O.NET Multithreading and File I/O
.NET Multithreading and File I/O
 
Concurrency in Python
Concurrency in PythonConcurrency in Python
Concurrency in Python
 
Programming at Compile Time
Programming at Compile TimeProgramming at Compile Time
Programming at Compile Time
 
A22 Introduction to DTrace by Kyle Hailey
A22 Introduction to DTrace by Kyle HaileyA22 Introduction to DTrace by Kyle Hailey
A22 Introduction to DTrace by Kyle Hailey
 

Andere mochten auch

In Search of the Perfect Global Interpreter Lock
In Search of the Perfect Global Interpreter LockIn Search of the Perfect Global Interpreter Lock
In Search of the Perfect Global Interpreter LockDavid Beazley (Dabeaz LLC)
 
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...David Beazley (Dabeaz LLC)
 
Tachyon-2014-11-21-amp-camp5
Tachyon-2014-11-21-amp-camp5Tachyon-2014-11-21-amp-camp5
Tachyon-2014-11-21-amp-camp5Haoyuan Li
 
The Little Warehouse That Couldn't Or: How We Learned to Stop Worrying and Mo...
The Little Warehouse That Couldn't Or: How We Learned to Stop Worrying and Mo...The Little Warehouse That Couldn't Or: How We Learned to Stop Worrying and Mo...
The Little Warehouse That Couldn't Or: How We Learned to Stop Worrying and Mo...Spark Summit
 
Linux Filesystems, RAID, and more
Linux Filesystems, RAID, and moreLinux Filesystems, RAID, and more
Linux Filesystems, RAID, and moreMark Wong
 
Lessons Learned with Spark at the US Patent & Trademark Office-(Christopher B...
Lessons Learned with Spark at the US Patent & Trademark Office-(Christopher B...Lessons Learned with Spark at the US Patent & Trademark Office-(Christopher B...
Lessons Learned with Spark at the US Patent & Trademark Office-(Christopher B...Spark Summit
 
The Hot Rod Protocol in Infinispan
The Hot Rod Protocol in InfinispanThe Hot Rod Protocol in Infinispan
The Hot Rod Protocol in InfinispanGalder Zamarreño
 
Advanced Data Retrieval and Analytics with Apache Spark and Openstack Swift
Advanced Data Retrieval and Analytics with Apache Spark and Openstack SwiftAdvanced Data Retrieval and Analytics with Apache Spark and Openstack Swift
Advanced Data Retrieval and Analytics with Apache Spark and Openstack SwiftDaniel Krook
 
Accelerating Cassandra Workloads on Ceph with All-Flash PCIE SSDS
Accelerating Cassandra Workloads on Ceph with All-Flash PCIE SSDSAccelerating Cassandra Workloads on Ceph with All-Flash PCIE SSDS
Accelerating Cassandra Workloads on Ceph with All-Flash PCIE SSDSCeph Community
 
Scaling up genomic analysis with ADAM
Scaling up genomic analysis with ADAMScaling up genomic analysis with ADAM
Scaling up genomic analysis with ADAMfnothaft
 
ELC-E 2010: The Right Approach to Minimal Boot Times
ELC-E 2010: The Right Approach to Minimal Boot TimesELC-E 2010: The Right Approach to Minimal Boot Times
ELC-E 2010: The Right Approach to Minimal Boot Timesandrewmurraympc
 
Velox: Models in Action
Velox: Models in ActionVelox: Models in Action
Velox: Models in ActionDan Crankshaw
 

Andere mochten auch (20)

Mastering Python 3 I/O (Version 2)
Mastering Python 3 I/O (Version 2)Mastering Python 3 I/O (Version 2)
Mastering Python 3 I/O (Version 2)
 
In Search of the Perfect Global Interpreter Lock
In Search of the Perfect Global Interpreter LockIn Search of the Perfect Global Interpreter Lock
In Search of the Perfect Global Interpreter Lock
 
Python in Action (Part 2)
Python in Action (Part 2)Python in Action (Part 2)
Python in Action (Part 2)
 
An Introduction to Python Concurrency
An Introduction to Python ConcurrencyAn Introduction to Python Concurrency
An Introduction to Python Concurrency
 
Python Generator Hacking
Python Generator HackingPython Generator Hacking
Python Generator Hacking
 
Python in Action (Part 1)
Python in Action (Part 1)Python in Action (Part 1)
Python in Action (Part 1)
 
Understanding the Python GIL
Understanding the Python GILUnderstanding the Python GIL
Understanding the Python GIL
 
Writing Parsers and Compilers with PLY
Writing Parsers and Compilers with PLYWriting Parsers and Compilers with PLY
Writing Parsers and Compilers with PLY
 
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
Why Extension Programmers Should Stop Worrying About Parsing and Start Thinki...
 
Open Stack Cheat Sheet V1
Open Stack Cheat Sheet V1Open Stack Cheat Sheet V1
Open Stack Cheat Sheet V1
 
Tachyon-2014-11-21-amp-camp5
Tachyon-2014-11-21-amp-camp5Tachyon-2014-11-21-amp-camp5
Tachyon-2014-11-21-amp-camp5
 
The Little Warehouse That Couldn't Or: How We Learned to Stop Worrying and Mo...
The Little Warehouse That Couldn't Or: How We Learned to Stop Worrying and Mo...The Little Warehouse That Couldn't Or: How We Learned to Stop Worrying and Mo...
The Little Warehouse That Couldn't Or: How We Learned to Stop Worrying and Mo...
 
Linux Filesystems, RAID, and more
Linux Filesystems, RAID, and moreLinux Filesystems, RAID, and more
Linux Filesystems, RAID, and more
 
Lessons Learned with Spark at the US Patent & Trademark Office-(Christopher B...
Lessons Learned with Spark at the US Patent & Trademark Office-(Christopher B...Lessons Learned with Spark at the US Patent & Trademark Office-(Christopher B...
Lessons Learned with Spark at the US Patent & Trademark Office-(Christopher B...
 
The Hot Rod Protocol in Infinispan
The Hot Rod Protocol in InfinispanThe Hot Rod Protocol in Infinispan
The Hot Rod Protocol in Infinispan
 
Advanced Data Retrieval and Analytics with Apache Spark and Openstack Swift
Advanced Data Retrieval and Analytics with Apache Spark and Openstack SwiftAdvanced Data Retrieval and Analytics with Apache Spark and Openstack Swift
Advanced Data Retrieval and Analytics with Apache Spark and Openstack Swift
 
Accelerating Cassandra Workloads on Ceph with All-Flash PCIE SSDS
Accelerating Cassandra Workloads on Ceph with All-Flash PCIE SSDSAccelerating Cassandra Workloads on Ceph with All-Flash PCIE SSDS
Accelerating Cassandra Workloads on Ceph with All-Flash PCIE SSDS
 
Scaling up genomic analysis with ADAM
Scaling up genomic analysis with ADAMScaling up genomic analysis with ADAM
Scaling up genomic analysis with ADAM
 
ELC-E 2010: The Right Approach to Minimal Boot Times
ELC-E 2010: The Right Approach to Minimal Boot TimesELC-E 2010: The Right Approach to Minimal Boot Times
ELC-E 2010: The Right Approach to Minimal Boot Times
 
Velox: Models in Action
Velox: Models in ActionVelox: Models in Action
Velox: Models in Action
 

Ähnlich wie Using Python3 to Build a Cloud Computing Service for my Superboard II

Building a Wireless Mesh Network Temperature Sensor
Building a Wireless Mesh Network Temperature SensorBuilding a Wireless Mesh Network Temperature Sensor
Building a Wireless Mesh Network Temperature Sensormichaelpigg
 
Using Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systemsUsing Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systemsSerge Stinckwich
 
How to build a virtual machine
How to build a virtual machineHow to build a virtual machine
How to build a virtual machineTerence Parr
 
Java on arm theory, applications, and workloads [dev5048]
Java on arm  theory, applications, and workloads [dev5048]Java on arm  theory, applications, and workloads [dev5048]
Java on arm theory, applications, and workloads [dev5048]Aleksei Voitylov
 
Feasibility of Security in Micro-Controllers
Feasibility of Security in Micro-ControllersFeasibility of Security in Micro-Controllers
Feasibility of Security in Micro-Controllersardiri
 
Javascript engine performance
Javascript engine performanceJavascript engine performance
Javascript engine performanceDuoyi Wu
 
[Advantech] PAC SW Multiprog Tutorial step by step
[Advantech] PAC SW Multiprog Tutorial step by step [Advantech] PAC SW Multiprog Tutorial step by step
[Advantech] PAC SW Multiprog Tutorial step by step Ming-Hung Hseih
 
Arduino Workshop @ MSA University
Arduino Workshop @ MSA UniversityArduino Workshop @ MSA University
Arduino Workshop @ MSA UniversityAhmed Magdy Farid
 
LECTURE2 td 2 sue les theories de graphes
LECTURE2 td 2 sue les theories de graphesLECTURE2 td 2 sue les theories de graphes
LECTURE2 td 2 sue les theories de graphesAhmedMahjoub15
 
8086 microprocessor instruction set by Er. Swapnil Kaware
8086 microprocessor instruction set by Er. Swapnil Kaware8086 microprocessor instruction set by Er. Swapnil Kaware
8086 microprocessor instruction set by Er. Swapnil KawareProf. Swapnil V. Kaware
 
Arduino Programming Familiarization
Arduino Programming FamiliarizationArduino Programming Familiarization
Arduino Programming FamiliarizationAmit Kumer Podder
 
Arduino by yogesh t s'
Arduino by yogesh t s'Arduino by yogesh t s'
Arduino by yogesh t s'tsyogesh46
 
Microcontrollers (Rex St. John)
Microcontrollers (Rex St. John)Microcontrollers (Rex St. John)
Microcontrollers (Rex St. John)Future Insights
 
02 direct3 d_pipeline
02 direct3 d_pipeline02 direct3 d_pipeline
02 direct3 d_pipelineGirish Ghate
 

Ähnlich wie Using Python3 to Build a Cloud Computing Service for my Superboard II (20)

Rig nitc [autosaved] (copy)
Rig nitc [autosaved] (copy)Rig nitc [autosaved] (copy)
Rig nitc [autosaved] (copy)
 
Building a Wireless Mesh Network Temperature Sensor
Building a Wireless Mesh Network Temperature SensorBuilding a Wireless Mesh Network Temperature Sensor
Building a Wireless Mesh Network Temperature Sensor
 
Using Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systemsUsing Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systems
 
How to build a virtual machine
How to build a virtual machineHow to build a virtual machine
How to build a virtual machine
 
Java on arm theory, applications, and workloads [dev5048]
Java on arm  theory, applications, and workloads [dev5048]Java on arm  theory, applications, and workloads [dev5048]
Java on arm theory, applications, and workloads [dev5048]
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
Feasibility of Security in Micro-Controllers
Feasibility of Security in Micro-ControllersFeasibility of Security in Micro-Controllers
Feasibility of Security in Micro-Controllers
 
Javascript engine performance
Javascript engine performanceJavascript engine performance
Javascript engine performance
 
5059734.ppt
5059734.ppt5059734.ppt
5059734.ppt
 
[Advantech] PAC SW Multiprog Tutorial step by step
[Advantech] PAC SW Multiprog Tutorial step by step [Advantech] PAC SW Multiprog Tutorial step by step
[Advantech] PAC SW Multiprog Tutorial step by step
 
Arduino Workshop @ MSA University
Arduino Workshop @ MSA UniversityArduino Workshop @ MSA University
Arduino Workshop @ MSA University
 
LECTURE2 td 2 sue les theories de graphes
LECTURE2 td 2 sue les theories de graphesLECTURE2 td 2 sue les theories de graphes
LECTURE2 td 2 sue les theories de graphes
 
8086 microprocessor instruction set by Er. Swapnil Kaware
8086 microprocessor instruction set by Er. Swapnil Kaware8086 microprocessor instruction set by Er. Swapnil Kaware
8086 microprocessor instruction set by Er. Swapnil Kaware
 
Arduino Programming Familiarization
Arduino Programming FamiliarizationArduino Programming Familiarization
Arduino Programming Familiarization
 
arduinoedit.pptx
arduinoedit.pptxarduinoedit.pptx
arduinoedit.pptx
 
Arduino by yogesh t s'
Arduino by yogesh t s'Arduino by yogesh t s'
Arduino by yogesh t s'
 
Microcontrollers (Rex St. John)
Microcontrollers (Rex St. John)Microcontrollers (Rex St. John)
Microcontrollers (Rex St. John)
 
Architecture of pentium family
Architecture of pentium familyArchitecture of pentium family
Architecture of pentium family
 
The PDP-10 - and me
The PDP-10 - and meThe PDP-10 - and me
The PDP-10 - and me
 
02 direct3 d_pipeline
02 direct3 d_pipeline02 direct3 d_pipeline
02 direct3 d_pipeline
 

Kürzlich hochgeladen

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 

Kürzlich hochgeladen (20)

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 

Using Python3 to Build a Cloud Computing Service for my Superboard II

  • 1. Using Python 3 to Build a Cloud Computing Service for my Superboard II David Beazley (http://www.dabeaz.com) Presented at PyCon 2011 Atlanta
  • 2. Note: This talk involves a number of live demonstrations. You will probably enjoy it more by watching the PyCon 2011 video presentation http://pycon.blip.tv/file/4878868/
  • 3. It Begins (Drumroll...)
  • 4.
  • 6. Personal History • Superboard II was my family's first computer • What I first learned to program (~1979) • It had everything that a kid could want
  • 11.
  • 12. You could get an electric shock You could look inside!
  • 13. Pure Awesome! You could program
  • 14. Pure Awesome! You could hack! Note the encouragement
  • 15. Backstory • 1982-2010. Superboard sits in mom's basement • July 2010. Eric Floehr mentions SB at Scipy • August 2010. Brother brings SB to Chicago • It still works! (to my amazement)
  • 16. Question • What do you do with an old Superboard II • 1 Mhz 6502 CPU • 8K RAM • 8K Microsoft Basic (vers. 1.0) • 300 Baud Cassette Audio Interface • 1K Video Ram (24x24 visible characters) • Not a modern powerhouse
  • 18.
  • 19. HOW? (with Python 3 awesomeness of course) (plus some ØMQ and Redis) (and some 6502 assembler)
  • 20. Getting to the Cloud This is the only I/O A pair of RCA audio jacks Used for cassette tape storage Not too promising
  • 22. Cassette Interface • Behind the RCA jacks, sits a real serial "port" • Motorola 6850 ACIA • Ports are a 300 baud audio stream encoded via Kansas City Standard • Might be able to hack it
  • 24.
  • 25.
  • 26. Python Audio Processing • pyaudio • http://http://people.csail.mit.edu/hubert/pyaudio/ • A Python interface to the portaudio C library • Allows real-time access to audio line in/out • I ported it to Python 3
  • 27. Reading Audio Input import pyaudio p = pyaudio.PyAudio() stream = p.open(format=pyaudio.paInt8, channels=1, rate=9600, chunksize=1024, input=True) while True: sample = stream.read(1024) process_sample(sample)
  • 28. Building a Python Modem writer thread pyaudio byte writer encoder TCP client socket pyaudio byte reader decoder reader thread • A network socket bridged to two real-time audio encoding/decoding threads
  • 29. KCS Audio Encoding 0= 1= (4 cycles @ 1200 Hz) (8 cycles @ 2400 Hz) 'A' = 0x41 (01000001) 0 0 1 0 0 0 0 0 1 1 1 start data stop
  • 30. KCS Audio Decoding samples (8-bit) 89, 103, 117, 151, 194, 141, 99, 64, 89, 112, 141, 203, 152, 107, 88, ... sign bits (0 = neg, 1= pos) 000111000111000111000111000111111000000111111000000111111000000111111... sign changes (XOR adjacent bits) 0001001001001001001001001001000001000001000001000001000001000001000001... Idea: Each 1 bit represents a 0-crossing
  • 31. Example Code def generate_sign_change_bits(stream): previous = 0 while True: samples = stream.read(CHUNKSIZE) # Emit a stream of sign-change bits for byte in samples: signbit = byte & 0x80 yield 1 if (signbit^previous) else 0 previous = signbit
  • 32. KCS Bit Decoding idle (constant 1) 1 0 11 0 0 0 0 start data byte stop Sign Change Bits push 1001001001001001001001001001 1001001001001001 discard Sample buffer (size = audio samples for 1 bit) ~ 8 sign changes ~ 16 sign changes 0 1
  • 33. Example Code from collections import deque # Sample buffer sample = deque(maxlen=SAMPLES_PER_BIT) for b in generate_sign_change_bits(stream): sample.append(b) nchanges = sum(sample) if nchanges < 10: # Detected a start bit # Sample next 8 data bits ... (The actual code is more optimized)
  • 34. Demo My Mac (linked via audio)
  • 35. Interlude • It's Alive! • Basic communication is just the start!
  • 36. This is uploading machine code ~500 lines of 6502 assembler ... getvar_copy_string: ! ;; Move the variable address to INDIRECT where we c ! LDA![0x95, Y]! ; Length ! STA!%MEM_LENGTH ! INY ! LDA![0x95, Y]! ; address (low) ! STA!%INDIRECT ! INY ! LDA![0x95, Y]! ; address (high) ! STA!%INDIRECT+1 ! LDY!#0x00 ... Wrote a 6502 assembler ~500 lines of Python 3
  • 37. Under the covers This is uploading machine code msgdrv.asm ~500 lines of 6502 .1C00/20 assembler asm6502.py 05 ... AE getvar_copy_string: EE ! ;; Move the variable address to INDIRECT where we c 1E ! msgdrv.hex Y]! ; Length LDA![0x95, 1E ! STA!%MEM_LENGTH AD ! INY 1E ! LDA![0x95, Y]! ; address (low) 1E ! STA!%INDIRECT 8D ! INY ! pymodem Y]! ; address (high) LDA![0x95, ! STA!%INDIRECT+1 ! LDY!#0x00 ... Wrote a 6502 assembler ~500 lines of Python 3
  • 38. Messaging Driver code Under the covers This is uploading machine request msgdrv.asm ~500 lines of 6502 .1C00/20 Client Superboard II control assembler asm6502.py 05 ... AE • Superboard issues requests getvar_copy_string: ! ! msgdrv.hex Y]! ; Length LDA![0x95, EE ;; Move the variable address to INDIRECT where we c 1E 1E • Client responds and gets control ! ! ! STA!%MEM_LENGTH INY AD 1E LDA![0x95, Y]! ; address (low) 1E • Driver coexists with BASIC ! STA!%INDIRECT 8D ! INY ! pymodem Y]! ; address (high) LDA![0x95, ! STA!%INDIRECT+1 1024LDY!#0x00 message driver ! bytes ... Wrote a 6502 Workspace 7168 bytes BASIC assembler ~500 lines of Python 3
  • 39. Example of makingcovers Messaging Driver code Under the a request This is uploading machine request 10 A = 96 msgdrv.asm ~500 lines Superboard II of 6502 assembler control Client asm6502.py 20 B = 42 .1C00/20 05 ... AE • SuperboardY]!issues1Erequests getvar_copy_string: = "FOO" ! ! 30 the variable address to INDIRECT where we c ;; Move msgdrv.hex C$ 40 S =; Length LDA![0x95, EE USR(37) 1E • Client responds and gets control ! Client ! ! STA!%MEM_LENGTH INY control 1E AD LDA![0x95, Y]! ; address (low) 1E • Driver coexists- Get a BASIC region ! STA!%INDIRECT 8D ! INY PEEK with memory ! pymodem Y]! ; address (high) LDA![0x95, ! ! POKE - Set a memory region STA!%INDIRECT+1 1024LDY!#0x00 message driver bytes ... GET - Get a BASIC variable SET - Set a BASIC variable Wrote a 6502 -Workspace to BASIC RETURN assembler 7168 bytes BASIC Return ~500 lines of shared memory! Distributed Python 3
  • 40.
  • 41. Messaging Architecture • There are two parts (driver and a client) superboard message client message driver audio socket pymodem BASIC Python 3 • Uses a binary message protocol USR(37) : x20 x06 x01 x25 x00 x02 Command Size Seq Data LRC • Protocol details not so interesting
  • 42. Message Driver • Interacts directly with Microsoft BASIC • Uses "Undocumented" ROM routines • Accesses BASIC interpreter memory • For this, some resources online • http://osiweb.org
  • 43.
  • 44.
  • 45.
  • 46. Client Architecture • Client bridges Superboard II to the outside world • Uses ØMQ (http://www.zeromq.com) • And pyzmq (http://github.com/zeromq/pyzmq) Message client Services audio socket pymodem ØMQ Python 3
  • 47. Request Publishing • Requests are broadcast on a ØMQ PUB socket • Retransmitted every few seconds if no response Message client USR(37) ØMQ PUB "37 1" "37 1" "37 1" ... To the "Cloud" Python 3 • Requests include the USR code and a sequence #
  • 48. Service Subscription • Services simply subscribe to the request feed import zmq context = zmq.Context() requests = context.socket(zmq.SUB) requests.connect("tcp://msgclient:21001") requests.setsockopt(zmq.SUBSCRIBE,b"37 ") • Now wait for the requests to arrive while True: request = requests.recv() • Clients are separate programs--live anywhere
  • 49. Request Response • Message client has a separate ØMQ REP socket • Used by services to respond Message client USR(37) ØMQ PUB "37 1" driver ØMQ REP Service commands (subscribed to 37) Python 3 • Service initially acks by echoing request back • On success, can issue more commands
  • 50. Command Connection • Setting up the command socket commands = context.socket(zmq.REQ) commands.connect("tcp://msgclient:21002") • Complete request/response cycle while True: request = requests.recv() commands.send(request) # Echo back resp = commands.recv() if resp[:2] == b'OK': # In control of Superboard # Do evil stuff ...
  • 51. Commands • Commands are just simple byte strings b"RETURN VALUE" b"PEEK ADDR SIZE" b"POKE ADDR DATA" b"GET VARNAME" b"SET VARNAME VALUE" • Response codes b"OK DATA" b"FAIL MSG" b"IGNORE" b"BUSY"
  • 52. Interactive Demo >>> request_sock.recv() b'37 1' >>> command_sock.send(b'37 1') >>> command_sock.recv() b'OK' >>> command_sock.send(b'GET A') >>> command_sock.recv() b'OK 96.0' >>> command_sock.send(b'GET B') >>> command_sock.recv() b'OK 42.0' >>> command_sock.send(b'SET Q 2') >>> command_sock.recv() b'OK' >>> command_sock.send(b'SET R 12') >>> command_sock.recv() b'OK' >>> command_sock.send(b'RET 0') >>> command_sock.recv() b'OK' >>>
  • 53.
  • 54. Big Picture Message client Up to 65536 Service IDs (N) ØMQ PUB USR(N) ØMQ REP Big Iron • Services can live anywhere • Written in any language • No real limit except those imposed by ØMQ
  • 55. Superboard Emulation • I dumped the BASIC and system ROMS • Loaded them into Py65 • Py65 : A 6502 Emulator Written in Python https://github.com/mnaberez/py65 • Work of Mike Naberezny • I ported it to Python 3
  • 56. Emulation in 60 Seconds You start with the Superboard II memory map (provided)
  • 57. Emulation in 60 Seconds You identify hardware devices
  • 58. Emulation in 60 Seconds You read (about keyboards)
  • 59. Emulation in 60 Seconds You read (about video ram)
  • 60. Emulation in 60 Seconds You read (about ACIA chips)
  • 61. Emulation in 60 Seconds Then you just plug it into py65 (sic) def map_hardware(self,m): # Video RAM at 0xd000-xd400 m.subscribe_to_write(range(0xd000,0xd400), self.video_output) # Monitor the polled keyboard port m.subscribe_to_read([0xdf00], self.keyboard_read) m.subscribe_to_write([0xdf00], self.keyboard_write) # ACIA Interface m.subscribe_to_read([0xf000], self.acia_status) m.subscribe_to_read([0xf001], self.acia_read) m.subscribe_to_write([0xf001], self.acia_write) # Bad memory address to force end to memory check m.subscribe_to_read([0x2000], lambda x: 0)
  • 63. Question • What do you do with an emulated Superboard?
  • 64. A Superboard Cloud 10 PRINT "I WILL THINK OF A" 15 PRINT "NUMBER BETWEEN 1 AND 100" 20 PRINT "TRY TO GUESS WHAT IT IS" 25 N = 0 30 X = INT(RND(56)*99+1) 35 PRINT 40 PRINT "WHATS YOUR GUESS "; Program Storage 50 INPUT G 10 PRINT "HELLO WORLD" 20 END 10 FOR I = 1 TO 1000 20 PRINT I 30 NEXT I 20 END Cloud Datastore Service Stored Instances (images of running Virtualized machines) Superboard CPUs
  • 65. Building The Cloud • I built it using Redis (http://redis.io) • Ported py-redis to Python 3 • Redis is cool • Can use it as a key-value store • Has other data structures (sets, hashes, etc.) • Queuing • Atomic operations
  • 66. Redis Example import redis db = redis.Redis() # Key-value store db.set('foo',data) data = db.get('foo') # Queuing db.lpush('queue',work) work = db.brpop('queue')
  • 67. Superboard Cloud Features • Remote program store • Load/save programs • Instance creation • Creation • Run with input • Distributed shared memory • It must be usable from the Superboard II
  • 68. Program Load/Store BASIC strings msg cloud set driver service get program redis settings • BASIC program & workspace memory directly manipulated by the message driver • Stored in Python object and pickled to Redis
  • 69. Instances • Instances are a running Superboard • 8K Program Memory • 1K Video RAM • Stored CPU context (registers, etc.) • Stored in a Python object • Pickled to Redis when inactive
  • 70. Instance Execution • "Runner" programs watch a Redis queue import redis r = redis.Redis() ... while True: work = r.brpop("queue") # Wait for work ... inst = load_instance() # Get instance run_emulation(work) # Run emulation save_instance(inst) # Save instance • Based on supplying keyboard input to SB • Instance runs until no more input available
  • 71. Instance Concurrency • Can have arbitrary number of runners Redis Runners • Asynchronous execution (w/ Superboard) • Uses Redis setnx() for locking
  • 72.
  • 73. import superboard as skynet pymodem Up to 65536 Service IDs (N) ØMQ PUB ØMQ REP Big Iron Cloud Service programs 10 PRINT "I WILL THINK OF A" 15 PRINT "NUMBER BETWEEN 1 AND Virtualized 100" 20 PRINT "TRY TO GUESS WHAT IT IS" 25 N = 0 Superboard CPUs 30 X = INT(RND(56)*99+1) 35 PRINT 40 PRINT "WHATS YOUR GUESS "; redis 50 INPUT G 10 PRINT "HELLO WORLD" 20 END Stored 10 20 30 FOR I = 1 TO 1000 PRINT I NEXT I Instances 20 END
  • 74. WHY?!
  • 75. Non-Answer • I don't actually want to use my Superboard II • It's awful! • It was painful even in 1980
  • 76. A Better Answer • For fun • Also to create a glorious mess! • Everything a systems hacker could want! • Hardware, device drivers, signal processing, protocols, networks, message passing, threads, synchronization, debugging, software design, testing, deployment, etc. • Awesome!
  • 77. Real Answer : Python 3 • Can Python 3 be used for anything real? • I needed to check it out myself • On a non-trivial project with many moving parts • And with a variety of library dependencies
  • 78. Lessons Learned • You can use Python 3 to do real work • However, it’s bleeding edge • You really have to know what you’re doing • Especially with respect to bytes/unicode • Must be prepared to port and/or patch
  • 79. Porting Experience • py65 (easy, some bytes issues) • pyredis (easy, bytes/unicode issues) • pypng (hard, really messy I/O) • pyaudio (hard, C extensions) • pyzmq (worked, Cython patch for Py3.2)
  • 80. Finding Python 3 Code • Every single package I used was downloaded from development repositories (github, subversion, etc, etc) • You can often find Python 3 compatible libraries in project forks or issue trackers if you look for it
  • 81. My Thoughts • Python 3 is cool • It keeps getting better >>> import numpy >>> • It’s different and fun • It might be a great language for distributed computing, messaging, and other applications
  • 82. That’s All Folks! • Thanks for listening! • Look for the “Python Cookbook, 3rd” edition in late 2011! • More info on my blog • http://www.dabeaz.com