Welcome to Gaia! ::


Aged Poster

5,750 Points
  • Forum Sophomore 300
  • Streaker 200
  • Partygoer 500
How exactly does a virtual machine make itself map its virtual resources to hardware resource? Is it done using a piece of software that can somehow mimic the behavior of a hardware and somehow turn it into software? I know for a fact that if a virtual machine got infected with a virus, the virtual resources will get infected but the hardware resources will still be in tact.

What do they mean by software resources and hardware resources? Is resources in this case just "components" or "parts"?
skyryo
What do they mean by software resources and hardware resources? Is resources in this case just "components" or "parts"?
They mean "things that accept commands, produce data, or hold state."

A virtual machine is simply a program that traps specific behaviors in software, and simulates the behavior that the software inside the virtual machine expects.

At a very low level, for example, a virtual machine might set up an area of memory that stores the registers of a CPU, and as it reads bytes from another specifically chosen area of memory, it changes the "registers" for the simulated CPU in memory, exactly as you would expect would happen to those registers if the same bytes were given to a real CPU of that type. This is what we mean by emulation.

At a higher level, though, a virtual machine will pass code from memory on to the real CPU normally, but it asks the CPU to notify it when the code does something very specific, like requesting data from memory or sending a command to a particular device, so that then, instead of sending those commands to real hardware, the virtual machine software can act in place of the hardware and simulate its behavior as the code it is running would expect.
skyryo
How exactly does a virtual machine make itself map its virtual resources to hardware resource? Is it done using a piece of software that can somehow mimic the behavior of a hardware and somehow turn it into software? I know for a fact that if a virtual machine got infected with a virus, the virtual resources will get infected but the hardware resources will still be in tact.

What do they mean by software resources and hardware resources? Is resources in this case just "components" or "parts"?


Ever heard of "sandboxing?"

Aged Poster

5,750 Points
  • Forum Sophomore 300
  • Streaker 200
  • Partygoer 500
Crackerjackthe4th
skyryo
How exactly does a virtual machine make itself map its virtual resources to hardware resource? Is it done using a piece of software that can somehow mimic the behavior of a hardware and somehow turn it into software? I know for a fact that if a virtual machine got infected with a virus, the virtual resources will get infected but the hardware resources will still be in tact.

What do they mean by software resources and hardware resources? Is resources in this case just "components" or "parts"?


Ever heard of "sandboxing?"


Nope.

Hallowed Lunatic

13,050 Points
  • Dressed Up 200
  • Forum Regular 100
  • Elocutionist 200
in laymen's terms "sandboxing" is like fencing out an area of a field for a specific purpose. You can apply this principle to the resources of your computer.

Aged Poster

5,750 Points
  • Forum Sophomore 300
  • Streaker 200
  • Partygoer 500
psychic stalker
skyryo
What do they mean by software resources and hardware resources? Is resources in this case just "components" or "parts"?
They mean "things that accept commands, produce data, or hold state."

A virtual machine is simply a program that traps specific behaviors in software, and simulates the behavior that the software inside the virtual machine expects.

At a very low level, for example, a virtual machine might set up an area of memory that stores the registers of a CPU, and as it reads bytes from another specifically chosen area of memory, it changes the "registers" for the simulated CPU in memory, exactly as you would expect would happen to those registers if the same bytes were given to a real CPU of that type. This is what we mean by emulation.

At a higher level, though, a virtual machine will pass code from memory on to the real CPU normally, but it asks the CPU to notify it when the code does something very specific, like requesting data from memory or sending a command to a particular device, so that then, instead of sending those commands to real hardware, the virtual machine software can act in place of the hardware and simulate its behavior as the code it is running would expect.


when you say "hold state" I'm thinking about variables and how variables can hold a value. accept commands reminds me of passing in an argument into a parameters of a instruction(functions/methods) and produce data reminds me a method or a function returning a value. Am I on the right track of thinking? I have experiencing programming games in Java. If I were to build a virtual machine, would it be any different?
skyryo
psychic stalker
skyryo
What do they mean by software resources and hardware resources? Is resources in this case just "components" or "parts"?
They mean "things that accept commands, produce data, or hold state."

A virtual machine is simply a program that traps specific behaviors in software, and simulates the behavior that the software inside the virtual machine expects.

At a very low level, for example, a virtual machine might set up an area of memory that stores the registers of a CPU, and as it reads bytes from another specifically chosen area of memory, it changes the "registers" for the simulated CPU in memory, exactly as you would expect would happen to those registers if the same bytes were given to a real CPU of that type. This is what we mean by emulation.

At a higher level, though, a virtual machine will pass code from memory on to the real CPU normally, but it asks the CPU to notify it when the code does something very specific, like requesting data from memory or sending a command to a particular device, so that then, instead of sending those commands to real hardware, the virtual machine software can act in place of the hardware and simulate its behavior as the code it is running would expect.


when you say "hold state" I'm thinking about variables and how variables can hold a value. accept commands reminds me of passing in an argument into a parameters of a instruction(functions/methods) and produce data reminds me a method or a function returning a value. Am I on the right track of thinking? I have experiencing programming games in Java. If I were to build a virtual machine, would it be any different?
A programming language is a kind of virtual machine. Java itself is also a virtual machine - it simulates the specific stack-based virtual CPU that Java Bytecode is written for. (Actually, there's a physical CPU that can also do it: ARM CPUs with Jazelle extensions.)

So, yes, you're on the right tack, but I'm speaking much, much more generally:

When I say something holds state, I mean that if you pass data to something, you can get that data back out. It might be something as simple as storing a number in memory, or something as abstract as getting the position of a stepper motor after you turn it. In the case of a computer, that includes everything from RAM to hard drives, and even video cards and sound cards.

When I say something accepts commands, I mean that it does something specific when you give it data. For example, when you pass a specific sequence of numbers to your hard drive, it looks up and fetches another set of numbers that it has stored. Or when you write a specific sequence of bytes to specific locations in memory, your video card draws things to the screen and puts new data in other locations in memory.

When a virtual machine needs to simulate these things, it acts out the same behaviors, but does it entirely in software, in RAM or to a backing file on the hard drive.

When something like the Java Virtual Machine needs to do something, it takes a group of bytes, and does something that has already been put forward as the "command" those bytes happen to represent. Your CPU does exactly the same kind of thing.
9fpbo
Maybe the programs can write its own programs on its own...[/quoteMetaprogramming]

Quick Reply

Submit
Manage Your Items
Other Stuff
Get GCash
Offers
Get Items
More Items
Where Everyone Hangs Out
Other Community Areas
Virtual Spaces
Fun Stuff
Gaia's Games
Mini-Games
Play with GCash
Play with Platinum