简体   繁体   English

Linux内核中是否有功能/宏来获取smp计算机上的当前抢占状态?

[英]Is there a function/Macro in Linux Kernel to get current preemption status on smp machine?

In my project I use get_cpu() and put_cpu() to disable and enable the preemption in the kernel on a smp machine. 在我的项目中,我使用get_cpu()put_cpu()禁用和启用smp计算机上内核中的抢占。

Is there a safe way to get the current preemption status in an smp machine ie whether the preemption is turned on or off. 有没有一种safe way来获取smp机中的当前抢占状态,即抢占是打开还是关闭。

preempt_count () returns current thread's preemption count. preempt_count ()返回当前线程的抢占计数。 0 value means that preemtion is allowed. 0值表示允许预先输入。

Usually, you shouldn't request preemtion status unless for the selfcheck. 通常,除非进行自我检查,否则您不应该请求抢占状态。 If some block of code requires preemtion to be disabled, it should be wrapped with preempt_disable() / preempt_enable() calls (or their alternatives). 如果某些代码块要求禁用preempt_disable() ,则应使用preempt_disable() / preempt_enable()调用(或其替代方法)进行包装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM