Coder Social home page Coder Social logo

msylvia / virtualmachine Goto Github PK

View Code? Open in Web Editor NEW

This project forked from claustopholt/virtualmachine

1.0 1.0 0.0 1.64 MB

A virtual machine that simulates a hypothetical microprocessor.

Batchfile 0.06% ANTLR 1.25% Python 83.77% HTML 14.92%

virtualmachine's Introduction

VirtualMachine

Written by Claus Topholt.

This is a demonstration of a simulated, distributed, stack-based microprocessor (a virtual machine) with a hypothetical integer-only instruction set. Programs are written in a simple high-level language which supports limited integer math, while-loops, if-else statements, comments and console output.

Each program's source code is compiled to bytecodes and placed into a 512-byte memory block, which the virtual machine's "cpu" operates on. The "cpu" is actually distributed across a number of isolated worker processes, which can scale across physical (or virtual) hardware. The memory blocks are stored in a central Redis cache and the worker threads periodically serialize and de-serialize the blocks in order to execute code. All data from the virtual machine, such as memory, registers, disassembly and console output is streamed back to the user with websockets using a pub/sub pattern.

The virtual machine is written in Python 2.7. The simple language uses the ANTLR4 lexer/parser. The website runs Flask on gunicorn and everything is hosted at DigitalOcean on two small CentOS 6.5 servers.

Please note: This is a toy project, used to examine various architectural ideas and patterns. It is not a production-like implementation of a virtual machine. That said, you are welcome to clone the source code.

Pre-requisites (pip): enum, antlr4-python2-runtime, redis, Flask.

###For a running demo and a more in-depth explanation, please visit topholt.com.

virtualmachine's People

Contributors

claustopholt avatar

Stargazers

Matt Sylvia avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.