Last change
on this file since 670 was
571,
checked in by meunier, 11 years ago
|
Correction of the "double barrier" problem from the user point of view for the generated llsc tests (use of 2 distinct barriers)
|
File size:
791 bytes
|
Rev | Line | |
---|
[536] | 1 | |
---|
| 2 | #include "functions.h" |
---|
| 3 | |
---|
| 4 | void take_lock(volatile int * plock) { |
---|
| 5 | volatile int * _plock = plock; |
---|
| 6 | __asm__ __volatile__ ( |
---|
| 7 | "move $16, %0 \n" |
---|
| 8 | "giet_lock_try : \n" |
---|
[571] | 9 | "lw $2, 0($16) \n" |
---|
[536] | 10 | "ll $2, 0($16) \n" |
---|
| 11 | "bnez $2, giet_lock_try \n" |
---|
| 12 | "li $3, 1 \n" |
---|
| 13 | "sc $3, 0($16) \n" |
---|
| 14 | "beqz $3, giet_lock_try \n" |
---|
| 15 | "nop \n" |
---|
| 16 | "giet_lock_ok: \n" |
---|
| 17 | "nop \n" |
---|
| 18 | : |
---|
| 19 | :"r" (_plock) |
---|
| 20 | :"$2", "$3", "$4", "$16"); |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | void release_lock(volatile int * plock) { |
---|
| 25 | asm volatile("\tsync\n"); |
---|
| 26 | *plock = 0; |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | |
---|
Note: See
TracBrowser
for help on using the repository browser.