Posted Jul 4, 2008 11:35 UTC (Fri) by walles (guest, #954)
Parent article: TASK_KILLABLE
Some languages throw exceptions when bad stuff (like an interrupted file write) happens. They
are easy to write in and is what most things should be written in.
Some languages (like C, assembler, C++) return error codes when bad stuff happens. These
error codes often get ignored. And programs written in these languages often have bugs of the
kind that are mentioned in this article. These languages are good for writing kernels and not
that much else.
Now, if people could just stick to the first kind of language for their user-space apps we
wouldn't be having these problems. If people could start writing their *kernels* in the first
kind of language, we would have even fewer problems (but there are a bunch of things that have
to be resolved before this happens).
Unfortunately, in practice, many people tend to go with the second kind of language for no
particular reason.
Things are getting better though. So maybe 10 years from now the uninterruptible sleeps can
be removed from the kernel.
Anyway, w00t for exception-throwing (and bounds-checking and garbage-collecting) languages!
Posted Jul 5, 2008 23:39 UTC (Sat) by giraffedata (subscriber, #1954)
[Link]
Things are getting better though. So maybe 10 years from now the uninterruptible sleeps can
be removed from the kernel.
There will have to be advances on other fronts for us to go that far. The article covers one of the major reasons for uninterruptible sleep today: that your client can't deal with a half-finished operation. But the other reason programs do uninterruptible sleep is that they themselves lack the intelligence to finish a partially done operation -- i.e. there's nowhere to get off the highway before the destination.
I have found it takes some very hard work to make it possible to get out of something in the middle. You have to carefully decide whether to spend time and bug tolerance for that or use it for something else.
Don't forget the ten commandments...
Posted Jul 7, 2008 5:14 UTC (Mon) by walles (guest, #954)
[Link]
... for C programmers. Let me quote the sixth commandment for you:
"
If a function be advertised to return an error code in the event of difficulties, thou shalt check for that code, yea, even though the checks triple the size of thy code and produce aches in thy typing fingers, for if thou thinkest ``it cannot happen to me'', the gods shall surely punish thee for thy arrogance.
"
Writing broken code for yourself is OK. Writing broken code for others is not.
w00t for exception-throwing languages
Posted Jul 8, 2008 17:56 UTC (Tue) by leoc (subscriber, #39773)
[Link]
Some languages throw exceptions when bad stuff (like an interrupted file write) happens.
Yes, but bad programmers use those languages too, and seem to actively enjoy doing things like wrapping large amounts of logic with empty or otherwise useless exception handlers.
w00t for exception-throwing languages
Posted Jul 10, 2008 11:02 UTC (Thu) by renox (subscriber, #23785)
[Link]
That's *very* different: catching all possible case is difficult for C programmers so it's
difficult also for code review to find those missing case.
It's much more easy to catch those guilty of wrapping their code with empy catch{} and sending
them to do other things than programming.