Pthreads Programming by Bradford Nicholes, Dick Buttlar, and Jacqueline Proulx Farrell Here are the changes from the February 1998 reprint: (iii): changed "Jackie Farrell" to "Jacqueline Proulx Farrell" {2}: addition to the code: new line 1: #include line added before "main": extern int and: changed "main()" to "main(void)" {3}: added a 4th line of code: return 0; {9}: added to beginning of code: #include #include #include replaced blank line 4 with: #include {10}: line added before "main": extern int and: changed "main()" to "main(void)" and: in line after "/*initialize shared...": changed "0" to "0660"; in two lines that read "exit()", inserted a "0" between the parens; in the two "waitpid" lines, added "&" before "status"; changed blank next-to-last line to read: return 0; {11}: line 6 of code: added "fork" in parens after "perror" and "1" in parens after "exit"; changed line 12 ("exit()") to read "return 0;" {13}: addition to the code: new line 1: #include line added before "main": extern int and: changed "main()" to "main(void)" {14}: changed blank next-to-last line to read: return 0; also added a paragraph after the last one: The formal prototype of a start routine is (void*)routine(void*arg). In our code example, we are adding threads to an existing program (a not atypical scenario) and using the (void *) cast to quit the compiler. In later examples, we redeclare the routine to the correct prototype where possible. (15): reprinted for pagebreak {18}: addition to the code: new line 1: #include line added before "main(int argc...": extern int and changed blank next-to-last line to: return 0; {21}: line added before "main": extern int and: changed "main()" to "main(void)"; changed line "routine_x()" to: void routine_x(void) {23}: added two lines to start of example 1-8: #include #include <9781565921153.h> line added before "main(int argc...": extern int {24}: new next-to-last line in example 1-8: return 0; in example 1-9, changed "exit(-1)" to "exit(1)" (line -6) {25}: same change as to line -6 on p. 24 made to line -5 of example 1-9 on this page {44}: added new first line to 2-6: extern int {45}: new final line of 2-6: return 0; {49}: changed blank line 5 of 2-7 to: extern int and added a line after "server_comm....": return 0 (50): reprinted for pagebreak {55}: 2-9: line added before "main()" (near middle of page): extern int and: changed "main()" to "main(void)"; tabbed line "mult(size, row..." to be under "(column" in the line above; added next-to-last line: return 0 {56}: 2-10: line added before "main()": extern int and: changed "main()" to "main(void) {57}: 2-10: indented line "/* Wait for peers..."; also, in the next-to-last para, line -2: added a space between "main" (in itals) and "routine" (58): line 1: changed "mallocoutside" to "malloc outside" (64): next-to-last para., line 2: changed "mutexfor" to "mutex for" {72}: 3-4: line 8: changed "return 1" to "return 0"; line 12: changed semicolon after "index" to a comma {73}: next-to-last line of 3-4: changed "1" to "0" {74}: 3-5: line 5: changed "1" to "0"; line 7: changed semicolon after "index" to a comma {75}: line "break;": tabbed it over to align with the "if" above; changed last line to "return 0;" and aligned the r with the p in "9781565921153" above {78}: added these lines to the beginning of example 3-6: #include #include #include #include added to end of #includes: #include added before "int shared...": #ifndef _POSIX_THREAD_PROCESS_SHARED #error "This platform does not support process shared mutex" #endif line added before "main()": extern int and: changed "main()" to "main(void); also, 5 lines below that ("shared_mem_id..."): changed "0" to "0660" (79): reprinted for pagebreak {80}: para. 2, line -2: changed ".._signalto" to ".._signal to" added line to beginning of 3-7: #include line added before "main()": extern int and: changed "main()" to "main(void)"; 8 lines below that: moved the "}" to align with "for" two lines above, and changed the blank line after the close curly bracket to read: return 0; (81): reprinted for pagebreak {82}: line 3: changed "watch_countprints" to "watch_count prints" {85}: line 12 of 3-8: changed "return 1;" to "return 0;" (87): 3-9: changed all the "rwdrp"s to "rdwrp", here and in the text 3-10, line 4: changed "readers_waiting" to "writer_writing" 3rd line from bottom of page: changed "readers_readingcount" to "readers_reading count" (88): 3 more changes from "rwdrp" to "rdwrp" {94}: 3-18: changed line 3 to read: extern int and added a line before the final }: return 0; {96}: 3-20: added a new first line: extern int and added a line before the final }: return 0; (101): 3-23: in 2nd comment: changed "th" to "the" {103}: line 1 of 3-25: added "int" to beginning of line; 9th line from bottom: changed "9781565921153_cond_signal" to "pthread_cond_broadcast" {104}: 3-26: 12: changed line to read "return 0;" {105}: 3-26: added line before final }: return 0; {106}: 3-28: added new 1st line: extern int {107}: 3-28: deleted line 2; also added line before final }: return 0; {113}: added new first line to 4-2: #ifdef _POSIX_THREAD_ATTR_STACKSIZE 3 lines below that: changed "If" to "if"; added a final line: #endif {115}: added these lines after line 1 of 4-5: . 9781565921153_attr_init (&custom_attr); . {120}: added the start of 2nd line of 4-10: "int" {121}: also added "int" to start of lines 3 and 13 {123}: changed line 3 of 4-11 to read: int init_comm(void) and line -4 to read: void free_conn(int *connp) {124}: added "int" to start of 1st line of 4-12 {126}: added "int" to start of lines 1 and 13 of 4-13 {131}: added the following lines to beginning of 4-14: #include #include #include #include #include <9781565921153.h> line added before "main()": extern int and: changed "main()" to "main(void)" {132}: line -7 0f 4-14: changed the "I" near the end of the line to "i"; changed blank line -3 to "}" aligned above "printf"; added a line below "printf...": return 0; {133}: line -5 of 4-15: lowercased the "I" {134}: 4-16: line 9: changed "type" to "state"; in line 10, changed "state" to "type"; 6th line from end of example: added "%d" before "\n" {152}: added semicolons to the end of lines 10 and 11 of code {155}: added new 1st line to 4-26: extern int and: changed "server main()" to "main(void)" {156}: added next-to-last line to 4-26: return 0; {159}: added line to replace middle dot in 4-27: high_prio = sched_get_priority_max(SCHED_FIFO); {160}: added sentence after parenthetical in para. 1: The priority passed is an integer argument set up in the same manner as a thread's priority value. {162}: at end of example: added these lines: . . . } {172}: 5-1: line added before "main()": extern int and: changed "main()" to "main(void)" {173}: added "void *" to start of line 1 of 5-2; also indented the lines from "sigwait..." to "9781565921153_mutex_unlock..."; added a new next-to-last line: return NULL; (174): indented the last 3 lines on the page {175}: 5-4: put "void *arg" in the parens in line 1; added a next-to-last line: return (NULL); {177}: added "void" to start of line 2 of 5-5; indented lines 8, 12, and 17; in line 14, changed "[j+l]" to "[j]" {178}: added "void" to start of line 1 of 5-6; indented lines 8 and 12 {184}: 5-8: added a final line: a "}" aligned with the "{" in line 2; also, in the next-to-last text para., changed both instances of "9781565921153_test_cancel" to "pthread_testcancel" {216}: added "void" to start of line 3 of both example 6-4 and 6-5 {217}: ditto for example 6-6; also in 6-6, lowercased the "I" in line 10 {218}: ditto for example 6-7; lowercased the "I" in line 9 {238-239}: for all of example A-1, when there's a word with "*" in front on a line by itself, moved that back to align with the other "*"s above. The same goes for "estring[20];" on p. 238; also, on 239, in A-2: changed blank line 4 to: extern int {240}: A-2: next-to-last line was "}", is now: return 0; (247): line 2: changed "9781565921153_attr_getschedcalls" to "9781565921153_attr_getsched calls" (248): under "Process-Blocking Calls": changed "tcdrainas" to "tcdrain as" (269): added the following to the next-to-last para.: Whenever possible, our books use RepKover (tm), a durable and flexible lay-flat binding. If the page count exceeds RepKover's limit, perfect binding is used.