Thursday, November 15, 2012

O hai

So many people have actually serious blogs where they blog about one particular thing. In fact, almost everyone I physically meet now who has a blog keeps one where they talk about a topic others might be interested in, like programming or design or startups or law or non-profits. Hopefully people find whatever random thoughts I have to be interesting enough, because I can't be counted on to write anything else here.
-------------------------------------------------

With the obligatory meta-blogging out of the way, here goes:

Thoughts on virtualization:
So I'm currently learning about OS (Operating Systems). One very important thing that the OS does is to give each program* the illusion that it is the only program running on the computer - each program "thinks" it has all 4GBs (or however much) of RAM and the entire CPU to itself even though it's actually sharing those with all the other programs(except the OS kernel) that are running on the computer. How does the OS do it? Well, it turns out that at any one time, the state of a program's execution(called the context) can be stored in quite a small amount of space. Every once in a while, you can "freeze" the program, save the context, "unfreeze" another program, and repeat. In this way, each program gets to run some of the times, and is never aware of anything that happens when it is not running.

But if we stop there, other programs could also leave stuff lying around, which would break the illusion that each program is the only one running. So the OS kernel does something sneaky: it never exposes the actual space to the program. Each program gets a virtual space, such that anytime it looks at or changes something in its space, the OS kernel would give the program the impression that whatever the program is looking for is where the program thinks it showing the program that the corresponding real location contains. The OS kernel has to do this very carefully, otherwise the program would get confused, or even worse, it might accidentally allow the program to touch something it is not supposed to touch.

The nice thing about this world that if the OS is done right, each program doesn't "feel" that their requests take a long time, even though it might actually have taken 1 million times as long as it had ever existed for the request to be fulfilled (I think about that when I'm lining up at the DMV.) The bad thing is that you're all alone, and the only way to talk to anyone else is by making a phone call to "the system".

So suppose you are someone with the ability to stop time and you never die, you could actually give everyone on earth the illusion that they are alone! Freeze time for everyone, let one guy move once in a while, and then put everyone else in a small place, swapping them around from time to time.

Then truly, "Only through our love and friendship system calls can we create the illusion for the moment that we're not alone".

* technically it's a process/thread, but the details are not that important here.


Some notes on entropy, and an interesting consequence

Entropy is a measure of "disorder", but it's also useful to think of it as a measure of how little we know about a system - these are equivalent ways of looking at the same thing.

Suppose you have a room full of stuff. The usual thing to say is that a messy room has more entropy than a neat room, because the messy room is more "disordered". But we can also look at this from the information perspective. Imagine you have a robot that can reconstruct your room item by item. Now you tell your robot, "Construct a messy room." (Assume that the robot also understands what "messy" and "neat" means. This would become important later.) How much would you know about the room that has been reconstructed by the robot if you are not allowed to look at it?

Well, not very much, because the robot has a great deal of freedom in putting things in different places. You have no way to know where any particular thing is going to be, and even after you know where something is, you still don't know where all the other things are. You are, in fact, so clueless about the messy room that the robot would need to give you a lot of information before you really know where everything is. In other words, saying that a room is messy doesn't tell you very much about it - that what it means (at least from an information perspective) by high entropy. In contrast, if you told the robot to construct a neat room, you already know that the books would be on the shelves, and the tables and chairs are going to be some angle not too far from being a right angle before you even look at the room - saying that a room is neat tells you quite a bit about it. That's how it's low entropy. Another way of saying it is that, entropy is a measure of the number of ways you can make up something that agrees with a particular description. "Messy room" is less descriptive than "neat room", so there are more ways you can make a room messy compared to the number of ways you can make a room neat.

This ties in two fundamental ideas in physics and computer science together. It turns out that this sets absolute physical limits to the information density of a chip, or anything at all (though in practice, this density limit is about as relevant to chip designers today as the speed of light limit is to spacecraft builders). Here's the argument: suppose you make a chip that holds a lot of information, let's call it an "uber-chip". When I say, "Here's an uber-chip," I am allowing for many ways to make up an uber-chip. Perhaps I flip the last bit, perhaps I flip the middle two, or perhaps I alternate the bits... and so on. This means that chips of arbitrarily high information density also have arbitrarily high entropy. Now, the entropy of a black hole increases by a certain fixed amount when you drop a mass into it. Suppose you drop an uber-chip into a black hole. Well, so you've started with something to arbitrarily high entropy, and how you've converted it to some fixed amount of entropy - decreasing the total entropy of the universe in the process. You can't do that, so that means no uber-chip is possible.

And I think that's pretty cool.

Comments

Loading... Logging you in...
  • Logged in as
There are no comments posted yet. Be the first one!

Post a new comment

Comments by