lkml.org 
[lkml]   [1999]   [Jul]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectLinux 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/

\
 
 \ /
  Last update: 2005-03-22 13:53    [W:0.052 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site