CHEATSHEET SISTEM OPERASI — BAB 4 (Threads), BAB 5 (Concurrency & Sync), BAB 6 (Deadlock)

BAB 4 — THREADS

1. Process vs Thread

2. Model Proses

3. Keuntungan Thread vs Process

4. Penggunaan Thread (single-user)

5. Thread States

6. Thread Synchronization

Karena semua thread share address space, perubahan resource oleh 1 thread mempengaruhi yang lain ⇒ perlu sinkronisasi (dibahas Bab 5).

7. Jenis Thread

ULT (User-Level Thread): dikelola aplikasi via library; kernel tidak tahu thread.
  • + Switch tanpa mode kernel, scheduling spesifik aplikasi, jalan di OS manapun.
  • System call blocking memblok seluruh proses; tidak bisa multiprocessing.
  • Jacketing = ubah blocking call jadi non-blocking utk atasi kekurangan ULT.
KLT (Kernel-Level Thread): dikelola kernel via API (cth: Windows).
  • + Beberapa thread satu proses bisa di banyak processor; thread blocked tidak blok proses; kernel routine bisa multi-thread.
  • Switch thread butuh mode switch ke kernel (lebih lambat dari ULT).
Combined (cth: Solaris): pembuatan & sebagian besar scheduling di user space, eksekusi di KLT.

8. Hubungan Thread ↔ Process

T:PKeteranganContoh
1:1tiap thread = proses unikUNIX tradisional
M:1banyak thread dalam 1 prosesWindows NT, Solaris, Linux
1:Mthread bisa pindah prosesRa (Clouds), Emerald
M:Nkombinasi M:1 & 1:MTRIX

9. Multicore & Performance

BAB 5 — MUTUAL EXCLUSION & SYNCHRONIZATION

1. Prinsip Concurrency

2. Perhatian OS

3. Critical Section & Mutual Exclusion

4. Dukungan Hardware

5. Semaphore

6. Producer / Consumer Problem

7. Monitor

8. Message Passing

9. Readers / Writers Problem

BAB 6 — DEADLOCK & STARVATION

1. Definisi

2. Kategori Resource

3. Resource Allocation Graph

4. Empat Syarat Deadlock

  1. Mutual Exclusion: hanya 1 proses pakai resource pada satu waktu.
  2. Hold & Wait: proses pegang resource sambil minta resource lain.
  3. No Preemption: resource tidak bisa diambil paksa.
  4. Circular Wait: ada rantai tertutup proses yang masing-masing menunggu resource milik proses berikutnya.

Tiga pertama = kebijakan (kondisi yang mungkin terjadi). Yang ke-4 = kejadian aktual. Semua harus ada agar deadlock terjadi.

5. Strategi Menangani Deadlock

PendekatanKebijakanSkema
PreventionKonservatif (under-commit)Minta semua sekaligus / Preemption / Resource ordering
AvoidanceTengahBanker's algo (cari minimal 1 safe path)
DetectionLiberal (grant sebisanya)Cek periodik & recovery

6. Deadlock Prevention

7. Deadlock Avoidance — Banker's Algorithm

8. Deadlock Detection & Recovery

9. Dining Philosophers

10. Mekanisme Concurrency UNIX