Help understanding e_mutexes

Discussion about Parallella (and Epiphany) Software Development

Moderators: amylaar, jeremybennett, simoncook

Help understanding e_mutexes

Postby louloizides » Mon Apr 20, 2015 9:33 pm

I'm familiar with mutexes in POSIX multithreading. But the e_mutex is confusing me a little.

Basically what's confusing me is the need to specify the core for the mutex... I would've thought it worked across all cores by default, so what exactly am I specifying? And I'm assuming the mutex has to be in shared DRAM -? Or do I create it on some core and specify that core on all processes?

And if I read and write the memory is using the e_read/e_write functions is that operation atomic?

Does anyone have a good example of how to use these properly? The documentation in the SDK only provides a really brief explanation. There are some examples in the SDK but I was really hoping to find something that's explicitly for e_mutexes.
louloizides
 
Posts: 26
Joined: Fri Mar 20, 2015 11:53 am

Re: Help understanding e_mutexes

Postby cmcconnell » Mon Apr 27, 2015 1:01 am

The easiest way to understand these things is often to look at the source code -
https://github.com/adapteva/epiphany-li ... tex_init.c

You can see that all the core specification (row and col) is actually doing is converting a local address to a global one. So, in terms of the affected memory, the mutex can be said to be 'owned' by the core specified by row and col, as the underlying memory location will be in its local SRAM.

It does seem to me to be a bit confusing and potentially dangerous. There's no explicit creation of the underlying object, you just have to make sure that particular address is not being used for anything else! I suppose the problem is that any other approach would mean that the core creating the mutex would somehow have to communicate its address to all the other cores.

The api could just have easily specified the global address directly; I guess the way it is done just makes it easier for the programmer to know which core is being affected.

The actual mechanism by which the shared memory location is being used to implement mutex functionality is the TESTSET instruction, which you can see in the e_mutex_lock() function -
https://github.com/adapteva/epiphany-li ... tex_lock.c
Colin.
cmcconnell
 
Posts: 99
Joined: Thu May 22, 2014 6:58 pm


Return to Programming Q & A

Who is online

Users browsing this forum: No registered users and 4 guests

cron