BIT202 · 2080 · 10 marks
Define serial, non-serial and serializable schedules with example. How can you test serializability in a schedule? Explain with an example.
Define serial, non-serial and serializable schedules with example. How can you test serializability in a schedule? Explain with an example.[10]
Quick answer
A serial schedule is one in which transactions are executed one after another, without any interleaving of operations. One transaction must complete entirely before the next one begins.
Serial, Non-Serial, and Serializable Schedules
1. Serial Schedule
Properties:
- No concurrency
- Always consistent (correct by definition)
- Poor performance due to no overlap
Example:
| Step | T1 | T2 |
|---|---|---|
| 1 | Read(A) | |
| 2 | Write(A) | |
| 3 | Read(B) | |
| 4 | Write(B) | |
| 5 | Read(A) | |
| 6 | Write(A) | |
| 7 | Read(B) | |
| 8 | Write(B) |
Here T1 executes completely before T2 starts. This is a serial schedule: T1 → T2.
2. Non-Serial Schedule
A non-serial schedule is one in which operations of multiple transactions are interleaved with each other. Transactions execute concurrently.
Properties:
- Allows concurrency and better throughput
- May or may not produce consistent results
- Not all non-serial schedules are correct
Example:
| Step | T1 | T2 |
|---|---|---|
| 1 | Read(A) | |
| 2 | Read(A) | |
| 3 | Write(A) | |
| 4 | Write(A) | |
| 5 | Read(B) | |
| 6 | Write(B) | |
| 7 | Read(B) | |
| 8 | Write(B) |
Here operations of T1 and T2 are interleaved. This is a non-serial schedule.
3. Serializable Schedule
A serializable schedule is a non-serial schedule that produces the same result as some serial schedule of the same transactions. It is the standard criterion for correctness of concurrent execution.
A non-serial schedule S is serializable if it is equivalent to some serial schedule.
Types of Serializability:
- Conflict Serializability (most commonly tested)
- View Serializability
4. Testing Serializability: Precedence Graph (Conflict Graph) Method
Concept of Conflicting Operations
Two operations conflict if:
- They belong to different transactions
- They access the same data item
- At least one of them is a Write
| Operation Pair | Conflict? |
|---|---|
| Read(X) - Read(X) | No |
| Read(X) - Write(X) | Yes |
| Write(X) - Read(X) | Yes |
| Write(X) - Write(X) | Yes |
Steps to Test Conflict Serializability
Step 1: Identify all pairs of conflicting operations between different transactions.
Step 2: Build a Precedence Graph (Serialization Graph):
- One node for each transaction
- Draw a directed edge from Ti → Tj if an operation of Ti conflicts with an operation of Tj, and Ti's operation appears before Tj's operation in the schedule
Step 3: Check for cycles in the graph:
- No cycle → Schedule is conflict serializable
- Cycle exists → Schedule is NOT conflict serializable
Worked Example
Consider the following schedule S with transactions T1, T2, T3:
| Step | T1 | T2 | T3 |
|---|---|---|---|
| 1 | Read(X) | ||
| 2 | Read(X) | ||
| 3 | Write(X) | ||
| 4 | Read(X) | ||
| 5 | Read(Y) | ||
| 6 | Write(Y) | ||
| 7 | Write(Y) | ||
| 8 | Write(X) |
Step 1: Identify Conflicting Pairs
| Conflict | Operations | Edge |
|---|---|---|
| T2: Write(X) before T1: Read(X) | Both on X, Write involved | T2 → T1 |
| T1: Read(X) at step 1 before T2: Write(X) at step 3 | Both on X, Write involved | T1 → T2 |
| T2: Write(Y) before T3: Write(Y) | Both on Y, Write involved | T2 → T3 |
| T3: Read(Y) before T2: Write(Y) | Both on Y, Write involved | T3 → T2 |
Step 2: Draw Precedence Graph
T1 ---------> T2
^ |
| v
+---- T2 T3 <----> T2
More precisely:
- T1 → T2 (T1 reads X before T2 writes X)
- T2 → T1 (T2 writes X before T1 reads X at step 4)
- T2 → T3 (T2 writes Y before T3 writes Y)
- T3 → T2 (T3 reads Y before T2 writes Y)
Step 3: Check for Cycles
- T1 → T2 → T1 forms a cycle
- T2 → T3 → T2 forms a cycle
Conclusion: The schedule contains cycles in the precedence graph, therefore it is NOT conflict serializable.
Example of a Serializable Schedule
| Step | T1 | T2 |
|---|---|---|
| 1 | Read(A) | |
| 2 | Write(A) | |
| 3 | Read(A) | |
| 4 | Write(A) | |
| 5 | Read(B) | |
| 6 | Write(B) |
**Conflicting
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.