* query regarding kernel daemon
@ 2011-04-04 9:28 shubham sharma
2011-04-04 9:45 ` Daniel Baluta
2011-04-05 6:40 ` Mulyadi Santosa
0 siblings, 2 replies; 3+ messages in thread
From: shubham sharma @ 2011-04-04 9:28 UTC (permalink / raw)
To: kernelnewbies
I was trying some experiments with the kernel daemon. The experiment works
as follows:
A daemon sleeps in the background. User can enter a string through the proc
interface. Whenever a string is entered, the daemon is woke. The daemon
keeps a copy of the last entered string in a variable. Initially the
variable is initialized to NULL. When the daemon wakes, it checks if the
string entered is same as the previous one or a new string is entered. When
the string is entered, in case the new or the old strings are NULL, or in
case the entered string is same as the old string the daemon goes back to
sleep (with the help of the function interruptible_sleep_on().
The problem I am facing is that when I enter the string the second time, the
system stalls. I added some sleeps in the code and figured out that when the
proc function wakes up the daemon, the system stalls.
I have attached the module code with the mail. Any suggestion for the error
would be a great help.
Shubham
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110404/910cb349/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: daemon_test.c
Type: text/x-csrc
Size: 6916 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110404/910cb349/attachment.bin
^ permalink raw reply [flat|nested] 3+ messages in thread
* query regarding kernel daemon
2011-04-04 9:28 query regarding kernel daemon shubham sharma
@ 2011-04-04 9:45 ` Daniel Baluta
2011-04-05 6:40 ` Mulyadi Santosa
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Baluta @ 2011-04-04 9:45 UTC (permalink / raw)
To: kernelnewbies
> A daemon sleeps in the background. User can enter a string through the proc
> interface. Whenever a string is entered, the daemon is woke. The daemon
> keeps a copy of the last entered string in a variable. Initially the
> variable is initialized to NULL. When the daemon wakes, it checks if the
> string entered is same as the previous one or a new string is entered. When
> the string is entered, in case the new or the old strings are NULL, or in
> case the entered string is same as the old string the daemon goes back to
> sleep (with the help of the function interruptible_sleep_on().
Don't use interruptible_sleep_on use wait_event* instead.
thanks,
Daniel.
[1] http://lxr.linux.no/linux+v2.6.38/include/linux/wait.h#L570
^ permalink raw reply [flat|nested] 3+ messages in thread
* query regarding kernel daemon
2011-04-04 9:28 query regarding kernel daemon shubham sharma
2011-04-04 9:45 ` Daniel Baluta
@ 2011-04-05 6:40 ` Mulyadi Santosa
1 sibling, 0 replies; 3+ messages in thread
From: Mulyadi Santosa @ 2011-04-05 6:40 UTC (permalink / raw)
To: kernelnewbies
On Mon, Apr 4, 2011 at 16:28, shubham sharma <shubham20006@gmail.com> wrote:
> The problem I am facing is that when I enter the string the second time, the
> system stalls. I added some sleeps in the code and figured out that when the
> proc function wakes up the daemon, the system stalls.
Typical: you must be doing somekind of busy looping or block while
interrupt is down. And this matter a lot since what running here is
kernel thread/daemon, which operate entirely in kernel space i.e if it
blocks, then the entire OS stalls since most likely scheduling happen
during kernel to user mode transition or voluntarily.
So as a side watch, check the preemption model your kernel use... try
to avoid no preemption...and if you could, switch to full preemption
mode...in this mode, preemption could happen on interrupt-to-kernel
mode transition.
--
regards,
Mulyadi Santosa
Freelance Linux trainer and consultant
blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-04-05 6:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-04 9:28 query regarding kernel daemon shubham sharma
2011-04-04 9:45 ` Daniel Baluta
2011-04-05 6:40 ` Mulyadi Santosa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).