summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.h
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2014-12-22 04:32:03 -0200
committerGravatar Yuri Kunde Schlesner2015-01-09 03:51:55 -0200
commitba72208cd4905410eab8b996da0fa05fd05c72ff (patch)
tree3dcaf53894232e83741d3a524c7c53b8da60409c /src/core/hle/kernel/thread.h
parentMove ThreadContext to core/core.h and deal with the fallout (diff)
downloadyuzu-ba72208cd4905410eab8b996da0fa05fd05c72ff.tar.gz
yuzu-ba72208cd4905410eab8b996da0fa05fd05c72ff.tar.xz
yuzu-ba72208cd4905410eab8b996da0fa05fd05c72ff.zip
Kernel: Move Thread's definition to the header file
Diffstat (limited to 'src/core/hle/kernel/thread.h')
-rw-r--r--src/core/hle/kernel/thread.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index 58bd85ac6..51290975e 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -4,8 +4,12 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <string>
8#include <vector>
9
7#include "common/common_types.h" 10#include "common/common_types.h"
8 11
12#include "core/core.h"
9#include "core/mem_map.h" 13#include "core/mem_map.h"
10 14
11#include "core/hle/kernel/kernel.h" 15#include "core/hle/kernel/kernel.h"
@@ -48,6 +52,56 @@ enum WaitType {
48 52
49namespace Kernel { 53namespace Kernel {
50 54
55class Thread : public Kernel::Object {
56public:
57 std::string GetName() const override { return name; }
58 std::string GetTypeName() const override { return "Thread"; }
59
60 static const HandleType HANDLE_TYPE = HandleType::Thread;
61 HandleType GetHandleType() const override { return HANDLE_TYPE; }
62
63 inline bool IsRunning() const { return (status & THREADSTATUS_RUNNING) != 0; }
64 inline bool IsStopped() const { return (status & THREADSTATUS_DORMANT) != 0; }
65 inline bool IsReady() const { return (status & THREADSTATUS_READY) != 0; }
66 inline bool IsWaiting() const { return (status & THREADSTATUS_WAIT) != 0; }
67 inline bool IsSuspended() const { return (status & THREADSTATUS_SUSPEND) != 0; }
68 inline bool IsIdle() const { return idle; }
69
70 ResultVal<bool> WaitSynchronization() override;
71
72 Core::ThreadContext context;
73
74 u32 thread_id;
75
76 u32 status;
77 u32 entry_point;
78 u32 stack_top;
79 u32 stack_size;
80
81 s32 initial_priority;
82 s32 current_priority;
83
84 s32 processor_id;
85
86 WaitType wait_type;
87 Handle wait_handle;
88 VAddr wait_address;
89
90 std::vector<Handle> waiting_threads;
91
92 std::string name;
93
94 /// Whether this thread is intended to never actually be executed, i.e. always idle
95 bool idle = false;
96
97private:
98 // TODO(yuriks) Temporary until the creation logic can be moved into a static function
99 friend Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 priority,
100 s32 processor_id, u32 stack_top, int stack_size);
101
102 Thread() = default;
103};
104
51/// Creates a new thread - wrapper for external user 105/// Creates a new thread - wrapper for external user
52Handle CreateThread(const char* name, u32 entry_point, s32 priority, u32 arg, s32 processor_id, 106Handle CreateThread(const char* name, u32 entry_point, s32 priority, u32 arg, s32 processor_id,
53 u32 stack_top, int stack_size=Kernel::DEFAULT_STACK_SIZE); 107 u32 stack_top, int stack_size=Kernel::DEFAULT_STACK_SIZE);
@@ -78,6 +132,9 @@ Handle ArbitrateHighestPriorityThread(u32 arbiter, u32 address);
78/// Arbitrate all threads currently waiting... 132/// Arbitrate all threads currently waiting...
79void ArbitrateAllThreads(u32 arbiter, u32 address); 133void ArbitrateAllThreads(u32 arbiter, u32 address);
80 134
135/// Gets the current thread
136Thread* GetCurrentThread();
137
81/// Gets the current thread handle 138/// Gets the current thread handle
82Handle GetCurrentThreadHandle(); 139Handle GetCurrentThreadHandle();
83 140