diff options
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index f59795901..8d65dc84d 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; |
| @@ -76,6 +78,9 @@ static Common::ThreadQueueList<Handle> thread_ready_queue; | |||
| 76 | static Handle current_thread_handle; | 78 | static Handle current_thread_handle; |
| 77 | static Thread* current_thread; | 79 | static Thread* current_thread; |
| 78 | 80 | ||
| 81 | static const u32 INITIAL_THREAD_ID = 1; ///< The first available thread id at startup | ||
| 82 | static u32 next_thread_id; ///< The next available thread id | ||
| 83 | |||
| 79 | /// Gets the current thread | 84 | /// Gets the current thread |
| 80 | inline Thread* GetCurrentThread() { | 85 | inline Thread* GetCurrentThread() { |
| 81 | return current_thread; | 86 | return current_thread; |
| @@ -325,6 +330,7 @@ Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 prio | |||
| 325 | thread_queue.push_back(handle); | 330 | thread_queue.push_back(handle); |
| 326 | thread_ready_queue.prepare(priority); | 331 | thread_ready_queue.prepare(priority); |
| 327 | 332 | ||
| 333 | thread->thread_id = next_thread_id++; | ||
| 328 | thread->status = THREADSTATUS_DORMANT; | 334 | thread->status = THREADSTATUS_DORMANT; |
| 329 | thread->entry_point = entry_point; | 335 | thread->entry_point = entry_point; |
| 330 | thread->stack_top = stack_top; | 336 | thread->stack_top = stack_top; |
| @@ -465,9 +471,21 @@ void Reschedule() { | |||
| 465 | } | 471 | } |
| 466 | } | 472 | } |
| 467 | 473 | ||
| 474 | ResultCode GetThreadId(u32* thread_id, Handle handle) { | ||
| 475 | Thread* thread = g_object_pool.Get<Thread>(handle); | ||
| 476 | if (thread == nullptr) | ||
| 477 | return ResultCode(ErrorDescription::InvalidHandle, ErrorModule::OS, | ||
| 478 | ErrorSummary::WrongArgument, ErrorLevel::Permanent); | ||
| 479 | |||
| 480 | *thread_id = thread->thread_id; | ||
| 481 | |||
| 482 | return RESULT_SUCCESS; | ||
| 483 | } | ||
| 484 | |||
| 468 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 485 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 469 | 486 | ||
| 470 | void ThreadingInit() { | 487 | void ThreadingInit() { |
| 488 | next_thread_id = INITIAL_THREAD_ID; | ||
| 471 | } | 489 | } |
| 472 | 490 | ||
| 473 | void ThreadingShutdown() { | 491 | void ThreadingShutdown() { |