Cleanup and add SetThreadPrecedence().
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
#include <mach/mach_types.h>
|
#include <mach/mach_types.h>
|
||||||
#include <mach/thread_act.h>
|
#include <mach/thread_act.h>
|
||||||
#include <mach/mach_init.h>
|
#include <mach/mach_init.h>
|
||||||
|
#include <mach/mach_error.h>
|
||||||
#include "Backtrace.h"
|
#include "Backtrace.h"
|
||||||
|
#include "RageLog.h"
|
||||||
|
|
||||||
bool SuspendThread( uint64_t threadHandle )
|
bool SuspendThread( uint64_t threadHandle )
|
||||||
{
|
{
|
||||||
@@ -29,16 +31,26 @@ bool GetThreadBacktraceContext(uint64_t iID, BacktraceContext *ctx)
|
|||||||
ppc_thread_state state;
|
ppc_thread_state state;
|
||||||
mach_msg_type_number_t count = PPC_THREAD_STATE_COUNT;
|
mach_msg_type_number_t count = PPC_THREAD_STATE_COUNT;
|
||||||
|
|
||||||
if (thread_get_state(thread, PPC_THREAD_STATE, thread_state_t(&state),
|
if( thread_get_state(thread, PPC_THREAD_STATE, thread_state_t(&state), &count) )
|
||||||
&count))
|
|
||||||
return false;
|
return false;
|
||||||
ctx->FramePtr = (void *)state.r1;
|
ctx->FramePtr = (void *)state.r1;
|
||||||
ctx->PC = (void *)state.srr0;
|
ctx->PC = (void *)state.srr0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetThreadPrecedence( int prec )
|
||||||
|
{
|
||||||
|
thread_precedence_policy po = { prec };
|
||||||
|
kern_return_t ret = thread_policy_set( mach_thread_self(), THREAD_PRECEDENCE_POLICY,
|
||||||
|
(int *)&po, THREAD_PRECEDENCE_POLICY_COUNT );
|
||||||
|
|
||||||
|
if( ret != KERN_SUCCESS )
|
||||||
|
LOG->Warn( "Couldn't set the precedence for the input thread: %s",
|
||||||
|
mach_error_string(ret) );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2004 Steve Checkoway
|
* (c) 2004, 2005 Steve Checkoway
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
|||||||
@@ -4,11 +4,12 @@
|
|||||||
bool SuspendThread( uint64_t threadHandle );
|
bool SuspendThread( uint64_t threadHandle );
|
||||||
bool ResumeThread( uint64_t threadHandle );
|
bool ResumeThread( uint64_t threadHandle );
|
||||||
uint64_t GetCurrentThreadId();
|
uint64_t GetCurrentThreadId();
|
||||||
|
void SetThreadPrecedence( int prec );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2004 Steve Checkoway
|
* (c) 2004, 2005 Steve Checkoway
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
|||||||
Reference in New Issue
Block a user