The access protection mechanism can be used to implement page level Answer: locking. Consider reads first. A process is allowed to read a page only after it read-locks the page. This is implemented by using mprotect to initially turn off read permissions to all pages, for the process. When the process tries to access an address in a page, a protection violation occurs. The handler associated with protection violation then requests a read lock on the page, and after the lock is acquired, it uses mprotect to allow read access to the page by the process, and finally allows the process to continue. Write access is handled similarly. Consider a database system that includes an atomic 15.10 increment V operation, in addition to the read and write operations. Let be the value X. of data item The operation C by increment(X) C sets the value ofXtoV+ in an atomic step. The value ofXis not available to the transaction unless the latter executes a read(X). Figure 15.23 shows a lock-compatibility matrix for three lock modes: share mode, exclusive mode, and incrementation mode. a. Show that, if all transactions lock the data that they access in the corresponding mode, then two-phase locking ensures serializability. b. Show that the inclusion of mode locks allows for increased increment concurrency. (Hint: Consider check-clearing transactions in our bank example.) The proof is in Korth, “Locking Primitives in a Database System,” Answer: JACM Vol. 30, 1983. In timestamp ordering,W-timestamp(Q) denotes the largest timestamp 15.11 of any transaction that executed write(Q) successfully. Suppose that, instead, we defined it to be the timestamp of the most recent transaction to execute write(Q) successfully.Would this change in wording make any difference? Explain your answer. It would make no difference. The write protocol is such that the Answer: most recent transaction to write an item is also the one with the largest timestamp to have done so. Use of multiple-granularity locking may require more or fewer locks 15.12 than an equivalent system with a single lock granularity. Provide examples of both situations, and compare the relative amount of concurrency allowed. If a transaction needs to access a large a set of items, multiple Answer: granularity locking requires fewer locks, whereas if only one item needs to
Answer: The access protection mechanism can be used to implement page level locking. Consider reads first. A process is allowed to read a page only after it read-locks the page. This is implemented by using mprotect to initially turn off read permissions to all pages, for the process. When the process tries to access an address in a page, a protection violation occurs. The handler associated with protection violation then requests a read lock on the page, and after the lock is acquired, it uses mprotect to allow read access to the page by the process, and finally allows the process to continue. Write access is handled similarly. 15.10 Consider a database system that includes an atomic increment operation, in addition to the read and write operations. Let V be the value of data item X. The operation increment(X) by C sets the value ofXtoV+ C in an atomic step. The value ofXis not available to the transaction unless the latter executes a read(X). Figure 15.23 shows a lock-compatibility matrix for three lock modes: share mode, exclusive mode, and incrementation mode. a. Show that, if all transactions lock the data that they access in the corresponding mode, then two-phase locking ensures serializability. b. Show that the inclusion of increment mode locks allows for increased concurrency. (Hint: Consider check-clearing transactions in our bank example.) Answer: The proof is in Korth, “Locking Primitives in a Database System,” JACM Vol. 30, 1983. 15.11 In timestamp ordering,W-timestamp(Q) denotes the largest timestamp of any transaction that executed write(Q) successfully. Suppose that, instead, we defined it to be the timestamp of the most recent transaction to execute write(Q) successfully.Would this change in wording make any difference? Explain your answer. Answer: It would make no difference. The write protocol is such that the most recent transaction to write an item is also the one with the largest timestamp to have done so. 15.12 Use of multiple-granularity locking may require more or fewer locks than an equivalent system with a single lock granularity. Provide examples of both situations, and compare the relative amount of concurrency allowed. Answer: If a transaction needs to access a large a set of items, multiple granularity locking requires fewer locks, whereas if only one item needs to
fasl15(kiau-alborz.ir).docx