Explore core concepts of linearizability and sequential consistency in distributed systems with this beginner-friendly quiz. Sharpen your understanding of consistency models, identify key differences, and apply these principles to sample scenarios involving shared objects and concurrent operations.
Which property defines linearizability in the context of shared objects in distributed systems?
Explanation: Linearizability requires that each operation appears to take effect instantly somewhere between its start and finish, creating a globally valid order. The second option is incorrect because linearizability does not force a fixed global order, just a valid one respecting real-time. The third is wrong since the effect must be visible to all, not just one process. The fourth confuses concurrency; linearizability allows concurrent operations as long as their order follows the rule.
What does sequential consistency guarantee in a multi-process system?
Explanation: Sequential consistency ensures that the overall effect is as if all operations were performed one at a time, in some order, while each process’s operations appear in that sequence in its original order. The second option actually describes a stronger property, like strict consistency. The third option contradicts the shared view required by sequential consistency. The fourth is an exact property of linearizability, not sequential consistency.
In which model must the real-time ordering of operations always be preserved?
Explanation: Linearizability always preserves real-time ordering, ensuring that if one operation completes before another begins, their order is reflected. Sequential consistency does not guarantee this real-time linkage. Eventual consistency is much weaker and does not enforce ordering strictly. Parallel consistency is not a recognized consistency model.
If Process X writes 'A' then Process Y reads 'A', and both operations do not overlap in time, which consistency model guarantees that Y must see 'A'?
Explanation: Linearizability ensures that if the write completes before the read begins, the read must reflect that write. Sequential consistency could allow the read to see a previous value because it does not require real-time constraints. Weak consistency and minimal consistency are less strict and do not offer this guarantee. Only linearizability directly preserves this behavior.
Which statement best describes a scenario allowed under sequential consistency but not under linearizability?
Explanation: Sequential consistency may permit a read to see a stale value if a real-time order is not enforced, while linearizability disallows such outcomes. The second and third options are unrelated to the difference and are not required by either model. The fourth is incorrect, as neither model requires a single fixed global issue order, only a valid one.
What does atomicity mean in the context of linearizability?
Explanation: Atomicity refers to the property that operations are indivisible and appear to take effect instantaneously. The second option is incorrect because processes interact under atomicity. The third option is the opposite of atomicity, allowing splitting. The fourth option is unrelated to atomicity or consistency models.
Which is the main difference between linearizability and sequential consistency?
Explanation: The principal difference is that linearizability enforces real-time operation order while sequential consistency does not. The second statement is incorrect since linearizability is actually stricter. The third describes neither model correctly. The fourth is false because they are distinct models with different requirements.
If a read operation returns an outdated value even after a completed write, which consistency model could permit this?
Explanation: Sequential consistency can, in some situations, allow a read to see an old value if real-time order is not maintained. Linearizability would not permit this as it enforces real-time order. The terms 'absolute consistency' and 'immediate consistency' are not standard or recognized models and thus do not apply here.
Suppose three processes perform operations on a shared counter: increments and reads. Which model ensures that the result of each read operation reflects all completed increments that finished before the read started?
Explanation: Linearizability ensures that any read reflects the effect of all previously completed operations, maintaining real-time guarantees. Sequential consistency might allow a read to miss some completed increments. Probabilistic consistency does not guarantee deterministic outcomes. 'Isolated consistency' is not a standard consistency model.
Why might designers choose sequential consistency over linearizability in a distributed system?
Explanation: Sequential consistency is often simpler to achieve, as it does not enforce real-time order, making it more scalable and efficient in practice. The second statement is false because linearizability requires up-to-date reads within its constraints. The third is untrue since sequential consistency allows exceptions without real-time order. The fourth inverts the relationship; linearizability is stricter, not weaker.