Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[runtime] Enhancement: Use runtime instead of libos #1058

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
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
34 changes: 2 additions & 32 deletions src/rust/catcollar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,8 @@ use crate::{
QToken,
QType,
},
scheduler::{
TaskHandle,
Yielder,
},
types::{
demi_qresult_t,
demi_sgarray_t,
},
scheduler::Yielder,
types::demi_sgarray_t,
DemiRuntime,
SharedDemiRuntime,
},
Expand Down Expand Up @@ -663,30 +657,6 @@ impl CatcollarLibOS {
}
}

pub fn poll(&mut self) {
self.runtime.poll()
}

pub fn schedule(&mut self, qt: QToken) -> Result<TaskHandle, Fail> {
self.runtime.from_task_id(qt.into())
}

pub fn pack_result(&mut self, handle: TaskHandle, qt: QToken) -> Result<demi_qresult_t, Fail> {
self.runtime.remove_coroutine_and_get_result(&handle, qt.into())
}

/// Allocates a scatter-gather array.
pub fn sgaalloc(&self, size: usize) -> Result<demi_sgarray_t, Fail> {
trace!("sgalloc() size={:?}", size);
self.runtime.alloc_sgarray(size)
}

/// Frees a scatter-gather array.
pub fn sgafree(&self, sga: demi_sgarray_t) -> Result<(), Fail> {
trace!("sgafree()");
self.runtime.free_sgarray(sga)
}

fn get_shared_queue(&self, qd: &QDesc) -> Result<CatcollarQueue, Fail> {
Ok(self.runtime.get_shared_queue::<CatcollarQueue>(qd)?.clone())
}
Expand Down
29 changes: 2 additions & 27 deletions src/rust/catloop/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ use crate::{
Yielder,
YielderHandle,
},
types::demi_qresult_t,
Operation,
OperationResult,
QDesc,
Expand Down Expand Up @@ -124,10 +123,11 @@ impl SharedCatloopLibOS {
};

// Create fake socket.
let runtime: SharedDemiRuntime = self.runtime.clone();
let catmem: SharedCatmemLibOS = self.catmem.clone();
let qd: QDesc = self
.runtime
.alloc_queue::<SharedCatloopQueue>(SharedCatloopQueue::new(qtype, catmem)?);
.alloc_queue::<SharedCatloopQueue>(SharedCatloopQueue::new(qtype, runtime, catmem)?);
Ok(qd)
}

Expand Down Expand Up @@ -471,31 +471,6 @@ impl SharedCatloopLibOS {
}
}

/// Allocates a scatter-gather array.
pub fn sgaalloc(&self, size: usize) -> Result<demi_sgarray_t, Fail> {
self.runtime.alloc_sgarray(size)
}

/// Releases a scatter-gather array.
pub fn sgafree(&self, sga: demi_sgarray_t) -> Result<(), Fail> {
self.runtime.free_sgarray(sga)
}

/// Inserts a queue token into the scheduler.
pub fn schedule(&mut self, qt: QToken) -> Result<TaskHandle, Fail> {
self.runtime.from_task_id(qt.into())
}

/// Constructs an operation result from a scheduler handler and queue token pair.
pub fn pack_result(&mut self, handle: TaskHandle, qt: QToken) -> Result<demi_qresult_t, Fail> {
self.runtime.remove_coroutine_and_get_result(&handle, qt.into())
}

/// Polls scheduling queues.
pub fn poll(&mut self) {
self.runtime.poll()
}

fn get_queue(&self, qd: &QDesc) -> Result<SharedCatloopQueue, Fail> {
Ok(self.runtime.get_qtable().get::<SharedCatloopQueue>(qd)?.clone())
}
Expand Down
9 changes: 5 additions & 4 deletions src/rust/catloop/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use crate::{
OperationResult,
QDesc,
QToken,
SharedDemiRuntime,
SharedObject,
},
};
Expand Down Expand Up @@ -60,10 +61,10 @@ pub struct SharedCatloopQueue(SharedObject<CatloopQueue>);

impl CatloopQueue {
/// Allocates a new Catloop queue.
pub fn new(qtype: QType, catmem: SharedCatmemLibOS) -> Result<Self, Fail> {
pub fn new(qtype: QType, runtime: SharedDemiRuntime, catmem: SharedCatmemLibOS) -> Result<Self, Fail> {
Ok(Self {
qtype,
socket: Socket::new(catmem)?,
socket: Socket::new(runtime, catmem)?,
})
}

Expand All @@ -75,8 +76,8 @@ impl CatloopQueue {

impl SharedCatloopQueue {
/// Allocates a new shared Catloop queue.
pub fn new(qtype: QType, catmem: SharedCatmemLibOS) -> Result<Self, Fail> {
Ok(Self(SharedObject::new(CatloopQueue::new(qtype, catmem)?)))
pub fn new(qtype: QType, runtime: SharedDemiRuntime, catmem: SharedCatmemLibOS) -> Result<Self, Fail> {
Ok(Self(SharedObject::new(CatloopQueue::new(qtype, runtime, catmem)?)))
}

/// Returns the local address to which the target queue is bound.
Expand Down
Loading