mutex by AVR32 instruction set

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

anyone used any mutex by some special AVR32 instructions? like memc, mems and xchg.

Cheng

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, for example the Linux kernel has mutexes and semaphores implemented.

The toolchain has also loads of synchronized builtins enabled, see the __builtin_sync stuff.

Do you have any problems? I saw no question in your post.

Hans-Christian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

where is this __builtin_sync???

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hmm, I was a bit fast typing the GCC intrinsic function name, it is all documented in the GCC manual:

http://gcc.gnu.org/onlinedocs/gc...

Hans-Christian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I tried __sync_bool_compare_and_swap and __sync_lock_test_and_set in my AVR32 code, but the compiler can't compile them.

Severity and Description	Path	Resource	Location	Creation Time	Id
undefined reference to `__sync_bool_compare_and_swap_1'	Framework/1.2.0ES-AT32UC3B/COMPONENTS/RF/CC2420	cc2420_pt.c	line 236	1208180677671	67545
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You will need a fairly new toolchain for them to work, I guess they were added in the GCC 4.2.2 release of GCC for AVR32.

Could you do a avr32-gcc --version?

Hans-Christian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avr32-gcc (GCC) 4.2.2-atmel.1.0.8 (mingw32 special)
This is mine.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Could you paste your code where you use the __sync_bool_compare_and_swap and __sync_lock_test_and_set? Just to sort out any syntax errors :)

Hans-Christian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ok:


U8 i = 0;

int main(void)
{
...
__sync_bool_compare_and_swap(&i, 0, 1);
...
}