Random Chitchat 2012-2016
So today I tested the cWorld::DoExplosiontAt function with the cLineBlockTracer. This is the result:


Attached Files Thumbnail(s)
   
Thanks given by: xoft
Cool!
Thanks given by:
I knew there would be cool stuff Wink
Now make it animate in time - napalm throwerBig Grin
Thanks given by:
I'm having trouble with Linux's sem_timedwait() function. For some reason it returns a "timeout" immediately after being called with a 0.5sec timeout. Therefore the DeadlockDetect thread misfires on Linux.

Does anyone have any experience with this?

For those of you with Linux, can you compile and run this quick test program?
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <semaphore.h>
#include <errno.h>

int main(void)
{
    sem_t sem;
    if (sem_init(&sem, 0, 0))
    {
        printf("sem_init failed\n");
        return 1;
    }
    timespec timeout;
    timeout.tv_sec = 1;
    timeout.tv_nsec = 500 * 1000 * 1000;
    clock_t Begin = clock();
    int res = sem_timedwait(&sem, &timeout);
    clock_t End = clock();
    printf("sem_timedwait: %d, errno %d, %llu ticks\n", res, errno, (long long)(End - Begin));
    sem_destroy(&sem);
    return 0;
}
Compile with (assuming test.cpp is the filename):
Code:
g++ test.cpp -lpthread

When run, it should print something like
Code:
sem_timedwait: -1, errno 110, 0 ticks
I'm interested in the results - are you getting zero ticks as well? Where's the bug?
Thanks given by:
I get the same as you.

Are the set and nsec values supposed to be different like they are?

110 seems to indicate that it timed out locking the thing. but idk.
Thanks given by:
It is expected to time out, because no-one is signalling the semaphore, but it is expected to time out after the specified timeout value, which in this case is 1.5 sec (1 sec + 500M nsec). For some reason it "timeouts" immediately.
Thanks given by:
Why not try signalling it and see if it works then?
Thanks given by:
Oh, duh! So stupid, didn't read the docs. The timeout is specifiead absolute, not relative, so it needs to be set to time(NULL) + nsec
Thanks given by:
Derp. Great that you got it working then.
Thanks given by:
Still, some weirdness going on. The test program stops correctly for the 1.5 sec, but still reports 0 ticks. Anyway, it's good enough for me now; I have more pressing issues:

1, Pickups
2, Hunger

It seems that PerWorldThreads has brought in a lot of unexpected resource contention; the current debugging version is no longer capable of running the world tick thread, not even for a single player. The release version is doing better, but still I need to fix this, because we can't do much without the debugging version.
Thanks given by:




Users browsing this thread: 5 Guest(s)