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

📄 smp_lock.h

📁 嵌入式系统设计与实例开发实验教材二源码 多线程应用程序设计 串行端口程序设计 AD接口实验 CAN总线通信实验 GPS通信实验 Linux内核移植与编译实验 IC卡读写实验 SD驱动使
💻 H
字号:
#ifndef __CRIS_SMPLOCK_H#define __CRIS_SMPLOCK_H#include <linux/config.h>#ifdef CONFIG_SMP#error "SMP is not supported for CRIS"/* *	Locking the kernel  */ extern __inline void lock_kernel(void){	unsigned long flags;	int proc = smp_processor_id();	save_flags(flags);	cli();	/* set_bit works atomic in SMP machines */	while(set_bit(0, (void *)&kernel_flag)) 	{		/*		 *	We just start another level if we have the lock 		 */		if (proc == active_kernel_processor)			break;		do 		{#ifdef __SMP_PROF__					smp_spins[smp_processor_id()]++;#endif						/*			 *	Doing test_bit here doesn't lock the bus 			 */			if (test_bit(proc, (void *)&smp_invalidate_needed))				if (clear_bit(proc, (void *)&smp_invalidate_needed))					local_flush_tlb();		}		while(test_bit(0, (void *)&kernel_flag));	}	/* 	 *	We got the lock, so tell the world we are here and increment	 *	the level counter 	 */	active_kernel_processor = proc;	kernel_counter++;	restore_flags(flags);}extern __inline void unlock_kernel(void){	unsigned long flags;	save_flags(flags);	cli();	/*	 *	If it's the last level we have in the kernel, then	 *	free the lock 	 */	if (kernel_counter == 0)		panic("Kernel counter wrong.\n"); /* FIXME: Why is kernel_counter sometimes 0 here? */		if(! --kernel_counter) 	{		active_kernel_processor = NO_PROC_ID;		clear_bit(0, (void *)&kernel_flag);	}	restore_flags(flags);}#endif#endif

⌨️ 快捷键说明

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