Re: kernel/sched.c questions

From: Tim Walberg (tewalberg@mediaone.net)
Date: Wed Apr 04 2001 - 15:08:33 EST


On 04/04/2001 16:52 -0300, Sardaņons, Eliel wrote:
>> Hello, I would like to know why you put this two functions:
>> void scheduling_functions_start_here(void) { }
>> ...
>> void scheduling_functions_end_here(void) { }
>>

That one I have no idea about - maybe some perverse sort
of comment? Or maybe something somewhere needs to know the
address range that some functions lie within, and these functions
would delimit that range. Of course, that presumes that the
compiler in use doesn't reorder functions in the object code
that emits, but I think that's a fairly safe assumption for
now...

>> why you put 'case TASK_RUNNING'
>>
>> switch (prev->state) {
>> case TASK_INTERRUPTIBLE:
>> if (signal_pending(prev)) {
>> prev->state = TASK_RUNNING;
>> break;
>> }
>> default:
>> del_from_runqueue(prev);
>> case TASK_RUNNING:
>> }
>>

This just indicates that there is nothing to be done for the
TASK_RUNNING case - if it were left out, the default case would
be taken. Of course, a 'case TASK_RUNNING: break;' placed earlier
in the switch construct would be semantically the same, but there
may be reasons related to code optimization that this was done the
way it was.

>> and the last one:
>>
>> in the function schedule() you always use this syntax:
>>
>> -----
>> if (a_condition)
>> goto bebe;
>> bebe_back
>>
>>
>> bebe:
>> do_bebe();
>> goto bebe_back;
>> ------
>> why not just doing:
>>
>> if (a_condition)
>> do_bebe();
>>
>>
>> I know that goto's are better but finaly you are jumping to a function and
>> then calling the function. I think you can improve performance doing this.

This looks like a hand-optimization to avoid a branch in the most common
case. Chances are a_condition is supposed to be pretty rare, and the code
you suggest would usually include a branch for the usual code path, then.

                        tw

-- 
+--------------------------+------------------------------+
| Tim Walberg              | tewalberg@mediaone.net       |
| 828 Marshall Ct.         | www.concentric.net/~twalberg |
| Palatine, IL 60074       |                              |
+--------------------------+------------------------------+


- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Apr 07 2001 - 21:00:15 EST