diff options
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 6da238828..ccb927381 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -78,6 +78,17 @@ static Common::ThreadQueueList<Handle> thread_ready_queue; | |||
| 78 | static Handle current_thread_handle; | 78 | static Handle current_thread_handle; |
| 79 | static Thread* current_thread; | 79 | static Thread* current_thread; |
| 80 | 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 | |||
| 84 | /** | ||
| 85 | * Gets the next available thread id and increments it | ||
| 86 | * @return Next available thread id | ||
| 87 | */ | ||
| 88 | static u32 NextThreadId() { | ||
| 89 | return next_thread_id++; | ||
| 90 | } | ||
| 91 | |||
| 81 | /// Gets the current thread | 92 | /// Gets the current thread |
| 82 | inline Thread* GetCurrentThread() { | 93 | inline Thread* GetCurrentThread() { |
| 83 | return current_thread; | 94 | return current_thread; |
| @@ -327,9 +338,7 @@ Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 prio | |||
| 327 | thread_queue.push_back(handle); | 338 | thread_queue.push_back(handle); |
| 328 | thread_ready_queue.prepare(priority); | 339 | thread_ready_queue.prepare(priority); |
| 329 | 340 | ||
| 330 | // TODO(Subv): Assign valid ids to each thread, they are much lower than handle values | 341 | thread->thread_id = NextThreadId(); |
| 331 | // they appear to begin at 276 and continue from there | ||
| 332 | thread->thread_id = handle; | ||
| 333 | thread->status = THREADSTATUS_DORMANT; | 342 | thread->status = THREADSTATUS_DORMANT; |
| 334 | thread->entry_point = entry_point; | 343 | thread->entry_point = entry_point; |
| 335 | thread->stack_top = stack_top; | 344 | thread->stack_top = stack_top; |
| @@ -484,6 +493,7 @@ ResultCode GetThreadId(u32* thread_id, Handle handle) { | |||
| 484 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 493 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 485 | 494 | ||
| 486 | void ThreadingInit() { | 495 | void ThreadingInit() { |
| 496 | next_thread_id = INITIAL_THREAD_ID; | ||
| 487 | } | 497 | } |
| 488 | 498 | ||
| 489 | void ThreadingShutdown() { | 499 | void ThreadingShutdown() { |