summaryrefslogtreecommitdiff
path: root/arm9/lib/include/OS_thread.h
diff options
context:
space:
mode:
authorCleverking2003 <30466983+Cleverking2003@users.noreply.github.com>2020-05-18 22:26:48 +0300
committerGitHub <noreply@github.com>2020-05-18 22:26:48 +0300
commit00b5f23f454d1cc64d6ca04224925797ebc7d1e7 (patch)
treeb2a3cf8c66fc00bc77a34755e25ac54d44097455 /arm9/lib/include/OS_thread.h
parent4c3e5d526588c546d20cd82613ea57396bebb64b (diff)
parentd8dcd1fef93929fc8905ee62c2bf627cb8e8db25 (diff)
Merge pull request #95 from red031000/master
fill out _OSThread
Diffstat (limited to 'arm9/lib/include/OS_thread.h')
-rw-r--r--arm9/lib/include/OS_thread.h63
1 files changed, 61 insertions, 2 deletions
diff --git a/arm9/lib/include/OS_thread.h b/arm9/lib/include/OS_thread.h
index 15cec0c9..adcadf2e 100644
--- a/arm9/lib/include/OS_thread.h
+++ b/arm9/lib/include/OS_thread.h
@@ -5,15 +5,42 @@
#ifndef POKEDIAMOND_OS_THREAD_H
#define POKEDIAMOND_OS_THREAD_H
+#include "types.h"
+#include "OS_context.h"
+
+typedef struct OSiAlarm OSAlarm;
+
typedef struct _OSThread OSThread;
+typedef struct _OSThreadQueue OSThreadQueue;
+typedef struct _OSThreadLink OSThreadLink;
+typedef struct _OSMutexQueue OSMutexQueue;
+typedef struct _OSMutexLink OSMutexLink;
+typedef struct OSMutex OSMutex;
+
struct _OSThreadQueue
{
OSThread *head;
OSThread *tail;
};
-typedef struct _OSThreadQueue OSThreadQueue;
+struct _OSThreadLink
+{
+ OSThread *prev;
+ OSThread *next;
+};
+
+struct _OSMutexQueue
+{
+ OSMutex *head;
+ OSMutex *tail;
+};
+
+struct _OSMutexLink
+{
+ OSMutex *next;
+ OSMutex *prev;
+};
typedef struct OSThreadInfo {
u16 isNeedRescheduling;
@@ -23,9 +50,41 @@ typedef struct OSThreadInfo {
void* switchCallback; // type: OSSwitchThreadCallback
} OSThreadInfo;
+typedef enum {
+ OS_THREAD_STATE_WAITING = 0,
+ OS_THREAD_STATE_READY = 1,
+ OS_THREAD_STATE_TERMINATED = 2
+} OSThreadState;
+
+typedef void (*OSThreadDestructor) (void *);
+
struct _OSThread
{
- u8 padding[0x80]; //todo: not the correct size but idfk
+ OSContext context;
+ OSThreadState state;
+ OSThread *next;
+ u32 id;
+ u32 priority;
+ void *profiler;
+
+ OSThreadQueue *queue;
+ OSThreadLink link;
+
+ OSMutex *mutex;
+ OSMutexQueue mutexQueue;
+
+ u32 stackTop;
+ u32 stackBottom;
+ u32 stackWarningOffset;
+
+ OSThreadQueue joinQueue;
+
+ void *specific[3];
+ OSAlarm *alarmForSleep;
+ OSThreadDestructor destructor;
+ void *userParameter;
+
+ u32 systemErrno;
};
void OS_SleepThread(OSThreadQueue * queue);