Comments (4)
Instead of a lock-free allocator, which is likely impossible, I think a better solution is to use a separate allocator for allocations that occur in interrupt contexts. This is now possible with Rust's new allocator_api
feature that allows you to allocate something using a specific allocator rather than just the global default.
rust-lang/rust#32838
For example, we can use Box::new_in(object, InterruptSafeAllocator)
instead of just Box::new(obj)
. See this: https://doc.rust-lang.org/alloc/boxed/struct.Box.html#method.new_in
from theseus.
another allocator here: https://github.com/gz/rust-slabmalloc
from theseus.
https://crates.io/crates/buddy_system_allocator
from theseus.
Instead of a lock-free allocator, which is likely impossible,
why is lock-free allocator likely impossible?
Heap allocations are horribly expensive right now because the Heap acquires an Irq-safe Mutex lock, which disables interrupts for the duration of a heap allocation.
The root issue we're trying to solve is to make the heap allocations use resources more efficiently. Can we break down the resource usage of the heap allocations into all the different cases/categories? Perhaps doing so may help us identify bottlenecks
IRQ safety (disabling interrupts) exists for a reason: it prevent race conditions in case two interrupt handlers try to access the same resource. This kind of memory safety is one of the main reasons we're introducing TheseusOS as a better alternative to OS:es based on C/C++. Ideally, we should identify when the interrupt disabling is needed and when it's not needed. That way, we can apply the interrupt disabling in cases where it's needed to prevent race conditions, while avoiding unnecessary resource waste outside of those cases (the number of interrupt handlers able to access CPU can be viewed as a resource).
The key question we need to answer is:
- When does IRQ-unsafe heap allocation risk race conditions?
from theseus.
Related Issues (20)
- Experiment with using `tracing` instead of `log`
- Attempt to remove runtime `match` statement for `Frames` const generic state HOT 1
- Follow-up improvements to aarch64 FIQ support HOT 1
- Does not get as far as shell prompt on AArch64 HOT 7
- Theseus fails to boot if built on non-English locale HOT 5
- Use MMIO mechanism to access PCI [extended] config space on x86_64
- make: *** [cargo] Error 101 HOT 9
- mlx3
- Use Cargo's workspace dependency feature
- Replace Round Robin scheduling with The Multi-Level Feedback Queue
- Eliminate CPU waste HOT 1
- Upcoming `tlb_shootdown` improvements HOT 1
- Add tests for `async_channel` HOT 1
- Build and publish Theseus documentation for aarch64 HOT 1
- `test_channel` bug (deadlock?) HOT 1
- Makefile error: `multiple target patterns. Stop.` HOT 1
- Finish porthole, our new graphics api (and window manager)
- Potential infinite loop bug in ixgbe driver HOT 5
- Switch all bitfields to bilge, take notes HOT 2
- page_allocator: use `RbTree`'s `Entry` API for deallocation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from theseus.