Search code examples
algorithmoperating-systemcritical-sectionmutual-exclusion

Starvation algorithm in operating system


Is there an algorithm for mutual exclusion with shared flag variables, as the Peterson's one, that doesn't prevent the starvation ?


Solution

  • Of course. Simply alter the resolution strategy for your flags -- when several consumers have to wait for a resource. Instead of a FIFO queue, use a random selection, or LIFO, or anything that doesn't recognize a long-suffering request's tenure in the request pool.