Skip to content
Snippets Groups Projects
Commit c06f403d authored by Liam Naddell's avatar Liam Naddell
Browse files

second round of documentation

parent 9d1fb301
No related branches found
No related tags found
1 merge request!95Add more documentation to the redox kernel
...@@ -70,6 +70,8 @@ fn init_contexts() -> RwLock<ContextList> { ...@@ -70,6 +70,8 @@ fn init_contexts() -> RwLock<ContextList> {
/// Get the global schemes list, const /// Get the global schemes list, const
pub fn contexts() -> RwLockReadGuard<'static, ContextList> { pub fn contexts() -> RwLockReadGuard<'static, ContextList> {
//call once will init_contexts only once during the kernel's exececution, otherwise it will return the current context via a
//cache.
CONTEXTS.call_once(init_contexts).read() CONTEXTS.call_once(init_contexts).read()
} }
......
...@@ -170,6 +170,11 @@ pub fn syscall(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize, bp: u ...@@ -170,6 +170,11 @@ pub fn syscall(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize, bp: u
} }
*/ */
// The next lines set the current syscall in the context struct, then once the inner() function
// completes, we set the current syscall to none.
//
// When the code below falls out of scope it will release the lock
// see the spin crate for details
{ {
let contexts = ::context::contexts(); let contexts = ::context::contexts();
if let Some(context_lock) = contexts.current() { if let Some(context_lock) = contexts.current() {
......
...@@ -16,7 +16,9 @@ pub fn clock_gettime(clock: usize, time: &mut TimeSpec) -> Result<usize> { ...@@ -16,7 +16,9 @@ pub fn clock_gettime(clock: usize, time: &mut TimeSpec) -> Result<usize> {
Ok(0) Ok(0)
} }
/// Nanosleep will sleep by switching the current context
pub fn nanosleep(req: &TimeSpec, rem_opt: Option<&mut TimeSpec>) -> Result<usize> { pub fn nanosleep(req: &TimeSpec, rem_opt: Option<&mut TimeSpec>) -> Result<usize> {
//start is a tuple of (seconds, nanoseconds)
let start = time::monotonic(); let start = time::monotonic();
let sum = start.1 + req.tv_nsec as u64; let sum = start.1 + req.tv_nsec as u64;
let end = (start.0 + req.tv_sec as u64 + sum / 1_000_000_000, sum % 1_000_000_000); let end = (start.0 + req.tv_sec as u64 + sum / 1_000_000_000, sum % 1_000_000_000);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment