Top 10 List of Week 07

Jonathan Nicholas --- Jakarta

Top 10 List of Week 07

  1. Lock, mutex, semaphore… what’s the difference? (thread)
    You can gain a deeper understanding by reading these stackoverflow replies. If you’ve been following my top 10 list, you might find this thread a bit familiar. That is because I’ve already touched up on the topic of lock, mutex, and semaphore. Since this week’s topic relates heavily with said topic, I have to bring this article up again. Still continuing last week’s material, this week’s material has heavy prerequisites on concurrency. This article explains with detail on the difference of lock, mutex, and semaphore. I’ve made a cheat sheet on their difference on my w02, so might as well bring it up here again, as I belive this is a very important topic to understand.
    • Lock allows only one active thread to enter a part that’s locked. The non-selected threads are put to sleep.
    • Mutex is similar to Lock, but allows sharing between multiple processes.
    • Semaphore is similar to Mutex but not actually. It allows ‘N’ number of threads to enter. Semaphore is signaling mechanism (“I am done, you can carry on” kind of signal).
  2. Introduction to DEADLOCK in Operating System (article)
    This article explains and mentions next’ weeks material about scheduling. It also has diagrams to help you understand better by visualizing what actually happens during a deadlock. Another topic that I’ve referred to, but only briefly, is about Deadlocks. Again, from my w02 I’ve made a cheat sheet on deadlock.
    • What is deadlock? Deadlock occurs when two or more processes each hold a resource and wait for other resources held by another process but none actually finish executing.
  3. What is a starvation problem in an operating system? (article)
    I’ve actually used educative.io when I was learning about systems design, and to no surprise, it’s quality for OS topics are also high quality. This article is very concise, yet touches up on all the important topics regarding starvation. It also has an interactive diagram / slide to play with. And to top it off, it also has a diagram listing the difference between a deadlock and starvation. Best read of today. Again, another topic I’ve mentioned very briefly in my w02 compilation. Here is what I summed up about starvation.
    • What is starvation? Starvation occurs when high priority processes keep executing while low priority ones get blocked for a certain amount of time.
  4. Difference between Mutex and Semaphore in Operating System (article)
    This website is unfamiliar to me, but has a very nice composition of explanation, points, code example, and quotes. Again, another topic I’ve discussed on w02, what is the difference between lock and semaphore? I’ve made a summary to hopefully help you understand.
    • Mutex is a locking mechanism used to synchronize access to a resource.
    • Semaphore is a signaling mechanism which an Interrupt Service Routine (ISR) signals for the task to wake up. The key word here is signal.
  5. Difference between binary semaphore and mutex (thread)
    This might be a repeat of the previous number’s topic, but I truly believe you won’t understand a topic until you’ve read a stackoverflow thread on said topic. This article is very interesting as it is the 3rd most voted question with the operating system tag. Binary mutex and mutex are referring to the same thing, and it looks like my understanding from the previous article is correct about mutex and semaphores.

  6. File Path Race Condition & How To Prevent It - bin 0x31 (video)
    If you’re learning about CTF and network security, you might know this youtuber. Liveoverflow is a ctf youtuber who explains hacking/ctf types of videos. It is an interesting video as the topic is about Race Condition and is tackled and explained by someone who is experienced in the linux/hacking/ctf scene. The race condition is about linux file paths and what happens is before opening the file path, the program switches the file path with a new one, hence the program ending up opening a file that shouldn’t have been opened. This type of race condition is often called as TOCTOU (time-of-check to time-of-use). The fix to this race condition is by using fstat to get the file description.

  7. Race Condition Trick /proc/self/fd (video)
    This is the continuation of the previous video, and takes a practical teaching of symlink. Liveoverflow also uses several tools such as python and c, so you can learn quickly from example. I also learn more about fd or file descriptors, used in the previous video. This video is a bit hard to understand, but essentially being able to read a ‘deleted’ file becuse the handle still exists. So in another real life scenario, you can take advantage of the proc filesystem. Let’s say you accidentally deleted a file, but a program is still using that file. You can do cat /proc/PID/foldernumber > youfile.c. I really love these real case scenario video tutorials.

  8. Critical Section Problem (article)
    A more theoretical link, it’s about critical section problem by tutorialspoint.This article is short and concise, plus it has visualization to help understanding the problem. So what is the solution to the critical section problem? We’ve actually studied it before! Mutex, Progress, and Bounded Waiting? That’s new. Bounded waiting is to make each process have a limited waiting time, therefore not wait endlessly.

  9. Handling Deadlocks (article)
    This is the mandatory geeks4geeks article for this week. It explains deeply about deadlocks. Also from this week’s thursday’s pop quiz, I learned that these are the four conditions that must be held for a deadlock to occur:
    • Mutual Exclution
    • Hold and wait
    • No pre-emption
    • Circular wait And here are the solutions on handling deadlocks:
    • Deadlock Prevention
    • Deadlock avoidance
    • Deadlock detection
  10. Detecting Race Conditions With Go
    This article is a mix of my own learning regiment of learning google’s Go and OS topics, race conditions. Warning, this is a very lengthy article, but the reasoning is that it has a TON of code snippets, which I like very much. The example programs are simple counter programs to incur race conditions, but I like the step by step and utilization of go’s Lock and Mutex to solve this problem step by step.

© 2021-2021 --- Jonathan Nicholas --- File Revision: 1.0.0---01-Mar-2021.