Linux sequential lock

  
 

Reading is not blocked, reading and writing is not blocked, write and write blocking, two fields 1. spinlock_t field, blocking write 2. sequence field, write modification, read check, value, etc., or even or not, not equal or Not even, reread equal and old values ​​are even: no writes are equal but old values ​​are odd: the writer reads the sequence value while writing, and is still writing unequal and the old value is even, the new value is odd: Before the writer started reading, but now it has been written and the old value is even, the new value is even: before the writer, start reading, but now the writer has completed and the old value is odd, The new value is odd: in the case that does not occur, this should be equal and the old value is odd, the new value is even: after the writer starts, the reading starts, but now the writer has also completed the write acquisition lock: Write_seqlock: sequence plus 1 write release lock: write_sequnlock: sequence plus 1 read structure: unsigned int seq; do {seq = read_seqbegin(&seqlock); /* critical section */}while (read_seqretry(&seqlock, seq )) Requirements: Not suitable for pointer reader critical section code no Side effects

Copyright © Windows knowledge All Rights Reserved