Unix Programming - concurrency

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > November 2006 > concurrency





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author concurrency
gio

2006-11-21, 7:21 pm

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? CAN THIS OPERATION BE OVERLAPPED?
THANKS ALL.

Pascal Bourguignon

2006-11-21, 7:21 pm

"gio" <giorginooo.rossi@yahoo.it> 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? CAN THIS OPERATION BE OVERLAPPED?
> THANKS ALL.


And you think it will help posting your very same question to a
bazillion different newsgroups?


--
__Pascal Bourguignon__ http://www.informatimago.com/

PUBLIC NOTICE AS REQUIRED BY LAW: Any use of this product, in any
manner whatsoever, will increase the amount of disorder in the
universe. Although no liability is implied herein, the consumer is
warned that this process will ultimately lead to the heat death of
the universe.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com