Hi,

Please find attached a small test program and also a patch to fix the
implementation of Eina_Barrier using an Eina_Lock and an
Eina_Condition variable. The current implementation causes a deadlock.
The fix was only tested on Linux (Posix) so it'd be good if wince and
win32 also could be tested given that's where it's really needed. If
the semantics of condition variables are the same (and they seem to)
then the patch should work for them as is.

Thanks,

--
Ulisses Furquim
ProFUSION embedded systems
http://profusion.mobi
Mobile: +55 19 9250 0942
Skype: ulissesffs
#include <unistd.h>

#include <Eina.h>

static Eina_Thread wk1, wk2, wk3, wk4, wk5;
static Eina_Barrier barrier;

static void *
wk_func(void *data EINA_UNUSED, Eina_Thread thread EINA_UNUSED)
{
    eina_barrier_wait(&barrier);
    return NULL;
}

static void *
wk1_func(void *data EINA_UNUSED, Eina_Thread thread EINA_UNUSED)
{
    sleep(1);
    eina_barrier_wait(&barrier);
    return NULL;
}

static void *
wk2_func(void *data EINA_UNUSED, Eina_Thread thread EINA_UNUSED)
{
    sleep(2);
    eina_barrier_wait(&barrier);
    return NULL;
}

static void *
wk3_func(void *data EINA_UNUSED, Eina_Thread thread EINA_UNUSED)
{
    sleep(3);
    eina_barrier_wait(&barrier);
    return NULL;
}

int main(void)
{
    eina_init();
    eina_threads_init();

    eina_barrier_new(&barrier, 6);
    eina_thread_create(&wk1, EINA_THREAD_NORMAL, 0, wk_func, NULL);
    eina_thread_create(&wk2, EINA_THREAD_NORMAL, 0, wk_func, NULL);
    eina_thread_create(&wk3, EINA_THREAD_NORMAL, 0, wk1_func, NULL);
    eina_thread_create(&wk4, EINA_THREAD_NORMAL, 0, wk2_func, NULL);
    eina_thread_create(&wk5, EINA_THREAD_NORMAL, 0, wk3_func, NULL);

    eina_barrier_wait(&barrier);

    eina_thread_join(wk1);
    eina_thread_join(wk2);
    eina_thread_join(wk3);
    eina_thread_join(wk4);
    eina_thread_join(wk5);

    eina_barrier_free(&barrier);

    eina_threads_shutdown();
    eina_shutdown();

    return 0;
}

Attachment: 0001-eina-eina_barrier-fix-implmentation-with-lock-and-co.patch
Description: Binary data

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to