本文介绍了在内核代码wait_event()和wake_up()下,系统挂起并且CPU处于高电平的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个分别运行a()和b()的内核线程. a()试图按如下方式唤醒b().

I have two kernel threads which run a() and b() respectively. a() is trying to wake up b() as follows.

a() {
    while(1) {
       while( atomic_read(status) != SET_SLEEP )
           msleep(10);

       atomic_set(status, SET_RUN);
       printk( "..." );
       wake_up( wq );
    }

b() {
    while(1) {
        atomic_set(status, SET_SLEEP);
        printk( "..." );
        wait_event( wq, atomic_read(status) != SET_SLEEP );
        printk( "..." );
    }

长时间运行后,整个系统将被挂起,CPU变高.没有打印任何紧急消息.有谁知道吗?

After running both for a long time, whole system will be hanged and CPU got high. No any panic message is printed. Is there anyone has idea?

推荐答案

尝试设置锁定状态,该锁定会将CPU a的高速缓存中的雕像刷新到主内存中,以便CPU b获得最新的更新.或将状态设置为易失性.

try put a lock on status, lock will flush the statue in CPU a's cache into main memory so that CPU b gets the latest update. Or maybe set status as volatile.

这篇关于在内核代码wait_event()和wake_up()下,系统挂起并且CPU处于高电平的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 10:03