Skip to content

.Net Core Virtual Machine - executing .Net Core library (dll) in C#

License

Notifications You must be signed in to change notification settings

cv-lang/virtual-machine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

.NET virtual-machine

virtualmachine-logo

.NET Virtual machine written in C #. It allows you to perform the compiled .net code (IL). The code is executed instruction by instruction. (Virtual machine emulates all instructions from IL). Execute code can be hibernated and then restarted (even on another machine after serialization).

Allow to:

  • Application checkpointing - allowing to stop execution (suspending/hibernation) save execution state to disk and later load state from disk and resume execution.
  • Hibernation and process recovery
  • Thread serialization

Example

public class HibernateWorkflow
{
    public int InputParametr { get; set; }
    public string Start()
    {
        //do some work
        for (int i = 0; i < 10; i++)
        {
            SomeInterpretedFunction();
        }

        //after restore (in another thread/computer)
        //do some work
        for (int i = 0; i < 10; i++)
        {
            SomeInterpretedFunction();
        }

        return "Helow World " + InputParametr;
    }

    [Interpret]
    public void SomeInterpretedFunction()
    {
        //do some work
        InputParametr++;

        //hibernate executed method
        VirtualMachine.VirtualMachine.Hibernate();
    }
}

launching code

var proces = new HibernateWorkflowSimple() { InputParametr = 10 };
var vm = new VirtualMachine.VirtualMachine();
vm.Start(proces);
var serializedVMXml = VirtualMachine.SerializeVirtualMachine(vm);
object retFromSerializedVM = "";

while (vm.Status == VirtualMachineState.Hibernated)
{
    vm = VirtualMachine.DeserializeVirtualMachine(serializedVMXml);
    retFromSerializedVM = vm.Resume();
    serializedVMXml = vm.Serialize();
}

var inProcProces = new HibernateWorkflowSimple() { InputParametr = 10 };
var retInProcProces = inProcProces.Start();
Assert.AreEqual(retInProcProces, retFromSerializedVM);

NuGet 'Cvl.VirtualMachine'

PM> Install-Package Cvl.VirtualMachine -Version 0.9.1

NuGet package Cvl.VirtualMachine

Dependencies

Mono.Reflection

SharpSerializer

About

.Net Core Virtual Machine - executing .Net Core library (dll) in C#

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages