hocky

Operating Systems 2021-1 (OS211)

Written by Hocky Yudhiono in Pontianak

Top 10 List of Week 05

Hello, this is my top 10 list of Week 05! This week we’re going to talk about virtual memory. The concept about virtual memory is like caching and hashing 📃. And yeah!

This week I came of to improve the user experience of my website, by adding the time approximation of watching or reading each link! Just so you know what to click when you open my site 😉! We will use the usual hours/degrees (°), minutes (‘), seconds (‘’) notation, OK?

1. What is a Paging File or Pagefile as Fast As Possible (5’ Video)

Basically, you logically can’t put all the process you’re running on a contiguous segments on your main memory 🌠. Moreover, it’s not entirely possible to run large multiple processes that will be stored in your main memory 💾. Most likely, the processes will be stored in a virtual memory, and only caches important files the virtual memory trying to acquire.

A page map will map your virtual memory to physical memory. If a page fault occurs, meaning the data in your physical memory ain’t valid, it will try to acquire it from the slower disk 🐌. This paging’s concept is more or less the same with swap space in Linux 😎! The video is a 7/10 but still a good video to start the week.

2. Thrashing in Operating System (3’ Article)

🗑️ Stop. Before you continue. This is not Trashing!! But Thrashing!. Literal meaning is.

beat repeatedly and violently with a stick or whip, hit (something) hard and repeatedly.

Thrashing happens when lets say there is a process, and page fault happens so often that the processor needs to swap in and swap out too frequently, that it doesn’t even do the job 😡. Another good read of Thrashing.

So, how to solve it? Get yourself some RAM 😂. This link basically explains why you shouldn’t run too much program while you’re browsing. Do you ever had like 40 tabs each opening maybe a meme page, one chatting app, your pdf reader, your video player, a note app, spotify or any streaming services, until you got like 90% of your RAM usage and it turns really slow? Yeah, that’s basically is thrashing happening.

3. Tree queries for O(nq) (10’ Article)

⌚ If you’re into competitive programming, this is a total good read. I will explain to you first why is this interesting. So, In C++ (It’s really similar to C). Usually in 1 second ⌚ you can do like approximately 10e8 processes (Competitive programming approximations). But, somehow and sometimes. The compiler can optimize your code, those bad constants can be put down to really small 🐜.

So, with the advantages of cache hit you can fit up to 10e10 processes! How? Essentialy, loop through optimal pages, pages that are already in the physical memory, rather than going through tons and tons of page fault 📃. This is so interesting as this is my first post I feel so blessed about because I understand computer’s operating systems 💻!!!

4. Why Don’t They Make BIGGER CPUs? (3’ Video + 2’ Article)

Why Aren’t CPUs Getting Faster?. People might ask. Let’s go back a bit to memory hierarchy. So why are CPUs grow and develop so fast? While main memory and ram grows so slow? 🤔🤔 That’s what most people think about studying memory. Actually, designing faster chips is really difficult, because transistor material can get so hot 🔥. It’s actually related to all physical stuffs. So to improve the power, we designed multi-core processors and parallelization of computing.

The difference with RAM, well see. CPU’s memory tend to be really small. The cache is not so big and can be counted as Megabytes. Well, you see. RAM, is dozens of Gigabytes 🐘. Imagine developing a CPU-speed RAM with that large of storage. Must be so expensive. Now you get my point. The link is so interesting as this will refresh you memory about memory hierarchy, no puns intended 🧠!

5. fork() in C (5’ Article)

🍴 This is not the fork like the eating utensils fork.. Read the definition here, and how to use it, you can read the article. Fork is one of the system calls 😁, it will create a new process, called the child process, that runs concurrently with the parent. The fork() System Call Notes

If you open your task manager, you’ll see some processes you can expand. Yes, the processes inside is called the child process, basically the child processes will share the same memory with its parent. See the good demo code here. 👩🏻‍💻

So how is this related with virtual memory and how is it so interesting? 🤝🏻 Of course, this child process will be a good resource saver for another process you’re running in your PC. The next, will be explained in Number 7 of this TOP 10! Go check it out!

P. S: Zombie and Orphan Processes in C is a good reading reference as well..

6. 10 simple tricks to optimize your C code in small embedded systems (5’ Article)

This post does nothing about speeding up your code as its optimizations are so minor that you won’t be able to realize it. But, It’s so interesting, try to understand the code and see how compiler optimizes your code and how they treat it in your virtual memory!! 💿

Extra references also in Tips and Tricks – 7 Tips for Memory Management

7. How does copy-on-write in fork() handle multiple fork? (1’ Forum)

When we’re forking, we can page share the virtual memory, then, the technique of copy-on-write can be used. It’s basically telling you to duplicate its parent, and then change when the page is modified from both page 📃.

To read more about it, go check out the forum!! The concept about copy-on-write is really awesome 😎 as the idea is good, that’s why it’s interesting.

8. How To Check RAM on Linux (3’ Article)

Wonder how to check how much RAM can you use 🤔? Well in Windows you can simply just open the property of your My PC. But how to check it through terminal? simply do free -th, or just check it using top. But how to check the CPU Speed through Linux Terminal? There are also lots of ways. Simply do lscpu. It’s so interesting because this site will show you how to check your basic environment hardware you’re working with 😉. Or simply just check the specifications of the server you’re given…

9. 30 Top Command Examples for Monitoring in Linux (10’-20’ Article)

The top command in Linux displays the running processes on the system. One of the most important tools for a system administrator! 🤼 It is used extensively for monitoring the load on a server 🌎. In this article, the top command will be explained in article!

It’s really interesting, the link will explain each column meaning for each descriptions, also how to use top efficiently! 😁

10. Frame Allocation (12’ Video)

When multiple processes run, the frames stored inside the physical memory must be allocated! 🖼. On how to allocate it, the operating systems will consider how many free frames do our computer has right now 📃. Then, the process will be determined by how much memory approximately will it take! The video is so good! So colorful 🌈 I really like it! You will definitely understand frame allocation just by seeing the video! A total watch when you have a free time while eating lunch or when you’re boreddd!!! Here is an extra of 50 minutes videos, for kernel memory allocation which is so good as well!! Slab and Buddy Allocators..

That’s all Week 5 from me. I’ll start doing Week 6 as soon as possible!

Peace out!


🌵 © Hocky Yudhiono, 2021 - 2021