|
11 | 11 | * |
12 | 12 | * The file middle is denoted via '|' character. |
13 | 13 | * |
14 | | - * You have three ways of running it. Use the 'reader' command to print the |
15 | | - * present state of the line while holding a lock. |
16 | | - * |
17 | | - * (1) The following will not lock at all: |
18 | | - * |
19 | | - * terminal1$ ./fcntl-locking xxx |
20 | | - * |
21 | | - * terminal2$ ./reader -l xxx |
| 14 | + * The parent process will periodically dump the file contents while adhering |
| 15 | + * to the locking protocol. |
22 | 16 | * |
23 | 17 | * You could also use the shell to print the file without locking on read: |
24 | 18 | * |
|
28 | 22 | * |
29 | 23 | * _###./#./////_///.__#_____/_#___._#_|####_//..._#/.##._#.../..#####__# |
30 | 24 | * |
| 25 | + * You have three ways of running it: |
| 26 | + * |
| 27 | + * (1) The following will not lock at all: |
| 28 | + * |
| 29 | + * terminal1$ ./fcntl-locking xxx |
| 30 | + * |
31 | 31 | * (2) Will use locking for the 2nd half of the file with descriptor sharing |
32 | 32 | * (that's the wrong solution, see "NOTE" below in the code): |
33 | 33 | * |
34 | 34 | * terminal1$ ./fcntl-locking -l xxx |
35 | 35 | * |
36 | | - * terminal2$ ./reader -l xxx |
37 | | - * |
38 | 36 | * You will see something "better" but obviously it does not work correctly. |
39 | 37 | * The first half sees contention which is fine but the 2nd half should have |
40 | 38 | * been composed from the same character since only one process is allowed to |
|
47 | 45 | * |
48 | 46 | * terminal1$ ./fcntl-locking -L xxx |
49 | 47 | * |
50 | | - * terminal2$ ./reader -l xxx |
51 | | - * |
52 | 48 | * You should see something like the following output. Note that the 1st half |
53 | 49 | * is not much random because of the scheduler and a side effect of the implicit |
54 | 50 | * ordering based on synchronization on the file middle position. The important |
|
0 commit comments