--- Gnu-Mach/kern/thread.h 2020/09/02 04:36:57 1.1 +++ Gnu-Mach/kern/thread.h 2020/09/02 04:54:10 1.1.1.6 @@ -34,12 +34,6 @@ #ifndef _KERN_THREAD_H_ #define _KERN_THREAD_H_ -#include -#include -#include -#include -#include - #include #include #include @@ -49,11 +43,11 @@ #include #include #include +#include #include #include #include #include /* event_t, continuation_t */ -#include #include #include #include @@ -76,6 +70,21 @@ struct thread { task_t task; /* Task to which I belong */ queue_chain_t thread_list; /* list of threads in task */ + /* Flags */ + /* The flags are grouped here, but documented at the original + position. */ + union { + struct { + unsigned state:16; + unsigned wake_active:1; + unsigned active:1; + }; + event_t event_key; +/* These keys can be used with thread_wakeup and friends. */ +#define TH_EV_WAKE_ACTIVE(t) ((event_t) (&(t)->event_key + 0)) +#define TH_EV_STATE(t) ((event_t) (&(t)->event_key + 1)) + }; + /* Thread bookkeeping */ queue_chain_t pset_threads; /* list of all threads in proc set*/ @@ -90,7 +99,7 @@ struct thread { vm_offset_t stack_privilege;/* reserved kernel stack */ /* Swapping information */ - void (*swap_func)(); /* start here after swapin */ + continuation_t swap_func; /* start here after swapin */ /* Blocking information */ event_t wait_event; /* event we are waiting on */ @@ -98,9 +107,10 @@ struct thread { kern_return_t wait_result; /* outcome of wait - may be examined by this thread WITHOUT locking */ - boolean_t wake_active; /* someone is waiting for this + /* Defined above */ + /* boolean_t wake_active; someone is waiting for this thread to become suspended */ - int state; /* Thread state: */ + /* int state; Thread state: */ /* * Thread states [bits or'ed] */ @@ -135,7 +145,8 @@ struct thread { /* VM global variables */ vm_offset_t recover; /* page fault recovery (copyin/out) */ - boolean_t vm_privilege; /* Can use reserved memory? */ + unsigned int vm_privilege; /* Can use reserved memory? + Implemented as a counter */ /* User-visible scheduling state */ int user_stop_count; /* outstanding stops */ @@ -160,9 +171,6 @@ struct thread { struct ipc_port *ith_self; /* not a right, doesn't hold ref */ struct ipc_port *ith_sself; /* a send right */ struct ipc_port *ith_exception; /* a send right */ -#if MACH_IPC_COMPAT - struct ipc_port *ith_reply; /* a send right */ -#endif /* MACH_IPC_COMPAT */ mach_port_t ith_mig_reply; /* reply port for mig */ struct ipc_port *ith_rpc_reply; /* reply port for kernel RPCs */ @@ -195,12 +203,16 @@ struct thread { unsigned int cpu_delta; /* cpu usage since last update */ unsigned int sched_delta; /* weighted cpu usage since update */ + /* Creation time stamp */ + time_value_t creation_time; + /* Time-outs */ timer_elt_data_t timer; /* timer for thread */ timer_elt_data_t depress_timer; /* timer for priority depression */ /* Ast/Halt data structures */ - boolean_t active; /* how alive is the thread */ + /* Defined above */ + /* boolean_t active; how alive is the thread */ int ast; /* ast's needed. See ast.h */ /* Processor data structures */ @@ -217,10 +229,6 @@ struct thread { #if NCPUS > 1 processor_t last_processor; /* processor this last ran on */ #endif /* NCPUS > 1 */ - -#if NET_ATM - nw_ep_owned_t nw_ep_waited; -#endif /* NET_ATM */ }; /* typedef of thread_t is in kern/kern_types.h */ @@ -269,12 +277,44 @@ extern kern_return_t thread_create( thread_t *child_thread); extern kern_return_t thread_terminate( thread_t thread); +extern kern_return_t thread_terminate_release( + thread_t thread, + task_t task, + mach_port_t thread_name, + mach_port_t reply_port, + vm_offset_t address, + vm_size_t size); extern kern_return_t thread_suspend( thread_t thread); extern kern_return_t thread_resume( thread_t thread); extern kern_return_t thread_abort( thread_t thread); +extern void thread_start( + thread_t thread, + continuation_t start); +extern thread_t kernel_thread( + task_t task, + continuation_t start, + void *arg); +extern kern_return_t thread_priority( + thread_t thread, + int priority, + boolean_t set_max); +extern void thread_set_own_priority( + int priority); +extern kern_return_t thread_max_priority( + thread_t thread, + processor_set_t pset, + int max_priority); +extern kern_return_t thread_policy( + thread_t thread, + int policy, + int data); +extern void consider_thread_collect( + void); +extern void stack_privilege( + thread_t thread); extern kern_return_t thread_get_state( thread_t thread, int flavor, @@ -303,6 +343,7 @@ extern kern_return_t thread_assign( processor_set_t new_pset); extern kern_return_t thread_assign_default( thread_t thread); +extern void stack_collect(void); #endif /* @@ -320,16 +361,14 @@ extern void thread_release(thread_t); extern kern_return_t thread_halt( thread_t thread, boolean_t must_halt); -extern void thread_halt_self(void); +extern void thread_halt_self(continuation_t); extern void thread_force_terminate(thread_t); -extern void thread_set_own_priority( - int priority); extern thread_t kernel_thread( task_t task, void (*start)(void), void * arg); -extern void reaper_thread(void); +extern void reaper_thread(void) __attribute__((noreturn)); #if MACH_HOST extern void thread_freeze( @@ -368,4 +407,9 @@ extern void thread_unfreeze( #define current_space() (current_task()->itk_space) #define current_map() (current_task()->map) +#if MACH_DEBUG +void stack_init(vm_offset_t stack); +void stack_finalize(vm_offset_t stack); +#endif /* MACH_DEBUG */ + #endif /* _KERN_THREAD_H_ */