vmem

Crates.iovmem
lib.rsvmem
version1.0.0
sourcesrc
created_at2024-01-12 17:10:25.224154
updated_at2024-01-27 19:12:04.813492
descriptionVmem is a resource management system theorized by Jeff Bonwick and Jonathan Adams in *[Magazines and Vmem: Extending the Slab Allocator to Many CPUs and Arbitrary Resources][1]*. It provides O(1) allocation and deallocation of any opaque numerical 'resource,' such as a block of memory or a process ID.
homepage
repositoryhttps://github.com/lylythechosenone/vmem
max_upload_size
id1097890
size107,425
(lylythechosenone)

documentation

README

What is this?

Vmem is a resource management system theorized by Jeff Bonwick and Jonathan Adams in Magazines and Vmem: Extending the Slab Allocator to Many CPUs and Arbitrary Resources. It provides O(1) allocation and deallocation of any opaque numerical "resource," such as a block of memory or a process ID.

This particular implementation provides a safe vmem allocator for use inside of my custom kernel, velvet. I am additionally submitting it as my AP Computer Science Principles Create Task. It aims to conform exactly to the spec laid out in the aformentioned paper, however, some changes may have been made for pure practicality.

What's missing?

Quantum caches were left out of this implementation because they would be more easily implemented inside of a more specific heap allocator. However, it is still recommended to cache allocations, especially on arenas which are used as sources.

Additionally, constrained allocations with [AllocPolicy::NextFit] are not supported, simply because this is not incredibly useful, despite taking a non-trivial amount of work to implement.

Crate features

  • nightly - enables an implementation of [alloc::Allocator] for all types that also implement [core::alloc::Allocator].
  • std - enables an implementation of [lock::Lock] for [std::sync::Mutex]
  • spin - enables an implementation of [lock::Lock] for [spin::Mutex]

References

This crate was written with reference to xvanc's Rust implementation, as well as the NetBSD C implementation it references. No code was directly copied, and any found issues were corrected. Both of the above implementations were designed to be placed inside of the kernel that they were written for. In contrast, this implementation is designed to work in nearly any environment (it even works in userspace, as seen in the tests!)

Reporting issues

If you find any issues with this crate, including bugs, memory leaks, panics (other than the one listed for xalloc below), or undefined behavior, please open an issue on the GitHub repository.

Licensing

This crate is licensed under your choice of either of the MIT or Apache 2.0 licenses.

Commit count: 0

cargo fmt