Skip to content

Commit c20d18f

Browse files
authored
Disable/Enable Local APIC timer upon preemption change (#839)
* This was temporarily removed in #835, but it now works again thanks to #838.
1 parent ca05e3f commit c20d18f

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

kernel/preemption/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ pub fn hold_preemption() -> PreemptionGuard {
4444

4545
// When transitioning from preemption being enabled to disabled,
4646
// we must disable the local APIC timer used for preemptive task switching.
47-
// apic::get_my_apic()
48-
// .expect("BUG: hold_preemption() couldn't get local APIC")
49-
// .write()
50-
// .enable_lvt_timer(false);
47+
apic::get_my_apic()
48+
.expect("BUG: hold_preemption() couldn't get local APIC")
49+
.write()
50+
.enable_lvt_timer(false);
5151
} else if prev_val == u8::MAX {
5252
// Overflow occurred and the counter value wrapped around, which is a bug.
5353
panic!("BUG: Overflow occurred in the preemption counter for CPU {}", cpu_id);
@@ -120,10 +120,10 @@ impl Drop for PreemptionGuard {
120120
// If the previous counter value was 1, that means the current value is 1,
121121
// which indicates we are transitioning from preemption disabled to enabled on this CPU.
122122
// Thus, we re-enable the local APIC timer used for preemptive task switching.
123-
// apic::get_my_apic()
124-
// .expect("BUG: PreemptionGuard::drop() couldn't get local APIC")
125-
// .write()
126-
// .enable_lvt_timer(true);
123+
apic::get_my_apic()
124+
.expect("BUG: PreemptionGuard::drop() couldn't get local APIC")
125+
.write()
126+
.enable_lvt_timer(true);
127127
} else if prev_val == 0 {
128128
// Underflow occurred and the counter value wrapped around, which is a bug.
129129
panic!("BUG: Underflow occurred in the preemption counter for CPU {}", cpu_id);

0 commit comments

Comments
 (0)