230: Filesystem: What Can They Do? Part 4.
Take Up Code - Podcast autorstwa Take Up Code: build your own computer games, apps, and robotics with podcasts and live classes
Kategorie:
There is a special type of filesystem used to swap memory. This is not something you’ll need to use directly. But since we’re talking about filesystems, now’s a good time to explain paging and swapping. Listen to the full episode to learn more details including an imaginary example that explains virtual memory and paging. You’ll also learn a bit about how the microprocessor enables virtual memory by going into protected mode. And a bit about random access memory or RAM. Putting all this together, you’ll understand how your computer can appear to have more memory than exists and what role the filesystem plays to enable all this. You can also read the full transcript below. Transcript This is not something you’ll need to use directly. But since we’re talking about filesystems, now’s a good time to explain paging and swapping. Depending on your operating system, this might be managed for you. I know that Linux users should have a partition with a Linux-swap filesystem setup. Other operating systems might give you the option for controlling paging or offer to manage everything for you. I’ll get to what paging is in just a moment. For now, just know that this is something the operating system needs to do sometimes when it gets low on memory. The benefit of having a dedicated partition for this is the operating system has one place to go when it needs more memory and doesn’t have to squeeze things into the same space you’re using to hold your important documents. Without a separate partition and dedicated filesystem, then the operating system will use a file that it creates. Usually, these files created by the operating system (and there are others), will be hidden from you so that you don’t accidentally delete them. The idea is that it also helps avoid clutter. However, one of the first things I do when setting up a new computer is to turn on the display of hidden and system files. I also choose to show filename extensions. Now, you might not be used to all this extra information. As a programmer, my advice is to start paying attention to these little details. And knowing what your operating system is doing with your filesystem definitely qualifies as something you should be aware of. Modern Windows operating systems make things a little more confusing with the addition of a swap file and a paging file. I haven’t done a lot of the new Windows App programming but from what I understand, the OS uses the swap file to hibernate the new Windows apps that you download from the Windows App Store when they’re not being used. Don’t get this confused with the swap partition in Linux. That’s more like the Windows paging file. Until Windows started making the distinction, I would normally use the terms swap and page to mean the same thing. Alright, let’s start with why a computer needs a swap partition or a paging file. I mentioned that it helps when the computer gets low on memory. Imagine this scenario, you have a clean desk. That’s already a stretch for me. Maybe you’re more tidy. I’ve got stuff all over my desk until I normally can’t see the surface anymore. But pretend for a moment that such a thing actually exists and you have a clean desk that can only hold let’s say 10 sheets of paper without any overlap. Since this is just imagination, we don’t want any paper to lay on top of another sheet. Let’s just call these pages. Now, what do you do when you need more than 10 pages? You could buy a bigger desk. That would be like installing more memory in your computer. But even then, you’ll eventually hit some limit to how many pages can fit on your desk. So for now, let’s assume we already have the biggest desk we can afford. And it will only hold 10 pages. A simple solution is to get a box that you can put on the floor that can hold pages you don’t need right now. You don’t wa