PCI driver code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Pl explain the following  structure declaration in PCI_driver code

static struct pci_driver foo_driver {
.name = ?foo?,
.probe = foo_probe,
.remove = foo_remove,
.id_table = foo_tbl,
};

consider me a novice only

Cheers
Ashok
Dinesh Ahuja <mdlinux7@xxxxxxxxxxx> wrote:
Hi Mulyadi,

> set_current_state(TASK_INTERRUPTIBLE);

>I think this is the problem. You set a running task
>into sleeping state, but didn't quickly follow it
with >re-scheduling function (that implicitly use wait
queue >too). What happen here was, your kernel thread
was >declared in sleeping state, time slice was
running >out, your thread was kicked out from CPU but
wasn't >runnable anymore.

This does not seems to be an issue as this line which
I have added to set the state of current process is
done in interruptible_sleep_time_out() function.
Removing this line does not solve problem and I still
get oops.

Internally, interruptible_sleep_time_out() invokes
schedule_timeout() {kernel/sched.c}. When I invoke
schedule_timeout directly, everything works fine. I
donot know what goes wrong when I try to invoke
interruptible_sleep_time_out().

Regards
Dinesh


Actually, you don't need it, because
interruptible_sleep_time_out do it
all for your.
--- Mulyadi Santosa wrote:

> Hi Dinesh...
>
> > Sorry for being late in replying back. I have used
> > schedule_timeout and it is working fine. But
> curious
> > to know what wrong is going on while using wait
> > queues.
> > I am working on kernel 2.4.20
> > Here is full code:
> [deleted]...
> > set_current_state(TASK_INTERRUPTIBLE);
>
> I think this is the problem. You set a running task
> into sleeping state,
> but didn't quickly follow it with re-scheduling
> function (that
> implicitly use wait queue too). What happen here
> was, your kernel
> thread was declared in sleeping state, time slice
> was running out, your
> thread was kicked out from CPU but wasn't runnable
> anymore.
>
> Actually, you don't need it, because
> interruptible_sleep_time_out do it
> all for your.
>
> I'll give another example how it is really done if
> you want to do it on
> very low level way. Take a look on
> wait_for_completion(). Comments are
> added inline:
> void wait_for_completion(struct completion *x)
> {
> spin_lock_irq(&x->wait.lock);
> if (!x->done) {
> // [Mulyadi]: declare a wait queue
> DECLARE_WAITQUEUE(wait, current);
>
> wait.flags |= WQ_FLAG_EXCLUSIVE;
> // [Mulyadi]: add to the wait queue first
> __add_wait_queue_tail(&x->wait,
> &wait);
> do {
> // [Mulyadi]: and then mark the current task as
> interruptible
>
> __set_current_state(TASK_UNINTERRUPTIBLE);
>
> spin_unlock_irq(&x->wait.lock);
> // [Mulyadi]: feel free to reschedule
> schedule();
>
> spin_lock_irq(&x->wait.lock);
> } while (!x->done);
> // [Mulyadi]: if you are done with it, remove the
> task from wait queue
> __remove_wait_queue(&x->wait,
> &wait);
> }
> x->done--;
> spin_unlock_irq(&x->wait.lock);
> }
>
> That way, the kernel knows that you're asking to be
> woken up when a
> signal is delivered, an event happens or simply
> because of timeout.
>
> So the conclusion is, as far as I know, declare a
> waitqueue, insert the
> task to waitqueue, and set the task state. Don't
> mess this order...
>
> regards,
>
> Mulyadi
>
>




__________________________________________________________
Yahoo! India Answers: Share what you know. Learn something new
http://in.answers.yahoo.com/

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/



Now you can scan emails quickly with a reading pane. Get the new Yahoo! Mail.

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux