Home > General Development > POSIX Parallel Programming, Part 2: Message PassingPOSIX Parallel Programming, Part 2: Message Passing Eugenia Loli 2007-01-13 General Development 7 CommentsFollowing on from the tutorial in part 1 of this series, David Chisnall explores some more-flexible mechanisms for allowing processes to communicate on a POSIX-compliant system.About The Author Eugenia LoliEx-programmer, ex-editor in chief at OSNews.com, now a visual artist/filmmaker.Follow me on Twitter @EugeniaLoli 7 Comments 2007-01-13 9:48 pm CloudyIn UNIX, everything is a file, even when that approach doesn’t make sense.pretty much sums up how superficial Chisnall’s understanding of concurrency is.This article makes sense to someone who already understand multithreading. Indeed, it contains quiet a bit of inadvertant comedy.But it’s a good example of how not to write a technical article. Terms are routinely used before they are defined. Extraneous information is regularly mentioned without indicating that it’s irrelevant to the article’s topic. Metaphors (bucket of flags) obscure the concept they’re meant to illuminate.Eguenia, why do you waste space on this crap? 2007-01-13 10:50 pm Doc Pain“This article makes sense to someone who already understand multithreading. Indeed, it contains quiet a bit of inadvertant comedy.”At least it’s interesting.“Terms are routinely used before they are defined.”Maybe the author assumes that people reading his article are familiar with some basics. From a didactic point of view, it’s not a good approach.But I’d like to mention something I found when reading the article. Excuse me if it’s of no importance or just subject to individual preference. It’s about the source code examples. What language is it? C? There are variable declarations within (instead prior to) expression blocks, that won’t work, at least cc -Wall throws warnings and errors. It seems to be a violation of the C99 standard, while such “declaration and statement mixsture” is used in C++ nearly all the way.% cc -Wall -o pp1ex2 pp1ex2.cpp1ex2.c: In function `populate_array’:pp1ex2.c:11: error: ‘for’ loop initial declaration used outside C99 modepp1ex2.c: In function `average_array’:pp1ex2.c:20: error: ‘for’ loop initial declaration used outside C99 modepp1ex2.c: In function `main’:pp1ex2.c:31: error: ‘for’ loop initial declaration used outside C99 modepp1ex2.c:44: error: ‘for’ loop initial declaration used outside C99 modepp1ex2.c:46: warning: implicit declaration of function `wait’At another point, a program does a “return -1;” to signal an abnormal termination. The author could have used EXIT_SUCCESS and EXIT_FAILURE (defined in stdlib.h) instead of 0 and 1 (or -1). The use of 0 is always okay, but -1…Another thing: When declaring poiner variables, the asterisk, the pointer qualifier, is to be applied to the identifier name. The author uses two ways others than this: “int* array” or “int * array”, but “int *array” would be the standard form. The source formatting is not very good, at least from my experience (when you have to develop source code in a way that others can use it).Or maybe I’m just too much autistic. 🙂Edited 2007-01-13 22:54 2007-01-13 11:47 pm Vargolpp1ex2.c:11: error: ‘for’ loop initial declaration used outside C99 modeI’m afraid you’re reading the error message incorrectly, itactually means that the for(int i=0; … style of declaring values in loops is part of the C99 standard, but cc’s default ‘C’ is not the ISO 1999 C standard.Trycc -std=c99 -Wall -o pp1ex2 pp1ex2.cand the warning messages will disappear. 2007-01-14 4:20 pm Doc Pain“I’m afraid you’re reading the error message incorrectly, it actually means that the for(int i=0; … style of declaring values in loops is part of the C99 standard, but cc’s default ‘C’ is not the ISO 1999 C standard.”Oops… call me Mister Stupid. 🙂 The declarations of variables inside for() is of course possible with ISO C 99 (-std=c99), but not with standard C (K&R), where declarations have to be prior to statement lines. 2007-01-14 2:08 pm stestaggI would welcome anyone to explain WHY c99 forbids declarations inside loops etc.. And also why gcc can’t be made to ignore the ‘no trailing newline at end of file’ warnings.</rant> 2007-01-14 7:06 pm johndaly>>I would welcome anyone to explain WHY c99 forbids>>declarations inside loopsActually C99 allows variable declaration inside the for loop, previous versions didn’t. That’s what >>’for’ loop initial declaration used outside C99 mode<< means.GCC uses C89/C90 as its default, you will have to enable C99 mode to use C99 features. Somebody already explained how to do this. K&R mode is something totally different from C89/C90 mode and you will have to enable it too but you probably wont since there isn’t much code left in that ancient dialect.I guess you are not a C programmer, maybe you are a C++ programmer? If that’s so then it might help if I tell you that C89/C90 is roughly the C subset supported by C++.Edited 2007-01-14 19:13 2007-01-15 1:43 pm stestaggThanks for the clarification. actually, I’m a c programmer who usually uses the MS compilers.