📓
Everything I Know
  • index
  • #
    • 3D Printing
  • A
    • Abandoned Spaces
    • ADHD
    • Aging
    • Algorithms & Data Structures
      • Array
      • Constraint Satisfaction Problem
      • Dynamic Programming
      • Graph
      • Hash Table
      • Heap
      • Linked List
      • Queue
      • Recursion
      • Set
      • Stack
      • Tree
      • Trie
      • Union Find
    • Amazon Web Services
    • Android
    • Anime, Comics & Manga
    • APIs
    • Artificial Intelligence
    • Assembly
      • ARM
      • MIPS
      • x86
    • Audio / Video Editing
    • Awesome
    • Azure
  • B
    • Board Games
    • Books
  • C
    • C (programming language)
    • C++
    • Cars
    • Cascading Style Sheets
    • Chess
    • Comedy
    • Command Line
      • Autotools
      • Awk
      • Bash scripting
      • Grep
      • Lsof
      • Sed
      • SSH
    • Competitive Programming
    • Compilers
    • Computer Graphics
      • OpenGL
      • Vulkan
      • WebGPU
    • Computer Networks
    • Computer Science
    • Concurrency
    • Continuous Integration / Delivery
    • Cooking
    • Cryptography
    • Cryptocurriencies
    • Curriculum Vitae
  • D
    • Databases
      • PostgreSQL
      • SQL
      • SQLite
    • Design Patterns
    • Digital Minimalism
    • Distributed Systems
    • Docker
    • Documentaries
    • Documentation
    • Domain Name System
    • Dopamine
    • Drawing
  • E
    • eCommerce
    • Electronics
      • Repairs
    • Engineering
    • Entrepreneurship
    • Events
  • F
    • Fashion
    • Fitness
      • Exercise
      • Nutrition
      • Weight Loss
    • Focus
    • Football
  • G
    • Game Development
      • Godot
      • LibGDX
      • Unity
      • Unreal Engine
    • Git
    • Goals
    • Guitar
  • H
    • Habits
    • Happiness
    • House
      • Tradespeople
      • Buying
      • Renting
  • I
    • Interviews
      • Behavioural Interviews
      • Coding Interviews
      • System Design Interviews
  • J
    • Java
    • JavaScript
      • Astro
      • Bun
      • Electron
      • Jest
      • Node.js
      • Nue.js
      • React.js
      • Redux
      • Vue.js
    • Journaling
  • K
    • Karting
    • Knots
    • Knowledge Bases
    • Kotlin
    • Kubernetes
  • L
    • LaTeX
    • Learning
      • Drawing
      • Languages
        • Certificate of Proficiency in English
        • Japanese
      • Piano
    • Legacy Code
    • LEGO
    • Lifestyle
    • Life Hacks
    • Linux
    • LISP
  • M
    • Machine Learning
      • Deep Learning
    • MacOS
    • Maths
    • Meditation
    • Movies
    • Music
      • Music Production
      • Music Theory
  • N
    • Negotiation
    • News
  • O
    • Operating Systems
      • Linux
  • P
    • Parenting
    • Personal Finance
      • ISAs
      • Pensions
    • PHP
    • Physics
    • Podcasts
    • Procrastination
    • Productivity
    • Programming
      • Functional Programming
      • Performance
    • Prometheus
    • Psychology
    • Public Speaking
    • Purpose
    • Puzzles
    • Python
      • Django
      • Pandas
  • Q
    • Quantum Computing
    • Quotes
  • R
    • Regular Expressions
    • Relationships
    • Reverse Engineering
    • Rust
      • Cargo
  • S
    • Security
      • Android
      • Binary Exploitation
      • CompTIA Security+ SYO-701
      • CTFs
      • Forensics
      • Linux
      • Web
      • Windows
    • Self Improvement
    • Shaving
    • Sitting
    • Sleep
    • Social Skills
    • Spring (framework)
    • Stoicism
    • Strength Training
      • Deadlifts
      • Push Ups
    • Success
    • System Design
      • Site Reliability Engineering
  • T
    • Table Tennis
    • Testing
    • Thinking
    • Touch Typing
    • Travel
      • Japan
        • Fukuoka
        • Hiroshima
        • Kyoto
        • Okinawa
        • Osaka
        • Tokyo
      • London
      • Rome
    • TV Series & Programmes
    • Twitch
    • TypeScript
    • Typography
  • V
    • Virtual Tours
    • Vim
    • Video Games
      • Emulation
      • Mods
      • Music
      • Speedrunning
      • Warzone
  • W
    • Web Apps
    • Web Cams
    • Web Development
      • Selenium
      • Web Assembly
    • Windows
      • Windows Development
    • Work
      • Freelancing
      • GitHub Profile
      • Interesting Companies
      • Job Boards
      • Remote Work
      • Startup
    • Writing
Powered by GitBook
On this page
  • Notes
  • Resources
  • Articles
  • Books
  • Images
  • YouTube Videos

Was this helpful?

  1. C

Concurrency

PreviousComputer ScienceNextContinuous Integration / Delivery

Last updated 4 months ago

Was this helpful?

Notes

  • A semaphore is like an integer, with three differences:

    • it can be initialised to any integer value, but the only allowed operations are increment and decrement (you cannot read the current value of the semaphore)

    • when a thread decrements the semaphore, if the result is negative, the thread blocks itself until another thread increments the semaphore

    • when a thread increments the semaphore, if there are other threads blocked, one of them gets unblocked

  • The simplest use for a semaphore is signaling, which means one thread sends a message to another thread to indicate that something has happened.

  • A second common use for a semaphore is to enforce mutual exclusion (mutex) around some portion of the code called critical section. When a single thread is allowed to execute (so the semaphore is initialised with the value 1) we have a mutex, when n threads are allowed to execute we have a multiplex.

  • A rendezvous is a synchronisation problem for which two threads have to reach a certain point in the execution, and neither is allowed to proceed further until both have arrived. The generalisation for n threads instead of just two is called a barrier.

  • A deadlock is a situation in which one thread is holding a resource and waiting for another to be available, while at the same another thread is holding the resource the first thread wants and is waiting on the resource held by the first thread. This situation must be avoided, as it will halt indefinitely the execution of a program.

  • Another situation to avoid as much as possible is called starvation: one or more threads might be waiting forever to enter in a critical section while other threads are able to carry on with theirs. In order to avoid this situation, we enforce a requirement of bounded waiting, which means the time a threads waits on a resource has to be provably finite.

Resources

Articles

  • - Edaqa Mortoray

Books

Images

YouTube Videos

- Katherine Cox-Buday

- Brian Goetz

- Allen B. Downey

- LaurieWired

How does a mutex work? What does it cost?
Concurrency in Go: Tools and Techniques for Developers
Java Concurrency in Practice
The Little Book Of Semaphores
Santa gave me a concurrency problem for Christmas...