View on GitHub

os202

OS202

HOME


Top 10 List of Week 07

  1. Race Conditions
    A race condition occurs when processes have concurrent access to shared data and the final result depends on the particular order in which concurrent accesses occur. Race conditions can result in corrupted values of shared data.

  2. Critical-Section Problem
    The critical section is a code segment where the shared variables can be accessed. An atomic action is required in a critical section i.e. only one process can execute in its critical section at a time. All the other processes have to wait to execute in their critical sections.

  3. Critical Section Solutions
    The critical section problem needs a solution to synchronize the different processes. The solution to the critical section problem must satisfy the following conditions:
    • Mutual Exclusion implies that only one process can be inside the critical section at any time. If any other processes require the critical section, they must wait until it is free.
    • Progress means that if a process is not using the critical section, then it should not stop any other process from accessing it. In other words, any process can enter a critical section if it is free.
    • Bounded waiting means that each process must have a limited waiting time. It should not wait endlessly to access the critical section.
  4. Process Synchronization
    Basic idead behind most synchronization: If two threads, processes, interrupt handlers, etc. are going to have conflicting accesses, force one of them wait until it is safe to be proceeded. Synchronization problems are: (1) synchronization can be required for different resources (2) there are different kinds of synchronization problems (3) synchronization may be across machines (4) sometimes it’s not OK to block a thread or process.

  5. Peterson’s Solution
    Peterson’s Solution preserves all three conditions : (1) Mutual Exclusion is assured as only one process can access the critical section at any time. (2) Progress is also assured, as a process outside the critical section does not block other processes from entering the critical section. (3) Bounded Waiting is preserved as every process gets a fair chance.

  6. Sempahore
    Semaphore is simply a variable that is non-negative and shared between threads. A semaphore is a signaling mechanism, and a thread that is waiting on a semaphore can be signaled by another thread. It uses two atomic operations, (1) wait, and (2) signal for the process synchronization. A semaphore either allows or disallows access to the resource, which depends on how it is set up.

  7. When to call it a Deadlock?
    • Mutual Exclusion
    • Hold and Wait
    • Non-pre-emptive
    • Circular Wait Please check the website to discover deadlock in details.
  8. Deadlock in Java Multithreading
    A Java multithreaded program may suffer from the deadlock condition because the synchronized keyword causes the executing thread to block while waiting for the lock, or monitor, associated with the specified object. Please check the website to see example.

  9. Deadlock Handling Method
    • Deadlock ignorance ignores deadlock. This approach is best suitable for a single end user system where User uses the system only for browsing and all other normal stuff.
    • Deadlock prevention: Deadlock happens only when Mutual Exclusion, hold and wait, No preemption and circular wait holds simultaneously. If it is possible to violate one of the four conditions at any time then the deadlock can never occur in the system.
    • Deadlock avoidance, the OS reviews each allocation so that the allocation doesn’t cause the deadlock in the system.
    • Deadlock detection and recovery let the processes fall in deadlock and then periodically check whether deadlock occur in the system or not. If it occurs then it applies some of the recovery methods to the system to get rid of deadlock.
  10. Recovery from Deadlock
    • Process Termination: Metode ini akan menghapus proses-proses yang terlibat pada kondisi deadlock dengan mengacu pada beberapa syarat. Beberapa syarat yang termasuk dalam metode ini adalah, sebagai berikut: ** Menghapus semua proses yang terlibat dalam kondisi deadlock (solusi ini terlalu mahal). ** Menghapus satu persatu proses yang terlibat, sampai kondisi deadlock dapat diatasi (memakan banyak waktu). ** Menghapus proses berdasarkan prioritas, waktu eksekusi, waktu untuk selesai, dan kedalaman dari rollback.
    • Resources Preemption: Metode ini lebih menekankan kepada bagaimana menghambat suatu proses dan sumber daya, agar tidak terjebak pada unsafe condition ** Pilih salah satu - proses dan sumber daya yang akan di-preempt. ** Rollback ke safe state yang sebelumnya telah terjadi. ** Mencegah suatu proses agar tidak terjebak pada starvation karena metode ini.