diff options
| author | Matteo Gmür <matteo.gmuer1@ost.ch> | 2024-11-26 09:49:06 +0000 |
|---|---|---|
| committer | Matteo Gmür <matteo.gmuer1@ost.ch> | 2024-11-26 09:49:06 +0000 |
| commit | d2aa4fbf948a56df5328e0f1b8ec3dfd52b16e13 (patch) | |
| tree | 8a6e8ffcb1f92af994103055a47de10c0a7bbd3d /arch/x86_64/include | |
| parent | eada7bbb150fd81e6fbf71b1df28c8dc19393cfa (diff) | |
| download | teachos-d2aa4fbf948a56df5328e0f1b8ec3dfd52b16e13.tar.xz teachos-d2aa4fbf948a56df5328e0f1b8ec3dfd52b16e13.zip | |
Make bump allocator atomic and therefore thread safe
Diffstat (limited to 'arch/x86_64/include')
| -rw-r--r-- | arch/x86_64/include/arch/memory/heap/bump_allocator.hpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/arch/x86_64/include/arch/memory/heap/bump_allocator.hpp b/arch/x86_64/include/arch/memory/heap/bump_allocator.hpp index d31783d..595eeea 100644 --- a/arch/x86_64/include/arch/memory/heap/bump_allocator.hpp +++ b/arch/x86_64/include/arch/memory/heap/bump_allocator.hpp @@ -1,6 +1,7 @@ #ifndef TEACHOS_ARCH_X86_64_MEMORY_HEAP_BUMP_ALLOCATOR_HPP #define TEACHOS_ARCH_X86_64_MEMORY_HEAP_BUMP_ALLOCATOR_HPP +#include <atomic> #include <cstdint> namespace teachos::arch::memory::heap @@ -44,9 +45,9 @@ namespace teachos::arch::memory::heap auto deallocate(uint8_t * pointer, std::size_t size) -> void; private: - std::size_t heap_start; ///< Start of the allocatable heap area - std::size_t heap_end; ///< End of the allocatable heap area - std::size_t next; ///< Current address, which is the start of still unused allocatable heap area + std::size_t heap_start; ///< Start of the allocatable heap area + std::size_t heap_end; ///< End of the allocatable heap area + std::atomic_uint64_t next; ///< Current address, which is the start of still unused allocatable heap area }; } // namespace teachos::arch::memory::heap |
