[geeks] Solaris losing-writers question

Lionel Peterson lionel4287 at verizon.net
Sat Aug 13 10:28:38 CDT 2005


>From: Patrick Giagnocavo 717-201-3366 <patrick at zill.net>
>Date: Fri Aug 12 23:05:05 CDT 2005
>To: geeks at sunhelp.org
>Subject: [geeks] Solaris losing-writers question

>Here is my situation and my question:
>

<snip>

>Question:  assume that 2 comments are made to the same pages at the same time, by two different processes (remember that Apache will run things in different processes so we can't do serialized requests easily from within the code).  So the comments are each being appended to the same file.
>
>Does one of the writers lose (not ending with the data being recorded)?  Or does each writer write data into the file, but there are no guarantees which comes first?

(Work with me here) Well, in a single-processor machine, only one process can access the file at a time, because only one process is running at a time. So, if two users attempt to save their comments at the same time, one will get the file lock and start to tranfer the file. Then the first process will give up the thread, and the second process will attempt to get write access to a locked file - it should fail, returning control to the calling program with an appropriate error message, which could be trapped and the file update could be attempted again.

In a multi-processor system, where two processes could be running at the same time, the filesystem should still only allow one process to access the file at a time.

The above assumes that they are both appending to the same pre-existing file.

That is how I understand it, anyway...

Hope this helps.



More information about the geeks mailing list