【发布时间】:2015-10-26 23:14:05
【问题描述】:
我正在使用 ISO C90 编写代码,它禁止混合声明和代码。 所以我有这样的事情:
int function(int something)
{
int foo, ret;
int bar = function_to_get_bar();
some_typedef_t foobar = get_this_guy(something);
spin_lock_irqsave(lock);
/*
Here is code that does a lot of things
*/
spin_unlock_irqrestore(lock);
return ret;
}
问题是硬件中断还是软件中断,在什么地方可以中断我的函数,也可以在变量声明的中间发生吗?
我问这个是因为我需要这个函数不被中断打断。我想使用 spin_lock_irqsave() 来确保这一点,但我想知道中断是否会在变量声明中中断我的函数?
【问题讨论】:
标签: c linux-kernel interrupt-handling spinlock