Skip to content

This is the virtual machine that runs as a process in the host system and shares the CPU time with the threads that are initialized in the process.

Notifications You must be signed in to change notification settings

NikhilJeikar/VirtualMachine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VirtualMachine

This program runs as a process in the host machine and share the resource with the threads that are created and initialized in Thread.c.


Files and their task

Init.h

This header file declares all the global variables and methods.This also declare all the global structures and enum that are used to through out the code.

Init.c

This is the main file which calls and bind all the function to void main.

Machine.c

This is the file that have the methods that interpret the opCode and also raise and handle interrupt.

Scheduler.c

Round robin is implemented in this Scheduler.This is the file used to switch context after end of every time quanta.

Thread.c

This is the file which create and initialize the thread. This also add and remove thread from the thread queue.


Custom OPCodes

Custom opcodes are negative enumerated value which are generated by enum opcodes in Init.h.

opHalt

  • This opcode is used to terminate the thread.

opNop

  • This opcode is used to skip a instruction.

opInc

  • This increment the top of the stack by 1.

opDec

  • This Decrement the top of the stack by 1

opEmit

  • Pop the top of the stack and print it.

opStartStr

  • This say the interpreter that there is a set of char is incoming and their to be printed together at once.

opPrintStr

  • This say the interpreter to pop the stack and print till the opStartStr is seen in the stack.

opLoop

  • This says that a loop have started and it runs till the top of the stack reach 0.

opEndLoop

  • This says that the instruction inside the loop ends here and whenever the interpreter read this it reduce the top of the stack by and move the instruction pointer to the start of the opLoop in the program instruction.

opStat

  • This print the usage stat of the thread.

About

This is the virtual machine that runs as a process in the host system and shares the CPU time with the threads that are initialized in the process.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages