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, 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?


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.


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 */


  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.