Compare commits
No commits in common. "6840a8983cf1b235f8c3e7fe27cd5e9736eceaa9" and "b23511edb18cfe6d07d9a51de02dc4b85e248583" have entirely different histories.
6840a8983c
...
b23511edb1
|
@ -178,7 +178,7 @@ namespace Kernel
|
||||||
ASSERT(s_kernel);
|
ASSERT(s_kernel);
|
||||||
ASSERT(paddr);
|
ASSERT(paddr);
|
||||||
|
|
||||||
ASSERT(s_fast_page_lock.current_processor_has_lock());
|
SpinLockGuard _(s_fast_page_lock);
|
||||||
|
|
||||||
constexpr uint64_t pdpte = (fast_page() >> 30) & 0x1FF;
|
constexpr uint64_t pdpte = (fast_page() >> 30) & 0x1FF;
|
||||||
constexpr uint64_t pde = (fast_page() >> 21) & 0x1FF;
|
constexpr uint64_t pde = (fast_page() >> 21) & 0x1FF;
|
||||||
|
@ -198,7 +198,7 @@ namespace Kernel
|
||||||
{
|
{
|
||||||
ASSERT(s_kernel);
|
ASSERT(s_kernel);
|
||||||
|
|
||||||
ASSERT(s_fast_page_lock.current_processor_has_lock());
|
SpinLockGuard _(s_fast_page_lock);
|
||||||
|
|
||||||
constexpr uint64_t pdpte = (fast_page() >> 30) & 0x1FF;
|
constexpr uint64_t pdpte = (fast_page() >> 30) & 0x1FF;
|
||||||
constexpr uint64_t pde = (fast_page() >> 21) & 0x1FF;
|
constexpr uint64_t pde = (fast_page() >> 21) & 0x1FF;
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Kernel
|
||||||
class SharedMemoryObjectManager
|
class SharedMemoryObjectManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Key = size_t;
|
using Key = uint32_t;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static BAN::ErrorOr<void> initialize();
|
static BAN::ErrorOr<void> initialize();
|
||||||
|
|
|
@ -11,12 +11,14 @@ namespace Kernel
|
||||||
static void initialize();
|
static void initialize();
|
||||||
static uint32_t get_u32();
|
static uint32_t get_u32();
|
||||||
static uint64_t get_u64();
|
static uint64_t get_u64();
|
||||||
template<BAN::unsigned_integral T> requires (sizeof(T) == 4)
|
template<typename T>
|
||||||
static T get() { return Random::get_u32(); }
|
static T get();
|
||||||
template<BAN::unsigned_integral T> requires (sizeof(T) == 8)
|
|
||||||
static T get() { return Random::get_u64(); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline uint32_t Random::get<uint32_t>() { return Random::get_u32(); }
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline uint64_t Random::get<uint64_t>() { return Random::get_u64(); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,12 +32,9 @@ namespace Kernel
|
||||||
|
|
||||||
LockGuard _(m_mutex);
|
LockGuard _(m_mutex);
|
||||||
|
|
||||||
// NOTE: don't set the top bit so cast to signed is not negative
|
Key key = Random::get<Key>();
|
||||||
auto generate_key = []() { return Random::get<Key>() & (~(Key)0 >> 1); };
|
|
||||||
|
|
||||||
Key key = generate_key();
|
|
||||||
while (m_objects.contains(key))
|
while (m_objects.contains(key))
|
||||||
key = generate_key();
|
key = Random::get<Key>();
|
||||||
|
|
||||||
TRY(m_objects.insert(key, object));
|
TRY(m_objects.insert(key, object));
|
||||||
return key;
|
return key;
|
||||||
|
|
Loading…
Reference in New Issue