Revert "Revert "Remove shared_cond and simplify reservation waiting""

This reverts commit b70c08a2e8.
This commit is contained in:
Nekotekina 2019-09-19 02:57:08 +03:00
parent 5ec35c7daa
commit feee3838eb
7 changed files with 3 additions and 349 deletions

View file

@ -17,8 +17,6 @@
#include <thread>
#include <deque>
static_assert(sizeof(shared_cond) == 8, "Unexpected size of shared_cond");
namespace vm
{
static u8* memory_reserve_4GiB(std::uintptr_t _addr = 0)
@ -50,9 +48,6 @@ namespace vm
// Reservation stats (compressed x16)
u8* const g_reservations = memory_reserve_4GiB((std::uintptr_t)g_stat_addr);
// Reservation sync variables
u8* const g_reservations2 = g_reservations + 0x10000000;
// Memory locations
std::vector<std::shared_ptr<block_t>> g_locations;
@ -634,11 +629,9 @@ namespace vm
if (addr == 0x10000)
{
utils::memory_commit(g_reservations, 0x1000);
utils::memory_commit(g_reservations2, 0x1000);
}
utils::memory_commit(g_reservations + addr / 16, size / 16);
utils::memory_commit(g_reservations2 + addr / 16, size / 16);
}
else
{
@ -646,12 +639,10 @@ namespace vm
for (u32 i = 0; i < 6; i++)
{
utils::memory_commit(g_reservations + addr / 16 + i * 0x10000, 0x4000);
utils::memory_commit(g_reservations2 + addr / 16 + i * 0x10000, 0x4000);
}
// End of the address space
utils::memory_commit(g_reservations + 0xfff0000, 0x10000);
utils::memory_commit(g_reservations2 + 0xfff0000, 0x10000);
}
if (flags & 0x100)

View file

@ -14,7 +14,6 @@ namespace vm
extern u8* const g_exec_addr;
extern u8* const g_stat_addr;
extern u8* const g_reservations;
extern u8* const g_reservations2;
struct writer_lock;

View file

@ -21,9 +21,9 @@ namespace vm
}
// Get reservation sync variable
inline shared_cond& reservation_notifier(u32 addr, u32 size)
inline atomic_t<u64>& reservation_notifier(u32 addr, u32 size)
{
return *reinterpret_cast<shared_cond*>(g_reservations2 + addr / 128 * 8);
return reinterpret_cast<atomic_t<u64>*>(g_reservations)[addr / 128];
}
void reservation_lock_internal(atomic_t<u64>&);