47 static void __threadDestroy(
struct object *
obj);
48 static void __threadShutdown(
struct object *
obj, uint32_t
mode);
49 static int32_t __threadGetStatus(
struct object *
obj,
UNUSED uint32_t
mode);
50 static struct linkedList *__threadWait(
struct object *obj,
UNUSED uint32_t
mode, uint32_t *result);
51 static void __threadSignal(
struct object *obj, uint32_t result);
91 __objectInit(&t->
obj, &threadFunctions);
111 memset(task, 0,
sizeof(*task));
120 task->
eip = (uint32_t)eip;
138 task->
iomap =
sizeof(*task);
161 if (lastFPUthread == original)
163 asm volatile(
"clts");
164 asm volatile(
"fnsave %0; fwait" :
"=m" (lastFPUthread->
fpu));
183 static void __threadDestroy(
struct object *obj)
186 if (t == lastFPUthread) lastFPUthread = NULL;
209 static void __threadShutdown(
struct object *obj, uint32_t
exitcode)
213 if (t == lastFPUthread) lastFPUthread = NULL;
258 static int32_t __threadGetStatus(
struct object *obj,
UNUSED uint32_t
mode)
275 static struct linkedList *__threadWait(
struct object *obj,
UNUSED uint32_t
mode, uint32_t *result)
295 static void __threadSignal(
struct object *obj, uint32_t result)
314 struct thread *next_t = NULL;
364 while (!ll_empty(&threadList))
394 queue = __objectWait(obj, mode, &t->
task.
eax);
struct thread * threadCreate(struct process *p, struct thread *original, void *eip)
Creates a new kernel thread object.
#define USERMODE_KERNELSTACK_LIMIT
const struct objectFunctions * functions
void * heapAlloc(uint32_t length)
Allocates a block of kernel memory.
void * memset(void *ptr, int value, size_t num)
Fills a memory region with some specific byte value.
#define objectShutdown(p, a)
struct linkedList threadList
void heapFree(void *addr)
Deallocates a block of kernel memory.
struct pagingEntry * pageDirectory
void * pagingAllocatePhysMem(struct process *p, uint32_t length, bool rw, bool user)
Allocates several pages of physical memory in a process.
void threadSchedule()
Schedules threads until all process have been terminated.
#define DEFAULT_STACK_SIZE
void * user_ring3StackBase
struct thread * lastFPUthread
#define LL_INIT(list)
Initializes a linkedList.
#define LL_ENTRY(element, type, field)
struct GDTEntry * codeRing3
void * user_threadLocalBase
struct GDTEntry * dataRing0
uint32_t user_threadLocalLength
#define INTERRUPT_EXIT_PROCESS
void pagingReleasePhysMem(struct process *p, void *addr, uint32_t length)
Releases several pages of physical memory in a process.
struct linkedList threads
#define objectContainer(p, type, functions)
uint32_t gdtGetEntryOffset(struct GDTEntry *entry, uint32_t ring)
Determines the offset of a GDT entry.
uint32_t tssRunUsermodeThread(struct thread *t)
Run a thread.
struct linkedList waiters
struct GDTEntry * dataRing3
struct linkedList entry_process
uint32_t pagingGetPhysMem(struct process *p, void *addr)
Returns the physical page index for a virtual address.
#define INTERRUPT_CONTINUE_EXECUTION
struct linkedList processList
#define INTERRUPT_EXIT_THREAD
uint32_t threadWait(struct thread *t, struct object *obj, uint32_t mode)
Makes a kernel thread object wait for some waitable object.
uint32_t user_ring3StackLength