| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | #ifndef SCHED_H |
|---|
| 20 | #define SCHED_H |
|---|
| 21 | |
|---|
| 22 | #include <i386/pit.h> |
|---|
| 23 | #include <llist.h> |
|---|
| 24 | #include <typedefs.h> |
|---|
| 25 | #include <string.h> |
|---|
| 26 | |
|---|
| 27 | extern int tasking; |
|---|
| 28 | extern volatile int thrNeedSchedule; |
|---|
| 29 | |
|---|
| 30 | struct Process; |
|---|
| 31 | struct Thread; |
|---|
| 32 | |
|---|
| 33 | extern struct Process* current; |
|---|
| 34 | extern struct Thread* currThread,*prevThread; |
|---|
| 35 | extern struct Thread* lastMathThread; |
|---|
| 36 | |
|---|
| 37 | int ThrInit(); |
|---|
| 38 | void ThrSchedule(); |
|---|
| 39 | struct Process* ThrCreateProcess(char* name); |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | #define ThrCreateKernelThread(address) (ThrCreateThread(NULL,(DWORD)(address),false,0, NULL)) |
|---|
| 43 | |
|---|
| 44 | struct Thread* ThrCreateThread(struct Process* parent,DWORD entry,int user,DWORD stackP, void* argument); |
|---|
| 45 | void ThrStartThread(struct Thread* thread); |
|---|
| 46 | void ThrProcessExit(int returnCode); |
|---|
| 47 | void ThrSetPriority(struct Thread* thread,int priority); |
|---|
| 48 | void ThrSuspendThread(struct Thread* thread); |
|---|
| 49 | void ThrResumeThread(struct Thread* thread); |
|---|
| 50 | char* ThrGetProcName(int pid); |
|---|
| 51 | void ThrFreeThread(struct Thread* thread); |
|---|
| 52 | void ThrFreeProcess(struct Process* process); |
|---|
| 53 | void ThrIdleFunc(); |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | #define ThrGetThread(thread) ((thread)->refs++) |
|---|
| 57 | #define ThrReleaseThread(thread) \ |
|---|
| 58 | do { (thread)->refs--; if ((thread)->refs <= 0) ThrFreeThread((thread)); } while(0) |
|---|
| 59 | |
|---|
| 60 | #define ThrGetProcess(process) ((process)->refs++) |
|---|
| 61 | #define ThrReleaseProcess(process) \ |
|---|
| 62 | do { (process)->refs--; if ((process)->refs <= 0) ThrFreeProcess((process)); } while(0) |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | #define PRIORITY_NONE 0 |
|---|
| 73 | #define PRIORITY_DEFAULT 16 |
|---|
| 74 | #define PRIORITY_TOP 32 |
|---|
| 75 | |
|---|
| 76 | #endif |
|---|