Compare commits
3 Commits
b23511edb1
...
6840a8983c
Author | SHA1 | Date |
---|---|---|
Bananymous | 6840a8983c | |
Bananymous | a1b3490764 | |
Bananymous | 076f1efecb |
|
@ -178,7 +178,7 @@ namespace Kernel
|
||||||
ASSERT(s_kernel);
|
ASSERT(s_kernel);
|
||||||
ASSERT(paddr);
|
ASSERT(paddr);
|
||||||
|
|
||||||
SpinLockGuard _(s_fast_page_lock);
|
ASSERT(s_fast_page_lock.current_processor_has_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);
|
||||||
|
|
||||||
SpinLockGuard _(s_fast_page_lock);
|
ASSERT(s_fast_page_lock.current_processor_has_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 = uint32_t;
|
using Key = size_t;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static BAN::ErrorOr<void> initialize();
|
static BAN::ErrorOr<void> initialize();
|
||||||
|
|
|
@ -11,14 +11,12 @@ 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<typename T>
|
template<BAN::unsigned_integral T> requires (sizeof(T) == 4)
|
||||||
static T get();
|
static T get() { return Random::get_u32(); }
|
||||||
|
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,9 +32,12 @@ namespace Kernel
|
||||||
|
|
||||||
LockGuard _(m_mutex);
|
LockGuard _(m_mutex);
|
||||||
|
|
||||||
Key key = Random::get<Key>();
|
// NOTE: don't set the top bit so cast to signed is not negative
|
||||||
|
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 = Random::get<Key>();
|
key = generate_key();
|
||||||
|
|
||||||
TRY(m_objects.insert(key, object));
|
TRY(m_objects.insert(key, object));
|
||||||
return key;
|
return key;
|
||||||
|
|
Loading…
Reference in New Issue