_WriteBarrier not found.. please help

Hello guys.. I am following some programmers on youtube and I'm at a point where he is doing Multithreaded for the game. The problem is that from what he is writing seems that this function _WriteBarrier(); does not exist for me. Like this piece of code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
.
..
...
internal void win32_create_queue(Os_Job_Queue *queue, int number_of_thread)
{
    zero_struct(*queue);
    queue->semaphore = CreateSemaphoreA(0, 0, number_of_thread, NULL); // CreateSemaphoreExA that I should use, seems this doesn't exist.

    for(int i = 0; i < number_of_thread; i++)
    {
        HANDLE thread = CreateThread(0, 0, win32_thread_proc, queue, 0, 0);
        CloseHandle(thread);
    }
}

os_add_job_to_queue(struct Os_Job_Queue *queue, Os_Job_Callback *callback, void *data)
{
    u32 volatile new_next_entry_to_write = (queue->next_entry_to_write + 1) % array_count(queue->entries);
    assert(new_next_entry_to_write != queue->next_entry_to_read); // Fails with a small queue

    Os_Job *entry = queue->entries + queue->next_entry_to_write;
    entry->callback = callback;
    entry->data = data;
    //_WriteBarrier(); // <- not working
    queue->next_entry_to_write = new_next_entry_to_write;
    ReleaseSemaphore(queue->semaphore, 1, 0);
}
...
..
.


Does this _WriteBarrier(); matters so much ? cause the program crushes a few times before it works. And this happens everytime I run the program.
Is there something I can change this function with something else.
Last edited on
Ouu... if this is to small I can put the hole win32_platform.c code, if is needed. Thank you...
Well.. pffff.. seems I'm too small to understand
atomic_thread_fence and std::atomic<T>, which are defined in the C++ Standard Library. For hardware access, use the /volatile:iso compiler option together with the volatile keyword.
.. this I belive will not happen.

I'm just do what he does just to have an idea of making a game and how this is working, but I'm not really at this point of using std::atomic<T>... :\
Last edited on
Plus this Header file <intrin.h> seems it doesn't appears to exist in my IDE.
Last edited on
Well if thi isn't working I'll use the program without the Multithread.. at least is working.
At least .. just for understand, those crushes are just cause I comment that function and not working at all //_WriteBarrier(); // <- not working ..?
Topic archived. No new replies allowed.