LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 06-29-2007, 05:30 PM   #1
shogun1234
Member
 
Registered: May 2004
Posts: 226

Rep: Reputation: 15
set_task_state question


I know this might be a stupid question for guru. But I am newbie to the Gnu/ Linux kernel, there are many parts that I do not understand very well. Hope someone can give me advice.

After reading book and searching online document, it says that set_task_state will `change the process's state (Linux kernel development)'.

So I write a simple kernel module to test the EXIT_ZOMBIE state. The source of kernel module looks as A). Beside, I write a infinite programme. Its source code mainly do the loop infinitely, as B).

What I expect is after `insmod set_state.ko` (infinite programme will run first), the infinite should be terminated (because it is set to EXIT_ZOMBIE). However, from the result I think I am wrong. I do not know where did I do it wrong due to the programme infinite is stilling running when `ps -ef | grep infinite` (as C). I think either I misunderstand the meaning of EXIT_ZOMBIE or some steps I miss in order to terminate the process.

What should I do in order to obtain the outcome I expect.

Thanks in advice.

A) set_state.c
Code:
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/module.h>

int
init_module(void)
{
        struct task_struct *task;
        for_each_process(task){
                if(strcmp(task->comm, "infinite")==0){
                        set_task_state(task, EXIT_ZOMBIE);                 
                }
        }
        return 0;
}

void
cleanup_module(void)
{
        printk(KERN_INFO " Cleaning Up.\n");
}
B.) infinite.c
Code:
int
main(int argc, int *argv[])
{
        while(1);
}
C.) ps -ef | grep infinite
Code:
user1  3865     1  0 02:10 ?        00:00:02 ./infinite

Last edited by shogun1234; 06-29-2007 at 05:59 PM.
 
Old 07-01-2007, 02:54 PM   #2
studioj
Member
 
Registered: Oct 2006
Posts: 460

Rep: Reputation: 31
i'm not so good at this stuff but i think EXIT_ZOMBIE state is for a child that has already died.
EXIT_ZOMBIE state just says hold on to childs file descriptor until parent is notified.
EXIT_ZOMBIE state is trying to cause a zombie after exit so the parent can do accounting properly.
after the parent is notified (presumably the parent is waiting) then the process can die normally.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question, Apples Contribution to Open Source + MacOs file structure question Higgy3k Other *NIX 5 07-25-2005 04:23 AM
Not your regular GRUB question - just a short question for a fried MBR!! ziphem Linux - General 3 01-31-2005 01:51 PM
Question 1 Firewall Log Question 2 Network Monitor Soulful93 Linux - Networking 4 08-04-2004 11:05 PM
login prompt question & kde scheme question JustinCoyan Slackware 2 06-09-2004 02:02 PM
Lilo/kernel question & font question phek Linux - General 9 09-18-2001 12:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 10:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration