Are terminal writes atomic?

Mark J. DeFilippis mark at promark.UUCP
Tue Oct 3 11:34:26 AEST 1989


In article <1118 at cs.yale.edu>, spolsky-joel at CS.YALE.EDU (Joel Spolsky) writes:
> I think this is safe. A while ago I wrote a little program that runs
> on a Unix host, and puts the time, date, and warns you if you get mail
> in the status line of TVI950's or VT100's.
> write() commands were preserved atomically.
> 

How about we take this further.  The answer to this question is an
undocumented feature of write() under Unix.  Several Authors note
that write() is atomic under Unix and that it is undocumented.
One is Marc J. Rochkind in his book _Advanced Unix Programming_,
Prentice-Hall.  Writes are Atomic, no matter what you are writing to,
even terminals.

However, if you have two processes writing to the same device simultaneously,
you cannot guarantee which one will preceed the other, (assuming no
formal communication  between the two processes course).

-- 
Adelphi University, Garden City, NY 11530                   (516) 663-1170
Department of Mathematics and Computer Science
                                 markd at adelphi.UUCP  or  mark at promark.UUCP
                      UUCP:      ...philabs!sbcs!bnlux0!adelphi!markd



More information about the Comp.unix.questions mailing list