Changeset 178 for soft/giet_vm/libs/spin_lock.c
- Timestamp:
- Jul 22, 2012, 12:06:11 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/libs/spin_lock.c
r165 r178 10 10 // It is a simple binary lock, without waiting queue. 11 11 // 12 // The lock_acquire() and lock_release() functions do not require a system call. 13 // The barrier itself must have been allocated in a non cacheable segment, 14 // if the platform does not provide hardwate cache coherence. 12 // The lock_acquire(), lock_try_acquire() and lock_release() functions do 13 // not require a system call. 15 14 // 16 15 // ALL locks must be defined in the mapping_info data structure, 17 16 // to be initialised by the GIET in the boot phase. 18 17 // The vobj_get_vbase() system call (defined in stdio.c and stdio.h files) 19 // can be used to get the virtual base address of the lock fro it's name.18 // can be used to get the virtual base address of the lock from it's name. 20 19 /////////////////////////////////////////////////////////////////////////////////// 21 20 … … 65 64 } 66 65 66 ////////////////////////////////////////////////////////////////////////////// 67 // lock_try_acquire() 68 ////////////////////////////////////////////////////////////////////////////// 69 int lock_try_acquire( giet_lock_t* lock ) 70 { 71 register int ret = 0; 72 register unsigned int* plock = &lock->value; 73 74 asm volatile ("ll $2, 0(%1) \n" // $2 <= _locks_lock 75 "bnez $2, _lock_done \n" // exitif busy 76 "li $3, 1 \n" // prepare argument for sc 77 "sc $3, 0(%1) \n" // try to set _locks_busy 78 "xori %0, $3, 1 \n" // ret = !$3 79 "_lock_done: \n" 80 :"=r"(ret) 81 :"r"(plock) 82 :"$2","$3"); 83 return ret; 84 }
Note: See TracChangeset
for help on using the changeset viewer.