File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change 242242memory, i.e. several variables shared by processes.
243243\item Dekker's solution is presented as a first solution to the problem of
244244mutual exclusion of 2 processes, without having to apply the mechanism of
245- strict alternation, i.e. if second process does not express will to enter
245+ strict alternation, i.e. if second process does not express the will to enter
246246critical section, the first can enter how many times it wants
247247(and ifdef([[[NOSPELLCHECK]]], [[[vice versa]]])).
248248Dekker's solution is not trivial, compare it with 16 year younger
265265Each process must check if the file exists and if yes, has to wait.
266266\end {itemize }
267267\begin {alltt }
268- void \funnm{lock}(char *lockfile) \{
269- while( (fd = open(lockfile,
270- O\_RDWR|O\_CREAT|\emprg{O\_EXCL}, 0600)) == -1)
268+ void \funnm{lock}(char *lockfile) \{
269+ while( (fd = open(lockfile,
270+ O\_RDWR|O\_CREAT|\emprg{O\_EXCL}, 0600)) == -1)
271271 sleep(1); {\rm /* waiting in a loop for unlock */}
272- close(fd);
273- \}
272+ close(fd);
273+ \}
274274
275- void \funnm{unlock}(char *lockfile) \{
276- unlink(lockfile);
275+ void \funnm{unlock}(char *lockfile) \{
276+ unlink(lockfile);
277277\}
278278\end {alltt }
279279\end {slide }
You can’t perform that action at this time.
0 commit comments