07.01.2013 Views

Lecture Notes in Computer Science 3472

Lecture Notes in Computer Science 3472

Lecture Notes in Computer Science 3472

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

18 Run-Time Verification 533<br />

the empty set, therefore no locks protects v. A warn<strong>in</strong>g is issued s<strong>in</strong>ce accesses<br />

to variable v are sometimes protected by the lock mu1 and sometimes by the<br />

lock mu2, thus no locks protects all accesses to v for the whole computation.<br />

⏐<br />

Program Locks held C (v)<br />

⏐<br />

{} {mu1,mu2}<br />

⏐<br />

lock(mu1)<br />

⏐<br />

{mu1} {mu1,mu2}<br />

⏐<br />

v := v+1<br />

⏐<br />

{mu1} {mu1}<br />

⏐<br />

Time ⏐ unlock(mu1)<br />

⏐<br />

{} {mu1}<br />

⏐ lock(mu2)<br />

⏐<br />

{mu2} {mu1}<br />

⏐ v := v+1<br />

⏐<br />

{m2} {}<br />

⏐ unlock(mu2)<br />

�<br />

{} {}<br />

Fig. 18.3. Example of the execution progress for the Eraser algorithm <strong>in</strong> the case of a<br />

variable v used by a six statements program.<br />

When a race is reported, Eraser <strong>in</strong>dicates both the file and l<strong>in</strong>e number at<br />

which the <strong>in</strong>struction violat<strong>in</strong>g the lock<strong>in</strong>g discipl<strong>in</strong>e is located. The report also<br />

<strong>in</strong>cludes the thread ID, memory address, type of memory access, and important<br />

register values such as the program counter and stack po<strong>in</strong>ter.<br />

The Eraser lock<strong>in</strong>g discipl<strong>in</strong>e is too strong. There are three very common<br />

programm<strong>in</strong>g practices that violate the discipl<strong>in</strong>e, yet are free from any data<br />

races: <strong>in</strong>itialization, read-shared data and read-write locks. These cases have been<br />

addressed by Savage et al. who extended the Lockset algorithm to accommodate<br />

<strong>in</strong>itialization, read-shared data and read-write locks [SBN + 97].<br />

The Eraser algorithm was implemented for Digital Unix and it has been<br />

used to detect data races <strong>in</strong> several programs. In particular, it tackled some<br />

large multi-threaded servers written by experienced researchers at Digital Equipment<br />

Corporation’s System Research Center: the HTTP server and <strong>in</strong>dex<strong>in</strong>g<br />

eng<strong>in</strong>e from AltaVista, the Vesta cache server, and the Petal distributed disk<br />

system. Eraser found undesirable race conditions <strong>in</strong> three of the four server programs<br />

[SBN + 97]. A version of the Eraser algorithm which addresses also Java<br />

programs has been implemented <strong>in</strong> PathExplorer [HR01b]. F<strong>in</strong>ally, Compaq provides<br />

a run-time debugg<strong>in</strong>g and analysis tool for multi-threaded applications<br />

called Visual Threads which f<strong>in</strong>ds data races by the Eraser algorithm [Har00].<br />

18.4.2 Deadlock Detection<br />

The problem of deadlock is common <strong>in</strong> parallel programs. Deadlock can occur<br />

whenever shared resources are required to accomplish a task. For <strong>in</strong>stance, if

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!