Back to articles
What is FiFo algo?

What is FiFo algo?

via Dev.to WebdevAnk

* Algorithm: FIFO (First In, First Out) Ticket Algorithm * Objective: To ensure that processes (or threads) access a shared resource in the exact order they requested it — maintaining fairness and avoiding starvation. Concept Overview The FIFO Ticket Algorithm is a synchronization mechanism used in concurrent systems. Each process gets a ticket number when it requests access to a critical section. Processes are served in increasing order of their ticket numbers — just like people waiting in line for tickets. Data Structures ticket: A shared integer counter that gives out unique ticket numbers. turn: A shared integer indicating the ticket number currently being served. my_ticket[i]: The ticket number assigned to process i. Initialization ticket = 0 turn = 0 for each process i: my_ticket[i] = -1 Algorithm Steps Step 1: Request Entry (Entering Critical Section) my_ticket[i] = FetchAndIncrement(ticket) // Atomically assign a unique ticket number to process i while (my_ticket[i] != turn): w

Continue reading on Dev.to Webdev

Opens in a new tab

Read Full Article
6 views

Related Articles