Re: sleep process, wait queues

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

 



On 7/3/05, Deepak Joshi <deepak_cins@xxxxxxxxxxx> wrote:
> #include <linux/module.h>
> #include <linux/kernel.h>
> #include <linux/wait.h>
> #include <linux/sched.h>
> #include <linux/list.h>
> MODULE_LICENSE("GPL");
> 
> 
> static DECLARE_WAIT_QUEUE_HEAD (my_queue);
> int init_module(void)
> {
>         struct task_struct *my_task ;
>         my_task = find_task_by_pid(1477);
>         DECLARE_WAITQUEUE(wait, my_task);
>         my_task->state = TASK_UNINTERRUPTIBLE ;
>         init_waitqueue_entry( &wait, my_task);
>         add_wait_queue( &my_queue , &wait);
>         sleep_on(&my_queue);
>         interruptible_sleep_on(&my_queue);
>         schedule( );

Its not the right way to put another process to sleep, because all the
sleep functions put the current running process to sleep and in your
case the current is insmod itself. You should rather hack control flow
of any of the common system calls, like open(). Once you hack that
(you can do that in init_module() function), in your hack function
check if the current process is the process you want to put to sleep,
if yes, do the above sleeping mechanism in your hack function.

regards,
-Gaurav

>         return 0;
> }
> 
> 
> void cleanuo_module()
> {
>         printk("Bye");
>         wake_up( &my_queue );
> }
> 
> 
> 
> 
> Hi  everyone,
> 
> In the above module I want to sleep the process having
> pid 1477 ( which is mpg123 player in my case in wait
> queue ). Instead of sleeping the process with the
> given pid it is hanging insmod command. so plz tell me
> what is wrong in the above code.
> 
> Thanks for replays in Advance,
> Thanks and regards
> Deepak Joshi.
> 
> 
> 
> 
> ___________________________________________________________
> How much free photo storage do you get? Store your holiday
> snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
> 
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
> 
>

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



[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