So, does your head hurt now?
(taking two Motrin tablets) Well, some. It’s hard to think about all the
ways threads can interleave.
Indeed it is. I am always amazed at how so few line of code, when
concurrent execution is involved, can become nearly impossible to understand.
Me too! It’s kind of embarrassing, as a Computer Scientist, not to be
able to make sense of five lines of code.
Oh, don’t feel too badly. If you look through the first papers on con-
current algorithms, they are sometimes wrong! And the authors often professors!
(gasps) Professors can be . umm. wrong?
Yes, it is true. Though don’t tell anybody – it’s one of our trade
I am sworn to secrecy. But if concurrent code is so hard to think about,
and so hard to get right, how are we supposed to write correct concurrent code?
Well that is the real question, isn’t it? I think it starts with a few
simple things. First, keep it simple! Avoid complex interactions between threads,
and use well-known and tried-and-true ways to manage thread interactions.
Like simple locking, and maybe a producer-consumer queue?
Exactly! Those are common paradigms, and you should be able to
produce the working solutions given what you’ve learned. Second, only use con-
currency when absolutely needed; avoid it if at all possible. There is nothing
worse than premature optimization of a program.
I see – why add threads if you don’t need them?
Exactly. Third, if you really need parallelism, seek it in other sim-
plified forms. For example, the Map-Reduce method for writing parallel data
analysis code is an excellent example of achieving parallelism without having to
handle any of the horrific complexities of locks, condition variables, and the other
nasty things we’ve talked about.
Map-Reduce, huh? Sounds interesting – I’ll have to read more about
it on my own.
Good! You should. In the end, you’ll have to do a lot of that, as
what we learn together can only serve as the barest introduction to the wealth of
knowledge that is out there. Read, read, and read some more! And then try things
out, write some code, and then write some more too. As Gladwell talks about in
his book “Outliers”, you need to put roughly 10,000 hours into something in
order to become a real expert. You can’t do that all inside of class time!
Wow, I’m not sure if that is depressing, or uplifting. But I’ll assume
the latter, and get to work! Time to write some more concurrent code.
FONDO NACIONAL DE DESARROLLO REGIONAL Proyectos de Energía Rural ENTIDAD SOLICITANTE 1. Nombre de la Institución: . 2. Número de RUC de la Institución: . 3. Representante Legal: 4. Dirección (Calle y Nr.) : . Casilla: . 5. Teléfono (s) : . Fax: . E-mail: . En caso que hubiera alguna forma más rápida para lograr comunicación con su Gobierno Municipa
2010, Issue 3 Mindfulness Can Reduce School Anxiety in Kids In this issue of the Health Update, we bring you tips from theWorldCare Consortium hospitals on reducing school-related stress for kids, and on the health benefits of olive oil. You’ll also learn Starting a new school year can be a real stressorabout a new study on cancer treatment from a top cancer institute. for kids