Changeset 189 for soft/giet_vm/libs/spin_lock.c
- Timestamp:
- Aug 7, 2012, 6:37:49 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/libs/spin_lock.c
r178 r189 10 10 // It is a simple binary lock, without waiting queue. 11 11 // 12 // The lock_acquire(), lock_try_acquire() and lock_release() functions do 13 // not require a system call. 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. 14 15 // 15 16 // ALL locks must be defined in the mapping_info data structure, 16 17 // to be initialised by the GIET in the boot phase. 17 18 // The vobj_get_vbase() system call (defined in stdio.c and stdio.h files) 18 // can be used to get the virtual base address of the lock fro mit's name.19 // can be used to get the virtual base address of the lock fro it's name. 19 20 /////////////////////////////////////////////////////////////////////////////////// 20 21 … … 64 65 } 65 66 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_lock75 "bnez $2, _lock_done \n" // exitif busy76 "li $3, 1 \n" // prepare argument for sc77 "sc $3, 0(%1) \n" // try to set _locks_busy78 "xori %0, $3, 1 \n" // ret = !$379 "_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.