1/* 2 * Copyright 2004-2007, Haiku Inc. 3 * Distributed under the terms of the MIT License. 4 * 5 * Thread definition and structures 6 */ 7#ifndef _KERNEL_THREAD_TYPES_H 8#define _KERNEL_THREAD_TYPES_H 9 10#define _THREAD_H 11 12#include <OS.h> 13 14#if 0 15struct cpu_ent { 16 bool preempted; 17}; 18#endif 19extern struct thread_queue dead_q; 20 21struct thread { 22 struct thread *queue_next; /* i.e. run queue, release queue, etc. */ 23 char *name; 24 thread_id id; 25 int32 priority; 26 int32 next_priority; 27 int32 state; 28 int32 next_state; 29 struct cpu_ent *cpu; 30 struct Thread *object; 31 32 bool in_kernel; 33 bool is_idle; 34 bool was_yielded; 35 36 bigtime_t user_time; 37 bigtime_t kernel_time; 38 bigtime_t last_time; 39}; 40 41enum additional_thread_state { 42 THREAD_STATE_FREE_ON_RESCHED = 7, // free the thread structure upon reschedule 43// THREAD_STATE_BIRTH // thread is being created 44}; 45 46struct thread_queue { 47 struct thread *head; 48 struct thread *tail; 49}; 50 51 52static inline bool 53thread_is_idle_thread(struct thread *thread) 54{ 55 return thread->is_idle; 56} 57 58void thread_enqueue(struct thread *t, struct thread_queue *q); 59struct thread *thread_get_current_thread(void); 60 61#define GRAB_THREAD_LOCK grab_thread_lock 62#define RELEASE_THREAD_LOCK release_thread_lock 63void grab_thread_lock(void); 64void release_thread_lock(void); 65 66void arch_thread_context_switch(struct thread *t_from, struct thread *t_to); 67void arch_thread_set_current_thread(struct thread *t); 68 69#endif /* _KERNEL_THREAD_TYPES_H */ 70