X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/e5568f75972dfc723778653c11cb6b4dc825716a..8ad349bb6ed4a0be06e34c92be0d98b92e078db4:/osfmk/kern/task.h?ds=sidebyside diff --git a/osfmk/kern/task.h b/osfmk/kern/task.h index 3e4c87b3c..d04fb8b9f 100644 --- a/osfmk/kern/task.h +++ b/osfmk/kern/task.h @@ -1,23 +1,31 @@ /* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ + * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the + * License may not be used to create, or enable the creation or + * redistribution of, unlawful or unlicensed copies of an Apple operating + * system, or to circumvent, violate, or enable the circumvention or + * violation of, any terms of an Apple operating system software license + * agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ */ /* * @OSF_FREE_COPYRIGHT@ @@ -80,9 +88,7 @@ #include #include -#include - -#ifdef __APPLE_API_PRIVATE +#include #ifdef MACH_KERNEL_PRIVATE @@ -93,19 +99,17 @@ #include #include #include -#include -#include + +#include #include #include #include -#include -#include +#include + #include -#include -#include -#include +#include -typedef struct task { +struct task { /* Synchronization/destruction information */ decl_mutex_data(,lock) /* Task's lock */ int ref_count; /* Number of references to me */ @@ -117,22 +121,9 @@ typedef struct task { void *user_data; /* Arbitrary data settable via IPC */ int suspend_count; /* Internal scheduling only */ -#if TASK_SWAPPER - /* Task swapper data */ - unsigned short swap_state; /* swap state (e.g. IN/OUT) */ - unsigned short swap_flags; /* swap flags (e.g. MAKE_UNSWAPP) */ - unsigned int swap_stamp; /* when last swapped */ - unsigned long swap_rss; /* size (pages) when last swapped */ - int swap_ast_waiting; /* number of threads that have not */ - /* reached a clean point and halted */ - int swap_nswap; /* number of times this task swapped */ - queue_chain_t swapped_tasks; /* list of non-resident tasks */ -#endif /* TASK_SWAPPER */ - /* Threads in this task */ queue_head_t threads; int thread_count; - int res_thread_count; int active_thread_count; processor_set_t processor_set; /* processor set for new threads */ @@ -154,8 +145,8 @@ typedef struct task { audit_token_t audit_token; /* Statistics */ - time_value_t total_user_time; /* user time for dead threads */ - time_value_t total_system_time; /* system time for dead threads */ + uint64_t total_user_time; /* terminated threads only */ + uint64_t total_system_time; #if MACH_PROF boolean_t task_profiled; /* is task being profiled ? */ @@ -181,22 +172,12 @@ typedef struct task { int semaphores_owned; /* number of semaphores owned */ int lock_sets_owned; /* number of lock sets owned */ - /* User space system call emulation support */ - struct eml_dispatch *eml_dispatch; - - /* Ledgers */ + /* Ledgers */ struct ipc_port *wired_ledger_port; struct ipc_port *paged_ledger_port; - unsigned long priv_flags; /* privelege resource flags */ + unsigned int priv_flags; /* privilege resource flags */ +#define VM_BACKING_STORE_PRIV 0x1 -#if NORMA_TASK - long child_node; /* if != -1, node for new children */ -#endif /* NORMA_TASK */ -#if FAST_TAS - vm_offset_t fast_tas_base; - vm_offset_t fast_tas_end; -#endif /* FAST_TAS */ - MACHINE_TASK integer_t faults; /* faults counter */ integer_t pageins; /* pageins counter */ integer_t cow_faults; /* copy on write fault counter */ @@ -208,93 +189,129 @@ typedef struct task { #ifdef MACH_BSD void *bsd_info; #endif - vm_offset_t system_shared_region; - vm_offset_t dynamic_working_set; + struct shared_region_mapping *system_shared_region; + struct tws_hash *dynamic_working_set; uint32_t taskFeatures[2]; /* Special feature for this task */ #define tf64BitAddr 0x80000000 /* Task has 64-bit addressing */ #define tf64BitData 0x40000000 /* Task has 64-bit data registers */ -} Task; +#define task_has_64BitAddr(task) \ + (((task)->taskFeatures[0] & tf64BitAddr) != 0) +#define task_set_64BitAddr(task) \ + ((task)->taskFeatures[0] |= tf64BitAddr) +#define task_clear_64BitAddr(task) \ + ((task)->taskFeatures[0] &= ~tf64BitAddr) + +}; #define task_lock(task) mutex_lock(&(task)->lock) #define task_lock_try(task) mutex_try(&(task)->lock) #define task_unlock(task) mutex_unlock(&(task)->lock) -#define itk_lock_init(task) mutex_init(&(task)->itk_lock_data, \ - ETAP_THREAD_TASK_ITK) +#define itk_lock_init(task) mutex_init(&(task)->itk_lock_data, 0) #define itk_lock(task) mutex_lock(&(task)->itk_lock_data) #define itk_unlock(task) mutex_unlock(&(task)->itk_lock_data) -#define task_reference_locked(task) ((task)->ref_count++) +#define task_reference_internal(task) \ + hw_atomic_add(&(task)->ref_count, 1) -/* - * priv_flags definitions - */ -#define VM_BACKING_STORE_PRIV 0x1 +#define task_deallocate_internal(task) \ + hw_atomic_sub(&(task)->ref_count, 1) -/* - * Internal only routines - */ +#define task_reference(task) \ +MACRO_BEGIN \ + if ((task) != TASK_NULL) \ + task_reference_internal(task); \ +MACRO_END -extern void task_backing_store_privileged( - task_t task); +extern kern_return_t kernel_task_create( + task_t task, + vm_offset_t map_base, + vm_size_t map_size, + task_t *child); /* Initialize task module */ extern void task_init(void); -/* task create */ -extern kern_return_t task_create_internal( - task_t parent_task, - boolean_t inherit_memory, - task_t *child_task); /* OUT */ +#define current_task_fast() (current_thread()->task) +#define current_task() current_task_fast() -extern void consider_task_collect(void); +#else /* MACH_KERNEL_PRIVATE */ -#define current_task_fast() (current_act_fast()->task) -#define current_task() current_task_fast() +__BEGIN_DECLS + +extern task_t current_task(void); + +extern void task_reference(task_t task); + +__END_DECLS #endif /* MACH_KERNEL_PRIVATE */ -extern task_t kernel_task; +__BEGIN_DECLS -/* Temporarily hold all threads in a task */ +#ifdef XNU_KERNEL_PRIVATE + +/* Hold all threads in a task */ extern kern_return_t task_hold( - task_t task); + task_t task); -/* Release temporary hold on all threads in a task */ +/* Release hold on all threads in a task */ extern kern_return_t task_release( - task_t task); + task_t task); -/* Get a task prepared for major changes */ +/* Halt all other threads in the current task */ extern kern_return_t task_halt( - task_t task); + task_t task); + +extern kern_return_t task_terminate_internal( + task_t task); + +extern kern_return_t task_create_internal( + task_t parent_task, + boolean_t inherit_memory, + task_t *child_task); /* OUT */ -#if defined(MACH_KERNEL_PRIVATE) || defined(BSD_BUILD) extern kern_return_t task_importance( task_t task, integer_t importance); -#endif + +extern void task_set_64bit( + task_t task, + boolean_t is64bit); + +extern void task_backing_store_privileged( + task_t task); + +extern void task_working_set_disable( + task_t task); + +/* Get number of activations in a task */ +extern int get_task_numacts( + task_t task); + /* JMM - should just be temporary (implementation in bsd_kern still) */ -extern void *get_bsdtask_info(task_t); extern void set_bsdtask_info(task_t,void *); -extern vm_map_t get_task_map(task_t); +extern vm_map_t get_task_map_reference(task_t); extern vm_map_t swap_task_map(task_t, vm_map_t); extern pmap_t get_task_pmap(task_t); -extern boolean_t task_reference_try(task_t task); +extern boolean_t is_kerneltask(task_t task); -#endif /* __APPLE_API_PRIVATE */ +#endif /* XNU_KERNEL_PRIVATE */ -#if !defined(MACH_KERNEL_PRIVATE) +#ifdef KERNEL_PRIVATE -extern task_t current_task(void); +extern void *get_bsdtask_info(task_t); +extern vm_map_t get_task_map(task_t); -#endif /* MACH_KERNEL_TASK */ +#endif /* KERNEL_PRIVATE */ -/* Take reference on task (make sure it doesn't go away) */ -extern void task_reference(task_t task); +extern task_t kernel_task; + +extern void task_deallocate( + task_t task); -/* Remove reference to task */ -extern void task_deallocate(task_t task); +__END_DECLS #endif /* _KERN_TASK_H_ */