mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-06 19:54:18 +00:00
_thread_suspend: hold on to the lock when suspending some other
thread, so as to not deadlock the process. _thread_resume: add wrapper git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14636
This commit is contained in:
parent
ccb4fc056b
commit
70cf4709e7
@ -565,6 +565,7 @@ DECL_TEMPLATE(darwin, thread_terminate);
|
||||
DECL_TEMPLATE(darwin, thread_create);
|
||||
DECL_TEMPLATE(darwin, thread_create_running);
|
||||
DECL_TEMPLATE(darwin, thread_suspend);
|
||||
DECL_TEMPLATE(darwin, thread_resume);
|
||||
DECL_TEMPLATE(darwin, thread_get_state);
|
||||
DECL_TEMPLATE(darwin, thread_policy);
|
||||
DECL_TEMPLATE(darwin, thread_policy_set);
|
||||
|
||||
@ -6882,6 +6882,33 @@ PRE(thread_suspend)
|
||||
// Do keep the scheduler lock while suspending any other thread.
|
||||
// Otherwise we might halt the other thread while it holds the lock,
|
||||
// which would deadlock the process.
|
||||
*flags &= ~SfMayBlock;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
POST(thread_resume)
|
||||
{
|
||||
}
|
||||
|
||||
PRE(thread_resume)
|
||||
{
|
||||
mach_msg_header_t *mh = (mach_msg_header_t *)ARG1;
|
||||
Bool self_resume = (mh->msgh_request_port == MACH_THREAD);
|
||||
|
||||
PRINT("thread_resume(%s)", name_for_port(mh->msgh_request_port));
|
||||
|
||||
AFTER = POST_FN(thread_resume);
|
||||
|
||||
if (self_resume) {
|
||||
// This doesn't make much sense. If we are resuming ourself, we can't
|
||||
// already be running. So I don't see how we can ever get here.
|
||||
vg_assert(0);
|
||||
} else {
|
||||
// Resuming some other thread. It might not yet come back to life
|
||||
// (if the suspend count is still above zero) so make sure we keep
|
||||
// holding the lock.
|
||||
*flags &= ~SfMayBlock;
|
||||
}
|
||||
}
|
||||
|
||||
@ -7375,6 +7402,9 @@ PRE(mach_msg_thread)
|
||||
case 3605:
|
||||
CALL_PRE(thread_suspend);
|
||||
return;
|
||||
case 3606:
|
||||
CALL_PRE(thread_resume);
|
||||
return;
|
||||
case 3612:
|
||||
CALL_PRE(thread_info);
|
||||
return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user