Code Monkey home page Code Monkey logo

Comments (2)

jinbpark avatar jinbpark commented on July 20, 2024

More generally speaking, what this issue wants to solve is

  • if X is in use, Y must not be freed.

For example, there are multiple RECs in use, the associated RD must not be destroyed even when RMI_REALM_DESTROY called. (error code: RMI_ERROR_IN_USE)

The cases in this category are:

  • RD (REALM_DESTROY): If there are other instances (e.g., Rec) that points to an RD, the RD should not be destroyed.
  • REC (REC_DESTROY): If there are other instances (e.g., Run) that points an REC, the REC should not be destroyed.

from islet.

jinbpark avatar jinbpark commented on July 20, 2024

More concrete scenario:
(1) Create Rd
(2) Create Rec
(3) Destroy Rd --> Check if this Rd's reference count is 1 by (2).

Possible approaches to do:
(1)

// (1) pub struct Rec
pub struct Rec {
    rd: usize,  // the physical address of  rd.
    vcpuid: usize,
    ripas: Ripas,
    id: id,    // we can use this ID as it's guranteed "rd" will not be destroyed as long as this Rec is in use.
}

// (2) we can put "Rec" inside "Granule"

// (3) get Rec (getter)
:: API-style-1
get_granule_object(addr, Rec (type?)) {
    // 1. check if the granule at addr is valid and Rec.
    // 2. If so, it returns something like "PointerMutGuard" in which it is able to directly maps "struct Rec".
    //      -- it increases Rec's reference count itself
    //      -- in order to avoid being destroyed when REC_DESTROY called.
   //       -- after guard ends, it decreases Rec's reference count.
}

:: API-style-2
GranuleObjectPointer  --> it's like HostPointer but related to granule object (Rd/Rec/Run/Data/...)
// can we reuse "HostPointer" for both HostPointer and GranuleObjectPointer, it seems possible.

pub struct GranuleObjectPointer<T> {   // T: struct Rec, struct Rd, ...
    /// pointer to physical region
    ptr: *const T,  // struct Rec, struct Rd,
    /// page_map to map or unmap `ptr` in RMM
    page_map: PageMap,  // --> is it needed??
}

pub fn validate<'a>(&'a self) -> Option<GranuleObjectPointerGuard<'a, T>> {
    // 1. check if the granule at addr is valid and Rec.
    get_granule(...)   // per-struct Accessor needed??? Accessor for Rec...

    if is_valid() {
        increment_reference_count(granule);
        return Guard;
    }
}
fn drop(&mut self) {
    decrement_reference_count();
}
--> it seems fitting in "temporal access" nicely, but not sure for "long-lived ones, like Rec, Rd".
--> for long-lived structs, who holds "GranuleObjectPointerGuard"?




from islet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.