pxa270唤醒后报错:ERROR: Power Handler function yield to low priority thread.

fujianfeng   2008-8-31 19:54 楼主
pxa270唤醒后报错:ERROR: Power Handler function yield to low priority thread.
现在加载的驱动加有touch,LCD,button,backlight了,都特别注意了xxx_powerup,xxx_pwerdown里面没有使用同步对象,但是依然报这个错出来。
况且我的PB是5.0的,不过BSP包是4.0上面移植过来的。不知道有没有原因。
实在没办法了。希望有高人指点一下。
在网上找了一些资料:

System Resume from Suspend(PowerOff) ,有時候會出現:ERROR: Power Handler function yield to low priority thread.,google的結果都指向同一個人( Steve Maillet)的回答:
In V5.0 MS added a power down thread so that power down handlers are called on
a thread instead of in the former no-thread kernel context.

The documented idea is that you can now handle synch objects in powerdown code. (There are still limits to synch objects so CloseHandle is still off limits.)

Unfortunately, they implemented this in a way that generates the error
mentioned if the driver's powerdown function blocks on a thread of lower
priority, which would be normal for an application that called into the
driver and has acquired a lock on the synch object in question.

So the upshot is that you are supposed to be able to do synch stuff in power
handlers and under light testing might even seem to work but it is virtually
guaranteed to fail at some point in the future, usually well after product
release. So don't do that.
所以我知道是因為我修改了backlight powerdown function 中呼叫了有使用Sleep( )的function。

我把那個function 中的Sleep( )改成for( ) delay 後,error message就沒有出現了 (該sleep 是在polling hardware state,所以可以這樣改)。

但是,剛剛的回答的意思,到底在CE 5.0 中,Power Handler (XXX_PowerUp/PowerDown)可不可以使用 系統同步物件(event, semaphore, mutex....) ?

Ask Robert,他說在CE 4.0 中的確是不行的,雖然compile可以過,但是實際執行,在call Win32 function 時會出現 complain message。
但是CE 5.0 後就沒有出現這個message了。

看看source code.. SC_PowerOffSystem( )
   SetThreadPriority (CurThread, 0);  SetThreadQuantum (CurThread, 0);  ....  CallPowerProc (GwesPowerProc....));   CallPowerProc (PowerProc.......));  Call (CallOEMPowerOff);   CallPowerProc (PowerProc.......));   CallPowerProc (GwesPowerProc....));  ....  SetThreadQuantum (CurThread, Quantum);  SetThreadPriority (CurThread, Prio);可以看到整個poweroff 的動作是對稱的..


先設定將目前thread的priority 為最高,timeslice 為"永遠"
呼叫GWES driver的power off function
呼叫PowerProc,會一一呼叫各device driver的PowerDown( )
硬體 poweroff ---- suspend,直到有人power - resume
呼叫PowerProc,會一一呼叫各device driver的PowerUp( )
呼叫GWES driver的Power on function
將目前的thread設回原來的TimeSlice & Priority
Device Driver 的PowerUp/Down function 就是在PowerProc( )呼叫的,也就是run 在priority 最高,no timeslice consume 的狀態。
除非該driver funciton 自行release 控制全,否則不會被task switch 掉。

但是因為不知道call 這個function 的Process是誰,所以無法知道是Kernel fork 的Thread 還是屬於呼叫的User Application 中。

回复评论 (2)

顶起来
点赞  2008-9-2 13:33
看的不是很明白,先保存下来,以后再慢慢理解~
点赞  2010-1-8 10:46
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复