Page 2 of 2

Re: Unhelpful comments in your code?

Posted: Thu Aug 01, 2013 3:06 pm
by bluemoon
While the code flow is simple and require few or none comment, the intention of the function is not.
what kschedule() actually do? does it pick a task, or it also perform the context switch?
do it modify anything in *cpu? can we call with null? what potential issue may arise (machine lock up if all task are blocked)?
do it require spinlock protection surrounding the call? etc.

These all may well be written as comment above the function.

Re: Unhelpful comments in your code?

Posted: Fri Aug 02, 2013 1:40 am
by Kevin
tiger717 wrote:Please have a look at this piece of code (originates from my multitasking scheduler) and tell me if you really need comments for understanding it.
No, because this is a trivial and short function, despite taking up all the space on the screen. The only thing this code needs is a regex removing some newlines. (Well, some might argue that it could need a more sophisticated algorithm, but that's not the point here... ;))

Nick's code was already somewhat more interesting, but I've seen much more complex things. What you're doing here is almost like comparing Hello World to a real application.