A LIFO is a Temporary Holding Place for thingees - whatever they might be. Those thingees are held in place, in the same order that they were entered or loaded. Example: Push 1/2" marbles into a 1/2" hose. All of the marbles maintain their relative positions.
A FIFO is a Temporary Holding Place for thingees - whatever they might be. Those thingees are held in place, in the same order that they were entered or loaded. Example: Push 1/2" marbles into a 1/2" hose. All of the marbles maintain their relative positions.
Notice that both descriptions, up to this point, are the EXACTLY the same... at least, up 'til now.
Now, you are told, by some loud voice in the sky, to "re-acquire" those thingees, those marbles - in order. (Notice that I didn't use the word "retrieve".)
If you are sharper than those marbles you've been loading, you might ask... "Which order? I could re-acquire those marbles from this-end-of-the-hose or that-end-of-the-hose."
So, the loud voice in the sky that's telling you to get those damned marbles back says, "In the SAME order that you got them". So you go to the far-end-of-the-hose and "re-acquire" the marble-thing-a-ma-bobbers.
That is a FIFO operation.
Or, the loud voice in the sky that's telling you to get those damned marbles back says, "In the REVERSE order that you got them". So you go to the near-end-of-the-hose and "re-acquire" the marble-thing-a-ma-bobbers.
That is a LIFO operation.
NOTICE...
The difference is in "how" those thingees are "re-acquired".
I didn't use the word "retrieve" because the word "retrieve" is "loaded". That is, "retrieve" implies, to a certain degree, that you "re-acquire" the marbles in a particular order - namely, "Reverse Order" - as in LIFO.
Having used the word "re-acquire" instead, the method of retrieval is completely ambiguous and, therefore, no particular method is implied. And so it should be!
You are then forced to consider the specific method that you need; "Last In, First Out", or "First In, Last Out"
FIFO is being a person standing in a check-out line at the grocery store.
LIFO is being a person standing in a "standing-room-only" subway-train.
The real-world applications, in terms of PLC's, are very similar, and, can, in fact, be EXACTLY the same! That is, you just might have a PLC that is monitoring people (or things) going through a Grocery check-out line. You could also have a PLC that is monitoring people with particular ID Numbers entering and exiting a "standing-room-only" subway-train.
In some cases, it's instances of things moving in/out of a que.
In other cases, it's data being placed on a "STACK". That is the way that ASSEMBLY LANGUAGE (which is about as close to Machine-Language as we are likely to get to, these days) handles its data and related instructions.