Is write(2) "atomic" ?

Naim Abdullah naim at eecs.nwu.edu
Tue Jul 12 20:12:23 AEST 1988


Do UNIX semantics guarantee that write(2) calls will be "atomic" ?

Suppose, process A executes write(fd, "123", 3) and process B
executes write(fd, "456", 3) "concurrently". The file descriptor fd
is shared between them (the file was creat(2)'ed for writing by the
common parent of A and B). Does UNIX guarantee that the contents of
the descriptor will be "123456" or "456123" (depending on which of
A and B won the race) but never "124536" ? Does it make a difference
whether the descriptor is a pipe or a terminal or a disk file or a
tape drive or something else ?

		      Naim Abdullah
		      Dept. of EECS,
		      Northwestern University

		      Internet: naim at eecs.nwu.edu
		      Uucp: {oddjob, chinet, gargoyle}!nucsrl!naim



More information about the Comp.unix.wizards mailing list