- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
Cannot hold locks at a thread boundary
What does it mean ???
I am doing something like this :
void my_Recursive_fn()
{
if ( base_case){
work0
return;
}
else
{
work1
spawn my_Recursive_fn();
my_Recursive_fn();
sync;
}
return;
}
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - pkroy
Hi all,
Cannot hold locks at a thread boundary
What does it mean ???
I am doing something like this :
void my_Recursive_fn()
{
if ( base_case){
work0
return;
}
else
{
work1
spawn my_Recursive_fn();
my_Recursive_fn();
sync;
}
return;
}
Hi Pkroy,
This error is an indication that you are holding a lock across a spawn or sync. Cilkscreen complains about this for a couple of reasons:
1. The thread that is running just after a spawn or sync statement is not necessarily the same one that was running beforehand. This means that the acquire() and release() functions may be called on different threads, which is not permitted on certain kinds of locks on Windows or on pthread mutexes.
2. You can deadlock, inadvertantly. Consider the following example:
void f (lock) {
acquire(lock);
do_work();
release(lock);
}
void g (lock) {
spawn f();
acquire(lock);
do_work();
sync;
release(lock);
}
In this case, if the acquire() in g() is executed before the acquire() in f(), then the program will deadlock because the release() in g() cannot be executed until after f() has returned and g() has been able to sync. But f() will never return.
---
For these reasons, cilkscreen will generate an error if you are holding a lock across a spawn or sync boundary.
-wml
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi wml,
Thanks for an illustrative example ...
pkroy
Thanks for an illustrative example ...
pkroy
Quoting - William Leiserson (Intel)
Hi Pkroy,
This error is an indication that you are holding a lock across a spawn or sync. Cilkscreen complains about this for a couple of reasons:
1. The thread that is running just after a spawn or sync statement is not necessarily the same one that was running beforehand. This means that the acquire() and release() functions may be called on different threads, which is not permitted on certain kinds of locks on Windows or on pthread mutexes.
2. You can deadlock, inadvertantly. Consider the following example:
void f (lock) {
acquire(lock);
do_work();
release(lock);
}
void g (lock) {
spawn f();
acquire(lock);
do_work();
sync;
release(lock);
}
In this case, if the acquire() in g() is executed before the acquire() in f(), then the program will deadlock because the release() in g() cannot be executed until after f() has returned and g() has been able to sync. But f() will never return.
---
For these reasons, cilkscreen will generate an error if you are holding a lock across a spawn or sync boundary.
-wml
This error is an indication that you are holding a lock across a spawn or sync. Cilkscreen complains about this for a couple of reasons:
1. The thread that is running just after a spawn or sync statement is not necessarily the same one that was running beforehand. This means that the acquire() and release() functions may be called on different threads, which is not permitted on certain kinds of locks on Windows or on pthread mutexes.
2. You can deadlock, inadvertantly. Consider the following example:
void f (lock) {
acquire(lock);
do_work();
release(lock);
}
void g (lock) {
spawn f();
acquire(lock);
do_work();
sync;
release(lock);
}
In this case, if the acquire() in g() is executed before the acquire() in f(), then the program will deadlock because the release() in g() cannot be executed until after f() has returned and g() has been able to sync. But f() will never return.
---
For these reasons, cilkscreen will generate an error if you are holding a lock across a spawn or sync boundary.
-wml
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No problem. :)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page