And your problem is?
Grab thee a piece of paper and
draw a picture of what the data-structures are. It's certainly not a problem for a
struct to be contained within another
struct ... as you can imagine, it happens all the time!
Let's look at your code:
Code:
task->sched_info->pid
Given that you have said that
task is "a pointer to a
struct task, the question before the jury is .. "
is the
sched_info component of a
task structure 'a pointer to' something that contains a
pid?"
(I don't know: I didn't take the time to look for myself before writing this. But then again, neither did
gcc...)
By using the construct
->, which is "pointer dereference," you're saying that it does. You're writing code that says that some element of the structure pointed-to by
task (that is, a
task_struct) contains a
pointer, named
sched_info,
to something (that is, to another
struct, located somewhere) that contains an element called
pid? "Can I,
gcc, your long-suffering but ever-obedient servant, possibly make sense of this thy pronouncement, Oh Grand Master, that I may render executable code from it?"
(If not, then it has many incomprehensible ways to declare to thee that thou art full of ka-ka.)
Draw a picture. Grab a piece of paper, or a cocktail napkin, or what have you, and
draw a picture. In this case, your bar-napkin drawing would have
two boxes... and one box would point to the second one.
It could, of course, be the case that "this thingy-whatchamacallit that is pointed-to by
task is actually a pretty big
struct which contains, among its many parts, a sub-
struct which includes an element called
pid. In that case, you'd write something like this:
Code:
task->sched_info.pid
(Notice the "." versus "->".)
Here, your bar-napkin drawing has only
one box, and within the outer box there's an inner one.
I emphasize again...
draw a picture. If you don't firmly understand what the situation is supposed to look like, then you cannot
possibly describe it to a computer.