thanks. Glenn.<div><br><div class="gmail_quote">On Mon, Feb 20, 2012 at 4:46 PM, Glenn Elliott <span dir="ltr"><<a href="mailto:gelliott@cs.unc.edu">gelliott@cs.unc.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">Hi Hang Su,<div><br></div><div>Zero-length arrays at the end of a struct is a trick that you'll see in C from time to time. Memory for the "struct pfair_param" instance is allocated dynamically with kmalloc. When this allocation is made, more than sizeof(struct pfair_param) memory is allocated. Thus, the subtasks array can be indexed past sizeof(struct pfair_param).</div>
<div><br></div><div>In sched_pfair.c, find the line "param = kmallock(…)" Observe that extra memory is allocated with "quanta * sizeof(struct subtask)". This allocates space for the subtask array.</div>
<div><br></div><div>Here's more information on this technique: <a href="http://stackoverflow.com/questions/295027/array-of-zero-length" target="_blank">http://stackoverflow.com/questions/295027/array-of-zero-length</a></div>
<div><br></div><div>-Glenn</div><div><br></div><div><br><div><div><div class="h5"><div>On Feb 20, 2012, at 4:14 PM, Hang Su wrote:</div><br></div></div><blockquote type="cite"><div><div class="h5">Hi all:<div><br></div><div>
I am reading source code about P-fair scheduling algorithm under /litmus/sched_pfair.c.<b> struct</b> subtask subtasks[0] is declared in <b>struct</b> pfair_param. From definition of function dump_subtasks(struct task_struct*t), subtasks is like a pointer to struct subtask or the name of a struct subtask array. But why it is declared as a struct subtask array with zero element ? is it as the same meaning as a pointer to struct subtask ? </div>
<div><br></div><div><br></div><div>Thanks.</div></div></div>
_______________________________________________<br>litmus-dev mailing list<br><a href="mailto:litmus-dev@lists.litmus-rt.org" target="_blank">litmus-dev@lists.litmus-rt.org</a><br><a href="https://lists.litmus-rt.org/listinfo/litmus-dev" target="_blank">https://lists.litmus-rt.org/listinfo/litmus-dev</a><br>
</blockquote></div><br></div></div><br>_______________________________________________<br>
litmus-dev mailing list<br>
<a href="mailto:litmus-dev@lists.litmus-rt.org">litmus-dev@lists.litmus-rt.org</a><br>
<a href="https://lists.litmus-rt.org/listinfo/litmus-dev" target="_blank">https://lists.litmus-rt.org/listinfo/litmus-dev</a><br>
<br></blockquote></div><br></div>