threads2 - Programming with POSIX Threads II CS 167 IV1...

Info icon This preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 167 IV–1 Copyright © 2008 Thomas W. Doeppner. All rights reserved. Programming with POSIX Threads II
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CS 167 IV–2 Copyright © 2008 Thomas W. Doeppner. All rights reserved. Global Variables int IOfunc( ) { extern int errno; ... if (write (fd, buffer, size) == –1) { if (errno == EIO) fprintf (stderr, "IO problems ...\n"); ... return (0); } ... } Unix was not designed with multithreaded programming in mind. A good example of the implications of this is the manner in which error codes for failed system calls are made available to a program: if a system call fails, it returns –1 and the error code is stored in the global variable errno . Though this is not all that bad for single-threaded programs, it is plain wrong for multithreaded programs.
Image of page 2