Re: thread concurrency (POSIX)
- From: "gio" <giorginooo.rossi@xxxxxxxx>
- Date: 21 Nov 2006 15:37:23 -0800
Pascal Bourguignon ha scritto:
"gio" <giorginooo.rossi@xxxxxxxx> writes:
Hi all.
I have a multithread application running on a multiprocessor ( 2 thread
can be running at the same time).
Suppose I have 2 thread:
t1 lists the content of a directory (using opendir and readdir_r) and
t2 delete a file.
Suppose also I have a directory /home that contains 2 file txt1 and
txt2.
Consider this scenario:
t1 read and print the content of /home
t2 delete txt1.
if t1 and t2 are running at the same time there are 3 possibility:
1.: t2 deletes txt1 first that t1 reads it with readdir_r
(IN THIS CASE THE OUTPUT OF T1 IS : TXT2)
2.: t2 deletes txt1 after t1 has read it with readdir_r
(IN THIS CASE THE OUTPUT OF T1 IS : TXT1 TXT2 ALSO IF TXT1 DOESN'T
EXIST)
3.: t2 deletes txt1 at the same time t1 reads it with readdir_r
WHAT APPENS IN THIS CASE AT LEVEL OF O.S. ? CAN THIS OPERATION BE
OVERLAPPED?
On one hand, POSIX mandates that file creation (creat, open) and file
suppression (unlink) be atomic. On the other hand, the way readdir
specification is worded, the suppression of a file has no effect on
the other directory entries that should still be all scanned by
readdir.
The only thing is that when the entry is removed after openddir or
rewinddir, it may still be read or not.
So:
reading an entry with readdir ==> the entry was present in the
directory when opendir or
rewinddir was executed.
is the only thing you can know.
This is the same for threads or processes.
--
__Pascal Bourguignon__ http://www.informatimago.com/
NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.
thanks for your answer but I don't understand.
what appens at level of O.S.(e.g. linux) when 2 request for the same
file arrive at the same time (one from readdir_r and the other from
remove ) ?
.
- Follow-Ups:
- Re: thread concurrency (POSIX)
- From: Pascal Bourguignon
- Re: thread concurrency (POSIX)
- References:
- thread concurrency (POSIX)
- From: gio
- Re: thread concurrency (POSIX)
- From: Pascal Bourguignon
- thread concurrency (POSIX)
- Prev by Date: Re: thread concurrency (POSIX)
- Next by Date: Re: thread concurrency (POSIX)
- Previous by thread: Re: thread concurrency (POSIX)
- Next by thread: Re: thread concurrency (POSIX)
- Index(es):
Relevant Pages
|
|