summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/thread.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/thread.h')
-rw-r--r--src/core/hle/kernel/thread.h65
1 files changed, 32 insertions, 33 deletions
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index cfd073a70..389928178 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -12,22 +12,23 @@
#include "common/common_types.h"
#include "core/core.h"
-#include "core/mem_map.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/result.h"
-enum ThreadPriority {
- THREADPRIO_HIGHEST = 0, ///< Highest thread priority
- THREADPRIO_DEFAULT = 16, ///< Default thread priority for userland apps
- THREADPRIO_LOW = 31, ///< Low range of thread priority for userland apps
- THREADPRIO_LOWEST = 63, ///< Thread priority max checked by svcCreateThread
+enum ThreadPriority : s32{
+ THREADPRIO_HIGHEST = 0, ///< Highest thread priority
+ THREADPRIO_USERLAND_MAX = 24, ///< Highest thread priority for userland apps
+ THREADPRIO_DEFAULT = 48, ///< Default thread priority for userland apps
+ THREADPRIO_LOWEST = 63, ///< Lowest thread priority
};
-enum ThreadProcessorId {
- THREADPROCESSORID_0 = 0xFFFFFFFE, ///< Enables core appcode
- THREADPROCESSORID_1 = 0xFFFFFFFD, ///< Enables core syscore
- THREADPROCESSORID_ALL = 0xFFFFFFFC, ///< Enables both cores
+enum ThreadProcessorId : s32 {
+ THREADPROCESSORID_DEFAULT = -2, ///< Run thread on default core specified by exheader
+ THREADPROCESSORID_ALL = -1, ///< Run thread on either core
+ THREADPROCESSORID_0 = 0, ///< Run thread on core 0 (AppCore)
+ THREADPROCESSORID_1 = 1, ///< Run thread on core 1 (SysCore)
+ THREADPROCESSORID_MAX = 2, ///< Processor ID must be less than this
};
enum ThreadStatus {
@@ -43,6 +44,7 @@ enum ThreadStatus {
namespace Kernel {
class Mutex;
+class Process;
class Thread final : public WaitObject {
public:
@@ -70,12 +72,6 @@ public:
void Acquire() override;
/**
- * Checks if the thread is an idle (stub) thread
- * @return True if the thread is an idle (stub) thread, false otherwise
- */
- inline bool IsIdle() const { return idle; }
-
- /**
* Gets the thread's current priority
* @return The current thread's priority
*/
@@ -88,6 +84,12 @@ public:
void SetPriority(s32 priority);
/**
+ * Temporarily boosts the thread's priority until the next time it is scheduled
+ * @param priority The new priority
+ */
+ void BoostPriority(s32 priority);
+
+ /**
* Gets the thread's thread ID
* @return The thread's ID
*/
@@ -127,6 +129,12 @@ public:
*/
void Stop();
+ /*
+ * Returns the Thread Local Storage address of the current thread
+ * @returns VAddr of the thread's TLS
+ */
+ VAddr GetTLSAddress() const;
+
Core::ThreadContext context;
u32 thread_id;
@@ -135,14 +143,19 @@ public:
u32 entry_point;
u32 stack_top;
- s32 initial_priority;
- s32 current_priority;
+ s32 nominal_priority; ///< Nominal thread priority, as set by the emulated application
+ s32 current_priority; ///< Current thread priority, can be temporarily changed
+
+ u64 last_running_ticks; ///< CPU tick when thread was last running
s32 processor_id;
+ s32 tls_index; ///< Index of the Thread Local Storage of the thread
+
/// Mutexes currently held by this thread, which will be released when it exits.
boost::container::flat_set<SharedPtr<Mutex>> held_mutexes;
+ SharedPtr<Process> owner_process; ///< Process that owns this thread
std::vector<SharedPtr<WaitObject>> wait_objects; ///< Objects that the thread is waiting on
VAddr wait_address; ///< If waiting on an AddressArbiter, this is the arbitration address
bool wait_all; ///< True if the thread is waiting on all objects before resuming
@@ -150,9 +163,6 @@ public:
std::string name;
- /// Whether this thread is intended to never actually be executed, i.e. always idle
- bool idle = false;
-
private:
Thread();
~Thread() override;
@@ -161,16 +171,13 @@ private:
Handle callback_handle;
};
-extern SharedPtr<Thread> g_main_thread;
-
/**
* Sets up the primary application thread
- * @param stack_size The size of the thread's stack
* @param entry_point The address at which the thread should start execution
* @param priority The priority to give the main thread
* @return A shared pointer to the main thread
*/
-SharedPtr<Thread> SetupMainThread(u32 stack_size, u32 entry_point, s32 priority);
+SharedPtr<Thread> SetupMainThread(u32 entry_point, s32 priority);
/**
* Reschedules to the next available thread (call after current thread is suspended)
@@ -214,14 +221,6 @@ void WaitCurrentThread_WaitSynchronization(std::vector<SharedPtr<WaitObject>> wa
void WaitCurrentThread_ArbitrateAddress(VAddr wait_address);
/**
- * Sets up the idle thread, this is a thread that is intended to never execute instructions,
- * only to advance the timing. It is scheduled when there are no other ready threads in the thread queue
- * and will try to yield on every call.
- * @return The handle of the idle thread
- */
-SharedPtr<Thread> SetupIdleThread();
-
-/**
* Initialize threading
*/
void ThreadingInit();