Orbital (#16)
* 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
2016-10-14 01:21:42 +02:00
|
|
|
use alloc::arc::Arc;
|
|
|
|
use collections::Vec;
|
|
|
|
use spin::{Mutex, RwLock};
|
|
|
|
|
|
|
|
use context::{self, Context};
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct WaitCondition {
|
|
|
|
contexts: Mutex<Vec<Arc<RwLock<Context>>>>
|
|
|
|
}
|
|
|
|
|
|
|
|
impl WaitCondition {
|
|
|
|
pub fn new() -> WaitCondition {
|
|
|
|
WaitCondition {
|
2016-10-21 05:49:47 +02:00
|
|
|
contexts: Mutex::new(Vec::with_capacity(16))
|
Orbital (#16)
* 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
2016-10-14 01:21:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn notify(&self) -> usize {
|
2016-10-21 05:49:47 +02:00
|
|
|
let mut contexts = self.contexts.lock();
|
|
|
|
let len = contexts.len();
|
|
|
|
while let Some(context_lock) = contexts.pop() {
|
Orbital (#16)
* 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
2016-10-14 01:21:42 +02:00
|
|
|
context_lock.write().unblock();
|
|
|
|
}
|
2016-10-21 05:49:47 +02:00
|
|
|
len
|
Orbital (#16)
* 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
2016-10-14 01:21:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn wait(&self) {
|
|
|
|
{
|
|
|
|
let context_lock = {
|
|
|
|
let contexts = context::contexts();
|
|
|
|
let context_lock = contexts.current().expect("WaitCondition::wait: no context");
|
|
|
|
context_lock.clone()
|
|
|
|
};
|
|
|
|
|
|
|
|
context_lock.write().block();
|
|
|
|
|
|
|
|
self.contexts.lock().push(context_lock);
|
|
|
|
}
|
|
|
|
unsafe { context::switch(); }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Drop for WaitCondition {
|
|
|
|
fn drop(&mut self){
|
|
|
|
self.notify();
|
|
|
|
}
|
|
|
|
}
|