This is an archive of the discontinued LLVM Phabricator instance.

[tsan] Add support for GCD dispatch_suspend and dispatch_resume
ClosedPublic

Authored by kubamracek on Nov 24 2016, 11:00 AM.

Details

Summary

GCD queues can be suspended and resumed with dispatch_suspend and dispatch_resume. Sometimes this is used as synchronization, e.g. in the following example, f1() is always fully executed before f2():

dispatch_suspend(q);
dispatch_async(q, ^{ f2(); });
f1();
dispatch_resume(q);

It seems to me that all we need to do is to add synchronization between the call to dispatch_resume and any subsequent executions of blocks in the queue that was resumed. We already have an Acquire(q) before the block executes, so this patch just adds the Release(q) in an interceptor of dispatch_resume.

Diff Detail

Event Timeline

kubamracek retitled this revision from to [tsan] Add support for GCD dispatch_suspend and dispatch_resume.
kubamracek updated this object.
kubamracek added a reviewer: dvyukov.
kubamracek set the repository for this revision to rL LLVM.
kubamracek added a project: Restricted Project.
kubamracek added subscribers: llvm-commits, zaks.anna.
dvyukov accepted this revision.Nov 24 2016, 11:36 AM
dvyukov edited edge metadata.
This revision is now accepted and ready to land.Nov 24 2016, 11:36 AM
This revision was automatically updated to reflect the committed changes.