示例#1
0
void THREAD_POOL::TLS_ELEMENT::WaitSemaphore(bool semaphoreState) const
{
    while (m_semaphore != semaphoreState)
    {
        DelayCurrentThread(0);
    }
    DelayCurrentThread(0); // we use this system call as a memory fence
}
int main()
{

    for (int i = 0; i < NUM_TH; i++)
        CreateOneThread(&threads[i], compute, (void*) (LOOPS + i));

    while (numThreads != NUM_TH)
    {
        DelayCurrentThread(10);
    }
    printf("All threads started running\n");
    fflush(stdout);

    for (int i = 0; i < NUM_TH; i++)
        JoinOneThread(threads[i]);

    exit(0);
}
示例#3
0
bool THREAD_POOL::TLS_ELEMENT::CheckSemaphore() const
{
    bool semaphoreState = m_semaphore;
    DelayCurrentThread(0); // we use this system call as a memory fence
    return semaphoreState;
}
示例#4
0
void THREAD_POOL::TLS_ELEMENT::SwitchSemaphore(bool semaphoreState)
{
    DelayCurrentThread(0); // we use this system call as a memory fence
    m_semaphore = semaphoreState;
}