Esempio n. 1
0
static void parititonAllocBaseInit(PartitionRootBase* root)
{
    ASSERT(!root->initialized);

    spinLockLock(&PartitionRootBase::gInitializedLock);
    if (!PartitionRootBase::gInitialized) {
        PartitionRootBase::gInitialized = true;
        // We mark the seed page as free to make sure it is skipped by our
        // logic to find a new active page.
        PartitionRootBase::gPagedBucket.activePagesHead = &PartitionRootGeneric::gSeedPage;
    }
    spinLockUnlock(&PartitionRootBase::gInitializedLock);

    root->initialized = true;
    root->totalSizeOfSuperPages = 0;
    root->nextSuperPage = 0;
    root->nextPartitionPage = 0;
    root->nextPartitionPageEnd = 0;
    root->firstExtent = 0;
    root->currentExtent = 0;

    memset(&root->globalEmptyPageRing, '\0', sizeof(root->globalEmptyPageRing));
    root->globalEmptyPageRingIndex = 0;

    // This is a "magic" value so we can test if a root pointer is valid.
    root->invertedSelf = ~reinterpret_cast<uintptr_t>(root);
}
static void threadMain(volatile char* buffer)
{
    for (int i = 0; i < 500000; ++i) {
        spinLockLock(&lock);
        changeAndCheckBuffer(buffer);
        spinLockUnlock(&lock);
    }
}
Esempio n. 3
0
void Partitions::initialize()
{
    static int lock = 0;
    // Guard against two threads hitting here in parallel.
    spinLockLock(&lock);
    if (!s_initialized) {
        m_bufferAllocator.init();
        s_initialized = true;
    }
    spinLockUnlock(&lock);
}
Esempio n. 4
0
void Partitions::initialize()
{
    spinLockLock(&s_initializationLock);

    if (!s_initialized) {
        partitionAllocGlobalInit(&Partitions::handleOutOfMemory);
        m_fastMallocAllocator.init();
        m_bufferAllocator.init();
        m_nodeAllocator.init();
        m_layoutAllocator.init();
        s_initialized = true;
    }

    spinLockUnlock(&s_initializationLock);
}
void Partitions::shutdown()
{
    spinLockLock(&s_initializationLock);

    // We could ASSERT here for a memory leak within the partition, but it leads
    // to very hard to diagnose ASSERTs, so it's best to leave leak checking for
    // the valgrind and heapcheck bots, which run without partitions.
    if (s_initialized) {
        (void) m_layoutAllocator.shutdown();
        (void) m_nodeAllocator.shutdown();
        (void) m_bufferAllocator.shutdown();
        (void) m_fastMallocAllocator.shutdown();
    }

    spinLockUnlock(&s_initializationLock);
}
Esempio n. 6
0
uint32_t ranval(ranctx* x)
{
    spinLockLock(&x->lock);
    if (UNLIKELY(!x->initialized)) {
        x->initialized = true;
        char c;
        uint32_t seed = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(&c));
        seed ^= static_cast<uint32_t>(getCurrentProcessID());
        x->a = 0xf1ea5eed;
        x->b = x->c = x->d = seed;
        for (int i = 0; i < 20; ++i) {
            (void) ranvalInternal(x);
        }
    }
    uint32_t ret = ranvalInternal(x);
    spinLockUnlock(&x->lock);
    return ret;
}