⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spinlock.hhf

📁 High Level assembly language(HLA)软件
💻 HHF
字号:
#if( ! @defined( spinlock_hhf ))?spinlock_hhf := true;// Note: since this is assembly language, not C, we'll// dispense with all the spin lock macros that preserve// flags (because it's much easier to preserve the flags// directly in assembly.namespace linux; @fast;type	spinlock_t: record  		_lock	:dword;  	endrecord;  	wq_lock_t	:spinlock_t;  	  	rw_lock_t	:spinlock_t;	rwlock_t	:rw_lock_t;const	spin_lock_unlocked :spinlock_t := spinlock_t:[0];	#if( @defined( __SMP__ ))		#error( "Need to add SMP support to spinlock.hhf" )			#else		// On single processor systems, spinlocks are empty		// since we can't preempt the kernel.				// Really, this should be an empty macro since we		// don't really use spinlocks in a single processor		// system.  However, since this *is* assembly language,		// some assembly programmer might actually poke around		// with the internal structure, so it's best to go ahead		// and initialize the spinlock.				#macro spin_lock_init(__x);			returns			(				{					mov( 0, __x._lock );				}, ""			)		#endmacro;				// spin_lock returns the value of the spinlock		// object passed as an argument.  This macro		// uses an empty "returns" statement rather than		// simply specifying "theLock._lock" as the macro		// body to allow the caller to specify this as		// a statement (as well as an instruction operand).		// If the user does this, HLA ignores the "rtn"		// value.		//		// Note that this macro can be used as a destination		// operand of an instruction, even though the caller		// should never really do that.		//		// In theory, this macro should spin until the lock		// is available, but since locks are never held in		// a uniprocessor system, there is no waiting.				#macro spin_lock(__Lock):rtn;			?rtn := @string:__Lock + "._lock";			returns({},rtn)		#endmacro;				// On a uniprocessor system, bottom halves are automatically		// disabled since we can't preempt the kernel.				#macro spin_lock_bh(__x):rtn;			?rtn := @string:__x + "._lock";			returns({},rtn)		#endmacro;						// Since this is uniprocessor code, the following		// macro always returns false (zero) since the		// spinlock is never locked (this code ignores		// the spinlock value if an assembly programmer		// has set it to some value other than zero).		// Again, this macro uses the "returns" statement		// so that invoking this macro as a statement		// is okay.				#macro spin_is_locked(__lock);			returns({}, "0")		#endmacro;						// spin_trylock attempts to aquire the lock		// without waiting.  Since we can always aquire		// the lock, this code always returns zero to		// indicate that the lock is available.				#macro spin_trylock(__lock);			returns({},"0")		#endmacro;				// spin_unlock_wait waits until the lock		// is available, but doesn't take possession of it.		// Of course, the lock is always available, so this		// macro really does nothing.				#macro spin_unlock_wait(__lock);		#endmacro;						// spin_unlock unlocks the specified spinlock.		// Since spinlocks in a uniprocessor system		// are never held, this macro does nothing.				#macro spin_unlock(__lock);		#endmacro;						/*		 * Read-write spinlocks, allowing multiple readers		 * but only one writer.		 *		 * NOTE! it is quite common to have readers in interrupts		 * but no interrupt writers. For those circumstances we		 * can "mix" irq-safe locks - any writer needs to get a		 * irq-safe write-lock, but readers can get non-irqsafe		 * read-locks.		 *		 * On a uniprocessor system, these macros are identical		 * to the spinlock macros.  See those macros for comments.		 */		#macro rwlock_init(__x):rtn;			?rtn := @string:__x + "._lock";			returns({},rtn)		#endmacro;				#macro read_lock(__Lock):rtn;			?rtn := @string:__Lock + "._lock";			returns({},rtn)		#endmacro;				#macro read_unlock(__lock);		#endmacro;				#macro write_lock(__Lock):rtn;			?rtn := @string:__Lock + "._lock";			returns({},rtn)		#endmacro;				#macro write_unlock(__lock);		#endmacro;					#endif				end linux;			#endif // spinlock_hhf

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -