summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.cpp
diff options
context:
space:
mode:
authorGravatar Subv2014-12-03 23:22:06 -0500
committerGravatar Subv2014-12-04 00:25:35 -0500
commit029ff9f1fd013ec46f3d61510c5f95f05bca698e (patch)
tree17177b27e64fa60c0c1847ba02e8ae187f0eebad /src/core/hle/kernel/thread.cpp
parentMerge pull request #236 from rohit-n/sign-compare (diff)
downloadyuzu-029ff9f1fd013ec46f3d61510c5f95f05bca698e.tar.gz
yuzu-029ff9f1fd013ec46f3d61510c5f95f05bca698e.tar.xz
yuzu-029ff9f1fd013ec46f3d61510c5f95f05bca698e.zip
SVC: Implemented GetThreadId.
For now threads are using their Handle value as their Id, it should not really cause any problems because Handle values are unique in Citra, but it should be changed. I left a ToDo there because this is not correct behavior as per hardware.
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
-rw-r--r--src/core/hle/kernel/thread.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index f59795901..6da238828 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -49,6 +49,8 @@ public:
49 49
50 ThreadContext context; 50 ThreadContext context;
51 51
52 u32 thread_id;
53
52 u32 status; 54 u32 status;
53 u32 entry_point; 55 u32 entry_point;
54 u32 stack_top; 56 u32 stack_top;
@@ -325,6 +327,9 @@ Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 prio
325 thread_queue.push_back(handle); 327 thread_queue.push_back(handle);
326 thread_ready_queue.prepare(priority); 328 thread_ready_queue.prepare(priority);
327 329
330 // TODO(Subv): Assign valid ids to each thread, they are much lower than handle values
331 // they appear to begin at 276 and continue from there
332 thread->thread_id = handle;
328 thread->status = THREADSTATUS_DORMANT; 333 thread->status = THREADSTATUS_DORMANT;
329 thread->entry_point = entry_point; 334 thread->entry_point = entry_point;
330 thread->stack_top = stack_top; 335 thread->stack_top = stack_top;
@@ -465,6 +470,17 @@ void Reschedule() {
465 } 470 }
466} 471}
467 472
473ResultCode GetThreadId(u32* thread_id, Handle handle) {
474 Thread* thread = g_object_pool.Get<Thread>(handle);
475 if (thread == nullptr)
476 return ResultCode(ErrorDescription::InvalidHandle, ErrorModule::OS,
477 ErrorSummary::WrongArgument, ErrorLevel::Permanent);
478
479 *thread_id = thread->thread_id;
480
481 return RESULT_SUCCESS;
482}
483
468//////////////////////////////////////////////////////////////////////////////////////////////////// 484////////////////////////////////////////////////////////////////////////////////////////////////////
469 485
470void ThreadingInit() { 486void ThreadingInit() {