haogrgr / haogrgr-test Goto Github PK
View Code? Open in Web Editor NEW用于一些简单的测试用的项目,比如实现某一算发,测试某框架新特性,等等...
License: Apache License 2.0
用于一些简单的测试用的项目,比如实现某一算发,测试某框架新特性,等等...
License: Apache License 2.0
你好,在cancelAcquire的唤醒后继节点的3个条件,第一个条件我是理解的,
我想问一下,为什么第二个条件和第三个条件为什么要唤醒后继节点,第3个条件,pred.pthread != null, 为什么等于null的时候要唤醒?如果是设置为了头节点,为什么当前的cancel节点要去唤醒后继节点,为什么不是持有锁的线程释放锁的时候来唤醒后继节点,如果是cancel节点,因为cancelAcquire一开始过滤cancel节点的时候,pred不是cancel,那么在底下的时候,如果pred的状态变为了cancel,那么已经说明当前线程不可能是pred唤醒的,因为pred醒来的时候,当前线程早已经醒了,所以不会是pred误唤醒了当前线程,还有会存在唤醒的可能是,正常释放锁的时候,会唤醒头节点,那么头节点如果是cancel,然后cancel有可能继续在接下来cancel节点醒来的时候,去唤醒他一次,但是如果是这种情况,那么当前节点在过滤cancel的时候,会过滤掉第一个节点,结果pred变为了head,这样又是不满足第一个条件 pred == head,结果走的不是pred.thread != null这个条件
关于第三个条件,pred.thread != null, 如果这个条件不成立,在release解锁的时候,会唤醒后面的线程,他会忽略cancel节点,所以为什么说唤醒链会断?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.