多線程之常見問題

死鎖產生條件

  1. Mutual Exclusion: Only one process can access a resource at a given time. Or, more accurately, there is limited access to a resource. A deadlock could also occur if a resource has limited quantity.
  2. Hold and wait: Processes already holding a resource can request additional resources, without relinquishing their current resources
  3. No preemption: One process cannot forcibly remove another process' resource
  4. Circular wait: Two or more processes form a circular chain where each process is waiting on another resource in the chain

Questions:

Thread vs. Process

Difference between thread and process

Context Switch

How would you measure the time spent in a context switch?

Dining Philosophers

Deadlock-Free Class

擴展閱讀

ping pong測試

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。