hocky

Operating Systems 2021-1 (OS211)

Written by Hocky Yudhiono in Pontianak

Top 10 List of Week 06

Hello, this is my top 10 list of Week 06!

1. The Layman’s Guide to Linux: Daemons & Init Systems (10’ Video)

Daemon is a background process that can’t be touched by the users. They communicate through history and log files. When system daemons can’t be started the kernel panic will show. The init is like the ancestor of all processes as it starts before others, and used as an initializaiton when booting happens 💻. It’s also the last being closed when shutdown happens 😪. In linux, the most popular init system is SystemD. For more good explanations, you can also watch:

Interesting Reason: My teaching assistant talked about the daemon, about how a daemon should have its parent killed 💀, but then I asked about whether it’s an orphan or not? Turns out it will be taken over by the init systems. So, by watching the video you will understand how it works. The video will summarize all important concepts by talking about Daemons and the Init Systems.

2. Understanding process creation in operating system with fork, exec and wait system calls (10’ Articles)

Besides fork, there’s thing called exec that’s when you want the child process to execute different program. It will basically create a new address space and loads a new program into it. After the fork(), both parent and child share the memory address space of the parent. In linux, these address space are divided into multiple pages. Only when the child writes to one of the parent memory pages, a duplicate of that page is created for the child 🤡. This lazy change allow the program to optimize better when the child process has nothing to do with memory!

Interesting Reason: You’ll learn about how forking, exec, and process creation in depth, this will improve your understanding and the explanation is easy to understand 👍👍👍! Really good 7-15 minutes read with code you can compile directly 🌠🌠

3. Multithreading Code - Computerphile (15’ Video)

In Linux, Thread can be seen as a task, in a program, some threads can cause a problem when computing something. When we do a a = a + i command, essentially there are 3 commands being done, that is loading, adding, and storing back to a register. When threading is done, those processes can collide and data can get lost. So, to handle it we can use stuffs called mutexes 😊😊.

Interesting Reason: The visual effect from computerphile is top notch! You can’t let that eye out of that video box! Multithreading is coool 😎😎😎!!

4. Why does a program with fork() sometimes print its output multiple times? (5’ Forum)

When outputting to standard output using the C library’s printf() function, the output is usually buffered. The buffer is not flushed until we output a newline, call fflush(stdout) or exit the program (not through calling _exit() though). The standard output stream is by default line-buffered in this way when it’s connected to a TTY 😀😀.

Interesting Reason: You’ll learn about how buffers in C works and how flush works, the concept is important, moreover it’s interesting because you’ll learn it from a case! 📚

5. WTF is a Thread (6’ Video)

Process is essentially a blob of memory, it has the code, data, register, stack. The operating systems store a process control block, this includes the state, number, and bla bla bla for each processes 🍴. When a process fork a children, it will copy the PCB from its parent. If a thread is made, only the register and stack is duplicated, the data and code stays the same 😁.

Interesting Reason: Very nice and clear explanation of Thread! The title so clickbaiting, but it’s OK! There’s no swearing inside the video 😋..

6. All You Need To Know About Processes in Linux [Comprehensive Guide] (3’ Article)

A process refers to a program in execution; it’s a running instance of a program. A new process is normally created when an existing process makes an exact copy of itself in memory. The child process will have the same environment as its parent 🤼, but only the process ID number is different. Init process is the mother (parent) of all processes on the system, it’s the first program that is executed when the Linux system boots up; it manages all other processes on the system. It is started by the kernel itself, so in principle it does not have a parent process.

Interesting Reason: This is like the cheatsheet if you want to mess with processes in Linux! 💻 There are lots of command you can type directly from your own terminal and can try for yourself! Well, if you someday in the future will work using Linux, this must be important concepts to you 😊!

7. What is Hyper Threading Technology as Fast As Possible (5’ Video)

You can see threading as like eating a food, when you eat with two hands, you can acquire things faster ✋. But you have to imagine the mouth is like the processor, it has to process something and wait till it’s done than the other hand can run as well. Our hand can be slow so while our hand is fetching another food, other hands can be helped to eat 😂. When there are multiprocessors, we can see it as other people eat the food with us 🍎.

Interesting Reason: Good analogy and easy explanation of multi-processing, concurrency and threading, very short yet clear video 😎!!

8. Process 101 (20’ Walkthrough Blog)

The process 101 talks about how a process execute, and wait, types of exec, the signals and interrupts, also lots and lots of shell examples! Really read this to understand processes and threads!!!

Interesting Reason: It’s purely complete and so interactive. It’s made using jekyll and the guide is just really good, it has pictures and explanation to make it easier for us to understand 🖼. Lots of code that we can try as well 🧠.

9. POSIX Shared Memory with C Programming (10’ Article)

POSIX shared memory is a framework for inter-process communication (IPC) specified in the POSIX specifications. Two (or more) tasks can read from it and write to the shared memory zone while establishing the shared memory. POSIX shared memory does not always enforce copy disbursements, in contrast to other IPC structures (e.g., pipe, socket, etc.), and is desirable for certain programs.

Interesting Reason: Really important concepts because threads or tasks is closely related to sharing memory between each others. In here, you will be taught on how to do it on C ⌨⌨!!

10. fork() can fail: this is important (2’ Blog)

People seem to know that fork will return 0 if it’s the child and some positive number if you’re the parent, that number is the child’s pid. They sock this number away and then use it later. Guess what happens when you don’t test for failure? Yep, that’s right, you probably treat -1 (fork’s error result) as a pid. Killing “pid -1” is equivalent to massacring every other process you are permitted to signal. If you’re root, that’s probably everything. You live and init lives, but that’s it. Everything else is gone gone gone.

TL;DR No more killing pid -1 you should be careful when coding, especially when handling processes, threads, and tasks.

Interesting Reason: Another short blog by one of my favorite operating systems blogger, RachelByTheBay. Simple stuffs you should handle when coding. It’s really good if you wanna go deep into the C embedding system 😁.

Extra

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

Peace out!


🌵 © Hocky Yudhiono, 2021 - 2021