OK, so we're going to go over some new topics in the next section and kind of require us to know a
little bit about the computer's memory.
So I'm going to provide a quick explanation on that.
And then later on in the course, I will go a little bit deeper in a computer memory so we can really
get into the weeds and you can understand what's going on under the hood in that digital kind of imaginary
space on your computer.
So where does the information in our code get stored?
So we've talked a bit about the compilation process of using the C++ compiler, right?
But what happens when we actually run our program, what's happening inside of our computer?
What is it doing?
So what happens from a very high level view is that our executable that we've created from the compilation
process also can be referred to as our binary program.
It gets loaded into a place we call virtual memory.
So another note here, you know, operating systems and memory management are complex right now, we're
just looking at it from a bird's eye view of very bird's eye view.
Later, we're going to go a little bit more into memory and I say a little bit because this is an operating
systems course or a computer architecture course.
I just want to kind of give you on the tools you need to be able to write software and understanding
memory and addresses and things like that are important.
So I will have to go into it a little bit.
So what is this virtual memory thing that I just mentioned?
Well, we call it virtual because it's not a physical thing.
We do have some physical things on our computer that deal with memory, and that would be RAM and the
hard disk drive.
So the hard disk drive is basically the spinning disk on your computer.
It can be made of silicon and metal and plastic and stuff, and has a little reading and writing head
that you can think of kind of like a like record player or something like that.
But that is something that stores memory permanently the hard disk drive.
So it's something we would call non-volatile, so you turn your computer off and stuff is still stored,
you don't you lose all your files that you've saved onto the hard disk drive.
You also can have a hard disk that is not necessarily a disk, it's kind of like maybe a solid state,
so you might have that in your computer so it doesn't use a spinning disk, but essentially the same
thing.
The RAM is also a physical thing that you can touch their sticks of RAM memory on your computer.
That's what a lot of people refer to when they're talking about memory, and that is something we refer
to as volatile storage, so it is not there.
Once you turn your computer off all the data in there, it gets wiped in the RAM.
But the virtual memory is something else.
So you can basically think that it is.
You can imagine it being in RAM.
Somewhere where our programming was stored is pretty complex.
It's managed by the operating system, but we're just going to imagine it somewhere in RAM and it's
just an imaginary space.
It is not physical, it's not.
So it's not a physical thing.
It's just some kind of area like set aside, you know, that RAM, your RAM has a certain amount, right?
So you might have, you know, whatever amount of RAM on your computer and you'll have this virtual
space, this part of RAM, where our computer program can get loaded.
So it's a little more complicated than that, but that's what we're going to imagine it is right now.
So some other things to talk about is there's big distances between some of these locations where you
can grab your data from.
So I'm going to compare RAM and the hard disk drive with some illustrations.
Another note down here remember that RAM is only volatile, so it's temporary.
When the computer turns off, the data goes away.
Right?
So let's look at a little analogy here.
So here's a room this square that's gray, and here is you.
And here is another room, and here is some data, so this could be like RAM, so let's say you're here.
If you wanted to get something from RAM, it could be kind of analogous to going out of this room into
another room and getting the data.
If we want to compare that though, with getting something from the hard disk drive and I'm talking
about like you being able to get some data for your program, you know, needing to fetch some data
that's needed in your program that's running in that virtual address space.
How far would you need to go when you're trying to get something from RAM compared to getting something
from hard disk drive?
So this is what it would be like on the hard disk drive.
It would be analogous to you being here on planet Earth and you having to go all the way to Pluto to
get the data and back.
So it may seem kind of weird to say something like that, but really when you look at the numbers like
how far away stuff is and RAM compared to how far away stuff is in the hard disk drive.
It really is massive in terms of what the computer sees.
So you might not notice that at all because everything seems really fast, right?
Like you get stuff pretty much instantly from RAM and you pretty much get stuff instantly from the hard
disk drive or the computer's moving really, really fast.
And it's making like some really quick calculations.
But if you look at the factor of like how much farther by what factor you need to multiply by to show
the difference in distance between going to RAM and going to the hard disk drive.
It would be something analogous to you having to physically go grab like pieces of paper that were data
in another room and instead having to make a spaceship and go out to Pluto to get it.
So pretty crazy and definitely really interesting when you think about the inner workings of the computer.
Another reminder is that the hard disk drive is non-volatile, so thankfully we are able to save our
documents and music and movies in a place that does not go away when the computer turns off.
So another important thing about this virtual memory land is it has addresses.
So imagine the virtual memory area as an incredibly huge parking lot.
So this parking lot has a lot of different areas based on what type of cars are allowed to park there,
and I'm using that analogy because there are different sections of memory that are kind of meant to
handle different things.
Each parking space in this parking lot is the same size and has a number associated with it so you can
find your car.
You can think of this as an address, and that is what we will be referring to these locations in the
virtual memory space, as we would call them, addresses.
So the memory addresses in this virtual memory land are represented in hexadecimal form, so you should
be familiar with something like this, you've seen it before.
We talked a little bit about binary and hex and decimal and octal and stuff like that.
So here are some examples.
So you see this number right here as high as zero X, that is actually not part of the address.
This is just something you prepend to the address to tell you.
It is Hex, so the zero x just means Hex.
After it, you might see an h sometimes, but that's pretty rare in that also can mean hex like a lowercase
h.
People refer to it as that.
So this cluding this right here we see one two three four five six seven eight f's.
And here we see eight zeros.
So basically, the zeros you can imagine as like in the very first parking spot.
So at the very like, you know, this is the closest spot and the eight F's would be the highest number
of spot, maybe like the farthest away.
So this is the numbering system going from zero up to F.
And that is, of course, because we're using the hex system, you know, where we're not just using
numbers, we also have those letters being kind of the highest one in that base.
16 Hex numbering system.
And the reason that there are eight here is because.
We are looking at something we could refer to as a 32 bit address space, so you might have heard of
something about what your computer's operating system really is in terms of the architecture.
So maybe when you look at details about your laptop or something like that or your desktop, you're
looking at details about the OS, whether it be Windows or Mac or something like that.
You might see like, Oh, I have 32 bit windows or I have 64 bit windows, and that's just talking about
this type of operating system and also talking about the address space that you would have 32 or 64
bit.
So remember that we kind of used to hex characters to represent a bite.
So each one could be four bits, right?
Four bits here, four bits.
They're eight bits.
Make up a byte, right?
And so if we kind of look at that here, here's eight eight bits, right?
So if we said we had eight ifs here, right?
So if we take this eight bits, which is a byte right here, you know, how many bytes do we have in
here?
Well, we have four of these, right?
So here's one.
You know, every two of them can be a byte.
So we have one two three four.
And so how many bytes are in here?
Well.
Or how many bits, sorry.
It would be 32 bits, right?
So we have four bytes or 32 bits.
So you see these eight big chunks, eight times for thirty two, and that is synonymous with us talking
about this 32 bit address space.
You might also have seen you might be seeing your addresses in 64 bit.
That can be kind of different.
Sometimes they only show the, let's say, first 12 characters there.
So that might be kind of confusing, but there could be like, you know, leaning chairs and stuff like
that.
But just wanted to use this 32 bit one to kind of help you understand it better.
So this could be a theoretical piece of this virtual memory address land.
And you can see that we are counting up in the addresses.
So here are the parking spots.
I mean, these would be like the places we could store our data, right?
So you see it says one and two and three and four, and these are hex addresses.
So it'll look a little something probably not exactly like this if you were to examine your computer
memory, but something like this.
So remember that these are represented in hexadecimal and they would start at like zero and go all the
way up to all these efforts right here.
So talk a little about that, a little bit about memory.
But we should also talk a little bit about what we're going to get into in the next session, which
is containers.
So it's great and all that.
We've been using variables like single variables, of course, you know, like making an integer or
a float or something like that, but it limits us quite a bit to only be able to use single variables
to store stuff.
Wouldn't it be nice if we could store than one more than one piece of data?
So like more than one end kind of in the same area, maybe we want to group a bunch of cars together
moving forward with this analogy and park them right next to each other.
So maybe we would want four cars parked right here next to each other in this virtual address space.
So in the next few lectures, we're going to start using some basic containers where we can group our
data and manipulate it so we can do more interesting things if you have a lot of your data stored in
the same location.
You can kind of combine that data in interesting ways and have a better type of organization of your
program.
It also makes it easier to write more complex programs.
So with that, I'm going to leave you with this lecture, and we will then get into talking about these
containers that I've talked about.
If you are confused about the addressing when we go through the lecture again, or you could look up
some additional information on how the address space works, we're going to be talking about how these
containers kind of look in memory and where our stuff is stored in relation to the other stuff.
When I say stuff, I mean, like variables like integers.
Where is one integer compared to the next integer?
How does it look if we put that in one of these containers that I'm talking about?
All right.
So with that, I will see you in the next lecture.