11 January 2021

Starvation

  • Starvation describes a situation where a greedy thread holds a resource for a long time so other threads are blocked forever. 
  • The blocked threads are waiting to acquire the resource but they never get a chance. Thus they starve to death.

  • Starvation can occur due to the following reasons:

    • Threads are blocked infinitely because a thread takes long time to execute some synchronized code (e.g. heavy I/O operations or infinite loop).
    • A thread doesn’t get CPU’s time for execution because it has low priority as compared to other threads which have higher priority.
    • Threads are waiting on a resource forever but they remain waiting forever because other threads are constantly notified instead of the hungry ones.

  • When a starvation situation occurs, the program is still running but doesn’t run to completion because some threads are not executed.
  • Deadlock:  All threads are blocked, the program hangs forever.
  • Livelock: No threads blocked but they run into infinite loops. The program is still running but unable to make further progress.
  • Starvation: Only one thread is running, and other threads are waiting forever.

No comments:

Post a Comment

Most views on this month