newbie k-developer: sleep_on/wake_up problems

Joe Phillips (jaiger@acm.org)
Mon, 30 Mar 98 23:08:57


hello,

I'm attempting to develop a driver for a device I have here. I'm
currently trying to explore certain functionality that I will need
to use for development. Specifically, I'm exploring sleep_on and
wake_up right now. let's get to the core of the broken code:

...

static wait_queue* sonic_wait= NULL;

...

/* inside ioctl */

switch(cmd){

...

case cmd_sleep:{
sleep_on_interruptible(&sonic_wait);
break;
}
case cmd_wake:{
if(sonic_wait != NULL){
wake_up_interruptible(&sonic_wait);
}
sonic_wait= NULL;
break;
}
default:
break;
}

/* end of ioctl */

...

now I can successfully insmod and rmmod the module, call various other
ioctl functions (not shown) and it appears the skeleton of my driver
works.

The problems I am having are when I try to exercise the above code
fragments. I have one user-space program that gives the cmd_sleep
ioctl
and another that gives the cmd_wake ioctl. The cmd_sleep seems to work
as the program stops and appears to be sleeping, I can do other things
on other terminals no problem. as soon as I run the program that does
the cmd_wake, linux crashes. The last message on the console is

"Unable to handle kernel NULL pointer dereference"

this message immediately follows other messages generated by my driver
but there are no oops or other visible signs of problems.

I added printk()'s to the ioctl code and it looks like the wake_up
completes since a printk placed after the wake_up gets printed to the
console just before the final error message.

also, printk's have shown that in one crashing case
sonic_wait= 0xc04a1f5c.
sonic_wait->task= 0xc04a0000.
sonic_wait->next= 0xc102dc80.

just previous to wake_up, so I didn't see any obvious NULL pointers
being used in my code.

Can anyone help me figure out what is wrong with my code?
Is there anything wrong with the above driver code fragment?
What can I try to poke around and figure out what is wrong?

my background:
I have read as many of the online kernel resources as I could find over
the past few months. I have read through the sources for a bunch of
drivers (that source navigator is great huh.) As you know, you can't
get everything from reading, so I'm in the experimental stage. Please
bear with me. I'd be more than glad to RTFM if I can find it. I've
followed the linux-kernel list for a number of months now via the
web interface. I'm not subscribed but follow the list regularly
through the web interface.

I'm developing on a debian system running 2.1.87 kernel.

TIA,

Joe Phillips

-- 
Windows is not the answer. Windows is the question. No is the answer.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu