Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

In the version 2.6.15 kernel, I got that I can rewrite the task_struct in the file (include/linux/sched.h),like:

struct task_struct {  
    unsigned did_exec:1;  
    pid_t pid;  
    pid_t tgid;  
    ...
    char hide;
}  

But, unfortunately, when I upgraded to the version 2.6.30.5, I looked through the same file, I just find a declaration of the task_struct, like:

struct task_struct;

And I have no idea which file I should refer to for the purpose of specifying my own task_struct? Can someone help me?

share

2 Answers 2

up vote 3 down vote accepted

Use grep or any other search tool to look for the definition:

grep -r '^struct task_struct ' include

Or search online at LXR: http://lxr.linux.no/linux+v2.6.30.5/+search?search=task_struct

The structure is still defined in include/linux/sched.h. There's a forward declaration which is used in mutually recursive type definitions, and the definition is further down.

share
    
thx,i got it in line 1117. –  kaiwii ho Jan 31 '12 at 0:29

I'm using Debian squeeze. I see a definition in the headers corresponding to my current kernel, in /usr/src/linux-headers-2.6.32-5-common-vserver/include/linux/sched.h. The definition starts with

struct task_struct {
        volatile long state;    /* -1 unrunnable, 0 runnable, >0 stopped */
        void *stack;
        atomic_t usage;
        unsigned int flags;     /* per process flags, defined below */
        unsigned int ptrace;

        int lock_depth;         /* BKL lock depth */

HTH.

share
    
So,am i using a unstable version?but do u have any idea where the defination switch to?any hint?thx –  kaiwii ho Jan 30 '12 at 5:44
    
@kaiwiiho: Sorry, I'm not sure what you mean. –  Faheem Mitha Jan 30 '12 at 6:03
    
i mean that whether version 2.6.15 is not stable.And,i think that the defination must exist in a .c file that delcrates the sched.h.But unfortunately,i have not think out a method to find oute c file.And can u give some hints for me? –  kaiwii ho Jan 30 '12 at 6:12
    
@kaiwiiho: Not sure you mean by stable. 2.6.15 is a kernel release. The definition of the struct is in the header file, as far as I can see. What are you looking for? –  Faheem Mitha Jan 30 '12 at 6:36

This site is currently not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .