* Port previous ethernet scheme

* Add ipd

* Fix initfs rebuilds, use QEMU user networking addresses in ipd

* Add tcp/udp, netutils, dns, and network config

* Add fsync to network driver

* Add dns, router, subnet by default

* Fix e1000 driver. Make ethernet and IP non-blocking to avoid deadlocks

* Add orbital server, WIP

* Add futex

* Add orbutils and orbital

* Update libstd, orbutils, and orbital
Move ANSI key encoding to vesad

* Add orbital assets

* Update orbital

* Update to add login manager

* Add blocking primitives, block for most things except waitpid, update orbital

* Wait in waitpid and IRQ, improvements for other waits

* Fevent in root scheme

* WIP: Switch to using fevent

* Reorganize

* Event based e1000d driver

* Superuser-only access to some network schemes, display, and disk

* Superuser root and irq schemes

* Fix orbital
This commit is contained in:
Jeremy Soller 2016-10-13 17:21:42 -06:00 • committed by GitHub
commit 224c43f761

View file

@ -16,36 +16,55 @@ pub unsafe fn switch() -> bool {
arch::interrupt::pause();
}
let from_ptr = {
let contexts = contexts();
let context_lock = contexts.current().expect("context::switch: Not inside of context");
let mut context = context_lock.write();
context.deref_mut() as *mut Context
};
let from_ptr;
let mut to_ptr = 0 as *mut Context;
for (pid, context_lock) in contexts().iter() {
if *pid > (*from_ptr).id {
{
let contexts = contexts();
{
let context_lock = contexts.current().expect("context::switch: Not inside of context");
let mut context = context_lock.write();
if context.status == Status::Runnable && ! context.running {
to_ptr = context.deref_mut() as *mut Context;
break;
}
from_ptr = context.deref_mut() as *mut Context;
}
}
if to_ptr as usize == 0 {
for (pid, context_lock) in contexts().iter() {
if *pid < (*from_ptr).id {
let check_context = |context: &mut Context| -> bool {
if context.status == Status::Blocked && context.wake.is_some() {
let wake = context.wake.expect("context::switch: wake not set");
let current = arch::time::monotonic();
if current.0 > wake.0 || (current.0 == wake.0 && current.1 >= wake.1) {
context.unblock();
}
}
if context.status == Status::Runnable && ! context.running {
true
} else {
false
}
};
for (pid, context_lock) in contexts.iter() {
if *pid > (*from_ptr).id {
let mut context = context_lock.write();
if context.status == Status::Runnable && ! context.running {
if check_context(&mut context) {
to_ptr = context.deref_mut() as *mut Context;
break;
}
}
}
}
if to_ptr as usize == 0 {
for (pid, context_lock) in contexts.iter() {
if *pid < (*from_ptr).id {
let mut context = context_lock.write();
if check_context(&mut context) {
to_ptr = context.deref_mut() as *mut Context;
break;
}
}
}
}
};
if to_ptr as usize == 0 {
// Unset global lock if no context found