Messages in this thread | | | Date | Mon, 26 Jul 1999 22:28:21 -0400 | From | "Kevin O'Connor" <> | Subject | Linux 2.2.5: write() atomic but not fair. |
| |
I've encountered the following problem with the standard RH 6.0 release.
When using the write() system call in a multi-threaded program, the interprocess synchronization used by write() is unfair.
Specifically, we are porting a program that runs multiple "reader" threads that all send output to a single outbound TCP/IP socket. When the traffic on this multi-threaded program becomes high, several of the reader threads become starved, and only one (or perhaps two) are able to continue writing to the outbound socket. The system load on the machine also goes up dramatically until it quickly peaks at a solid 1.0 load average.
After tracking down this anomaly, I fixed the problem by wrapping the call to write() in a mutex. With this fix in place the program operates properly, and does not cause excessive cpu usage. (Or at least doesn't report excessive CPU usage.)
The requirement of the mutex definitely seems "wrong", and increases the porting requirements when converting other Unix programs to Linux. (In our case the existing system was Sun Solaris.)
-Kevin
-- ------------------------------------------------------------------------ | Kevin O'Connor "BTW, IMHO we need a FAQ for | | koconnor@cse.buffalo.edu 'IMHO', 'FAQ', 'BTW', etc. !" | ------------------------------------------------------------------------
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |