뮤텍스

공유 자원에 대한 동시 접근을 방지하는 잠금.

A Mutex (short for Mutual Exclusion) is a locking mechanism used to manage access to a shared resource. Only one thread can 'own' a mutex at a time. If a thread wants to use a resource, it must 'lock' the mutex. If the mutex is already locked, the thread's execution is typically blocked until the owner 'unlocks' it.

        graph LR
  Center["뮤텍스"]:::main
  Rel_semaphore["semaphore"]:::related -.-> Center
  click Rel_semaphore "/terms/semaphore"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧠 지식 테스트

1 / 1

🧒 5살도 이해할 수 있게 설명

열쇠가 하나뿐인 화장실을 상상해 보세요. 사용하고 싶으면 열쇠를 가져갑니다. 열쇠를 가지고 있는 동안에는 다른 누구도 들어갈 수 없습니다. 다 쓰면 다른 사람이 쓸 수 있도록 열쇠를 돌려놓습니다.

🤓 Expert Deep Dive

뮤텍스 구현: 스핀락(활성 폴링) 대 블로킹 뮤텍스(스레드 일시 중지). 재진입 뮤텍스는 동일한 스레드에 의한 재획득을 허용합니다. 우선순위 상속 프로토콜은 우선순위 역전 문제를 해결합니다.

📚 출처