Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions src/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ where
{
if let Some(mut guard) = crate::executor::network::NIC.try_lock() {
let delay = if let Ok(nic) = guard.as_nic_mut() {
nic.set_polling_mode(false);

nic.poll_delay(Instant::from_micros_const(now.try_into().unwrap()))
.map(|d| d.total_micros())
} else {
Expand All @@ -178,10 +180,6 @@ where
delay.map(|d| crate::arch::processor::get_timer_ticks() + d),
);
}

if let Ok(device) = crate::executor::network::NIC.lock().as_nic_mut() {
device.set_polling_mode(false);
}
}

return t;
Expand All @@ -195,6 +193,8 @@ where
{
if let Some(mut guard) = crate::executor::network::NIC.try_lock() {
let delay = if let Ok(nic) = guard.as_nic_mut() {
nic.set_polling_mode(false);

nic.poll_delay(Instant::from_micros_const(now.try_into().unwrap()))
.map(|d| d.total_micros())
} else {
Expand All @@ -204,10 +204,6 @@ where
delay.map(|d| crate::arch::processor::get_timer_ticks() + d),
);
}

if let Ok(device) = crate::executor::network::NIC.lock().as_nic_mut() {
device.set_polling_mode(false);
}
}

return Err(Errno::Time);
Expand All @@ -217,6 +213,8 @@ where
if backoff.is_completed() {
let delay = if let Some(mut guard) = crate::executor::network::NIC.try_lock() {
if let Ok(nic) = guard.as_nic_mut() {
nic.set_polling_mode(false);

nic.poll_delay(Instant::from_micros_const(now.try_into().unwrap()))
.map(|d| d.total_micros())
} else {
Expand All @@ -233,17 +231,12 @@ where
let wakeup_time =
timeout.map(|duration| start + u64::try_from(duration.as_micros()).unwrap());

// allow network interrupts
if let Ok(device) = crate::executor::network::NIC.lock().as_nic_mut() {
device.set_polling_mode(false);
}

// switch to another task
task_notify.wait(wakeup_time);

// restore default values
if let Ok(device) = crate::executor::network::NIC.lock().as_nic_mut() {
device.set_polling_mode(true);
if let Ok(nic) = crate::executor::network::NIC.lock().as_nic_mut() {
nic.set_polling_mode(true);
}

backoff.reset();
Expand Down