Skip to content

Commit b848fb6

Browse files
committed
Prove ReadGuaed::dro partially
1 parent 9ebf5af commit b848fb6

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

ostd/src/sync/rwlock.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,7 @@ impl<T /*: ?Sized*/, G: SpinGuardian> RwLockReadGuard<'_, T, G>
723723
ghost g => {
724724
let prev_usize = prev as usize;
725725
let next_usize = next as usize;
726+
assume (no_max_reader_overflow(prev_usize));
726727
lemma_consts_properties_value(prev_usize);
727728
lemma_consts_properties_value(next_usize);
728729
lemma_consts_properties_prev_next(prev_usize, next_usize);
@@ -732,6 +733,19 @@ impl<T /*: ?Sized*/, G: SpinGuardian> RwLockReadGuard<'_, T, G>
732733
rem.combine(perm);
733734
rem.bounded();
734735
g.cell_perm_resource.put_resource_left(rem);
736+
let has_writer_bit: bool = (next_usize & WRITER) != 0;
737+
let has_upgrade_bit: bool = (next_usize & UPGRADEABLE_READER) != 0;
738+
let has_max_reader_bit: bool = (next_usize & MAX_READER) != 0;
739+
let total_reader_bits: int = (next_usize & MAX_READER_MASK) as int;
740+
let reader_bits: int = if has_max_reader_bit { MAX_READER as int } else { (next_usize & READER_MASK) as int };
741+
let active_writer: bool = g.cell_perm_resource.is_right();
742+
let remaining_pcell_perms: int = if !active_writer { g.cell_perm_resource.resource()->Left_0.frac() } else { 0 };
743+
let total_active_readers: int = if !active_writer { (V_MAX_PERM_FRACS as int) - remaining_pcell_perms } else { 0 };
744+
let active_upgrade_guard: bool = g.upreader_guard_token.is_empty();
745+
let active_read_guards: int = total_active_readers - if active_upgrade_guard { 1int } else { 0 };
746+
let pending_failed_upread_attempt: bool = g.upread_retract_token.is_empty();
747+
let failed_reader_attempts: int = V_MAX_READ_RETRACT_FRACS - g.read_retract_token.frac();
748+
assert(0<= active_read_guards) by {admit();};
735749
}
736750
);
737751
}

0 commit comments

Comments
 (0)