Skip to content

Commit 303099c

Browse files
committed
std: xous: add ticktimer_server as a service
Add a service connection for the ticktimer server. This server is used when managing process time, such as when sleeping a thread for a given amount of time. It is also used for locks, such as Condvar and Mutex. Signed-off-by: Sean Cross <[email protected]>
1 parent ac0b44f commit 303099c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

library/std/src/os/xous/services.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,17 @@ pub(crate) fn log_server() -> Connection {
125125
LOG_SERVER_CONNECTION.store(cid.into(), Ordering::Relaxed);
126126
cid
127127
}
128+
129+
/// Return a `Connection` to the ticktimer server. This server is used for synchronization
130+
/// primitives such as sleep, Mutex, and Condvar.
131+
pub(crate) fn ticktimer_server() -> Connection {
132+
static TICKTIMER_SERVER_CONNECTION: AtomicU32 = AtomicU32::new(0);
133+
let cid = TICKTIMER_SERVER_CONNECTION.load(Ordering::Relaxed);
134+
if cid != 0 {
135+
return cid.into();
136+
}
137+
138+
let cid = crate::os::xous::ffi::connect("ticktimer-server".try_into().unwrap()).unwrap();
139+
TICKTIMER_SERVER_CONNECTION.store(cid.into(), Ordering::Relaxed);
140+
cid
141+
}

0 commit comments

Comments
 (0)