_WriteBarrier not found.. please help

Jul 6, 2021 at 9:50am
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 Jul 6, 2021 at 9:51am
Jul 6, 2021 at 9:56am
Ouu... if this is to small I can put the hole win32_platform.c code, if is needed. Thank you...
Jul 6, 2021 at 9:57am
Jul 6, 2021 at 10:01am
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 Jul 6, 2021 at 10:01am
Jul 6, 2021 at 10:02am
Plus this Header file <intrin.h> seems it doesn't appears to exist in my IDE.
Last edited on Jul 6, 2021 at 10:03am
Jul 6, 2021 at 10:05am
Well if thi isn't working I'll use the program without the Multithread.. at least is working.
Jul 6, 2021 at 10:09am
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.