[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

schedule in task queues - restarting thread :)

>   I have one interesting doubt
> >   Please have a look at small piece of code 
> > 
> > void   print()
> >   {
> >    printk("The current process
> >    schedule();
> >    printk(" The current process
> >   }
> > 
> I'm not sure that you're allowed to use the task
queue that way.
> The purpose of the task queue is what they call
"software interrupt
> handling". When you get a hardware interrupt, you
don't want to spend
> time blocking other irqs, so you queue the work and
unmask interrupts.
> At other points in time (return from syscall,
interrupt, ctx 
> switch etc), the
> task queue is checked and executed. I think calling
> when you're
> in the task queue, will somehow mark the process
> for scheduling.


I don't know what happened to this one, I just
subscribed to the list for an hour and then
unsubscribed after finding out that I had no time to
read all these mails. I picked this one again from the
archive and assumed that there was no final answer.
Iam here at a client's place where everyone happens to
be a *solaris* geek :) so  I installed Linux on my
/official/ laptop, today in the morning to actually
test it :)

[root@woody fiddle]# cat mod.c

#define NULL (void *)0
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/tqueue.h>

struct tq_struct myjob;
void fun(void)
        printk("Before calling schedule\n");
        printk("After calling schedule\n");
int init_module()
      myjob.routine = fun;
      myjob.data = NULL;
      myjob.sync = 0;
      myjob.next = NULL;
      queue_task(&myjob, &tq_scheduler);
      printk("Module loaded\n");
      return 0;

void cleanup_module()
          printk("Module Unloaded\n");
[root@woody fiddle]# gcc -c -O2 -DMODULE -D__KERNEL__
mod.c: In function `init_module':
mod.c:21: warning: assignment from incompatible
pointer type
[root@woody fiddle]# insmod mod
Module loaded
Before calling schedule
After calling schedule
[root@woody fiddle]# rmmod mod
Module Unloaded
[root@woody fiddle]#

Btw this is 2.2.14 from a redhat CD.

Hope that helps,


Do You Yahoo!?
Kick off your party with Yahoo! Invites.