Is it dangerous using EKern::Sleep() in kernel extension?

This is a discussion on Is it dangerous using EKern::Sleep() in kernel extension? within the Symbian forums in Other Technologies category; Hi, I am a audio device driever engineer.=20 I use many EKern::Sleep() in codec kern extenstion for reduce codec pop noi= se.=20 But somebody say "It is very dangerous". I want know why it is sangerous and what is casuse by usging this function.= =20 thank you. Edited by: happypunk on 20-Aug-2008 13:18...

Go Back   Application Development Forum > Other Technologies > Symbian

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-20-2008, 08:19 AM
happypunk
Guest
 
Default Is it dangerous using EKern::Sleep() in kernel extension?

Hi, I am a audio device driever engineer.=20
I use many EKern::Sleep() in codec kern extenstion for reduce codec pop noi=
se.=20
But somebody say "It is very dangerous".

I want know why it is sangerous and what is casuse by usging this function.=
=20

thank you.

Edited by: happypunk on 20-Aug-2008 13:18
Reply With Quote
  #2  
Old 08-20-2008, 12:52 PM
markd
Guest
 
Default Re: Is it dangerous using EKern::Sleep() in kernel extension?

Hi

If the sleep is a blocking sleep, e.g. waits for a counter to expire, then =
this can cause problems depending on the length of time you want to sleep.

Do you mean NKern::Sleep(TUint32 aTime) ?
Puts the current nanothread to sleep for the specified duration and it can =
be called from Symbian OS threads.

Mark
Symbian
Reply With Quote
  #3  
Old 08-20-2008, 08:15 PM
happypunk
Guest
 
Default Re: Is it dangerous using EKern::Sleep() in kernel extension?


oh, I mean NKern::Sleep().=20

Is not it dangerous?


Reply With Quote
  #4  
Old 08-21-2008, 12:12 PM
shanekearns
Guest
 
Default Re: Is it dangerous using NKern::Sleep() in kernel extension?

NKern::Sleep will block the current thread for a number of milliseconds acc=
ording to the parameter you give.
Other threads can still run, so it is often safe.

Times when NKern::Sleep should not be used:
1) If you don't know what context the function is called in
2) If your driver is executing in DFC0, DFC1 or interrupt context
DFC0 is a shared thread, so all drivers using DFC0 are also blocked (a <=
5ms sleep is probably fine, but long sleeps can cause side effects in other=
drivers because their DFC runs too late)
DFC1 is the timer thread, calling NKern::Sleep here will deadlock the syste=
m
In interrupt context, the system will crash

Recommended context to use NKern::Sleep:
1) in the context of a user thread
For example when handling a DoControl
2) in your device driver's private DFC thread.
Private DFC threads, created with Kern:ynamicDfcQCreate (from 9.3) or Ker=
n:fcQCreate (from 8.1b) are recommended because your device driver can ma=
ke blocking calls with NKern::Sleep or fast mutex / fast semaphore without =
affecting other drivers.

PS: the very dangerous function is Kern::NanoWait, which is a spinning dela=
y loop and should only be used for microsecond size delays. (it blocks all =
lower priority threads in the system)
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 08:18 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.