Multiprocess programming - Lower Bounds on the Number of Locations

Any deadlock-free Lock algorithm requires allocating and then reading or writing at least n distinct locations in the worst case. This result motivates us to add to our multiprocessor machines,synchronization operations stronger than read-write, and use them as the basis of our mutual exclusion algorithms.

In this section, we observe why this linear bound isherent. The proof requries us to argue about the state of all memory used by a given multithreaded program. I list them as below.

Object's state                           => the state of its fields
Thread's local state                => the state of program counters and local variables
Global state or system state => state of all objects and local states of the threads
Note that the object is independent with threads. The relation is represented as the following graph.

Definition 2.8.1. incosistent

For some global state S = (Sthreads, Slock) which shows that some thread is in the critical section, if the lock object state Slock is compatible with another global state S' = (S'threads, S'lock) in which no thread is in the critical section or is trying to enter the critical section, then we say Slock is in consistent.

Lemma 2.8.1. No deadlock-free Lock algorithm can enter an incosistent state.

    For s and s', if thread B tries to enter the critical section, B cannot determine whether A is in the critical section through reading lock object state.

Definition 2.8.2. covering state

A covering state Scover for a lock object is one in which satisfies that

 - There is at least one thread about to write to each shared location, but

 - The lock object's locations "look" like the CS is empty.

Notice that A is poised to write LA, that is, the writing action will be done by A once A continues to run. Armong lock object's locations, which is LA or LB, depends on th real running.

How to maneuver threads A and B into a covering state?

Assuming that the initial lock object state S0 shows that "Empty Critical Section".

Step 1. Since the lock algorithm is deadlock-free, both thread A and B can enter the CS successfully. Consider an execution in which B runs through the CS 3times. Each time around, it must write some location, so consider the first location it writes when trying to enter the CS. Since there are only two locations, B must write one location twice. Call that location LB.

Let B run until it is poised to write location LB. Then we know the lock object's state is the same with S0[lock], since B has not written the lock object's locations yet.

Step 2. If A runs now, A will enter the CS.

                    If A writes only LB, then

                          Let A enter the CS, and write LB. Then let B write to LB, which will obliterate A's last write. The result is an inconsistent state: B cannot tell whether A is in the critical section.

                    Denote the location that A first write (except for LB) as LA. Let A run until it is poised to write LA. Let B run, obliterating any value A might have written to LB, entering and leaving the CS at most 3 times, and halting just before its second write to LB.

                    In this state, A is about to write LA, B is about to write LB, and the locations are consistent with no thread trying to enter or in the CS, as required in a covering state.

The procedure can be depicted as the following diagram.

REFERENCE: Maurice Herlihy, Nir Shavit.  The Art of Multiprocessor Programming

weixin063传染病防控宣传微信小程序系统的设计与实现+springboot后端毕业源码案例设计 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值