00001 /****************************************************** 00002 The interface to the operating system 00003 process control primitives 00004 00005 (c) 1995 Innobase Oy 00006 00007 Created 9/30/1995 Heikki Tuuri 00008 *******************************************************/ 00009 00010 #ifndef os0proc_h 00011 #define os0proc_h 00012 00013 #include "univ.i" 00014 00015 #ifdef UNIV_LINUX 00016 #include <sys/ipc.h> 00017 #include <sys/shm.h> 00018 #endif 00019 00020 typedef void* os_process_t; 00021 typedef unsigned long int os_process_id_t; 00022 00023 /* The cell type in os_awe_allocate_mem page info */ 00024 #if defined(__WIN2000__) && defined(ULONG_PTR) 00025 typedef ULONG_PTR os_awe_t; 00026 #else 00027 typedef ulint os_awe_t; 00028 #endif 00029 00030 /* Physical page size when Windows AWE is used. This is the normal 00031 page size of an Intel x86 processor. We cannot use AWE with 2 MB or 4 MB 00032 pages. */ 00033 #define OS_AWE_X86_PAGE_SIZE 4096 00034 00035 extern ibool os_use_large_pages; 00036 /* Large page size. This may be a boot-time option on some platforms */ 00037 extern ulint os_large_page_size; 00038 00039 /******************************************************************** 00040 Windows AWE support. Tries to enable the "lock pages in memory" privilege for 00041 the current process so that the current process can allocate memory-locked 00042 virtual address space to act as the window where AWE maps physical memory. */ 00043 00044 ibool 00045 os_awe_enable_lock_pages_in_mem(void); 00046 /*=================================*/ 00047 /* out: TRUE if success, FALSE if error; 00048 prints error info to stderr if no success */ 00049 /******************************************************************** 00050 Allocates physical RAM memory up to 64 GB in an Intel 32-bit x86 00051 processor. */ 00052 00053 ibool 00054 os_awe_allocate_physical_mem( 00055 /*=========================*/ 00056 /* out: TRUE if success */ 00057 os_awe_t** page_info, /* out, own: array of opaque data containing 00058 the info for allocated physical memory pages; 00059 each allocated 4 kB physical memory page has 00060 one slot of type os_awe_t in the array */ 00061 ulint n_megabytes); /* in: number of megabytes to allocate */ 00062 /******************************************************************** 00063 Allocates a window in the virtual address space where we can map then 00064 pages of physical memory. */ 00065 00066 byte* 00067 os_awe_allocate_virtual_mem_window( 00068 /*===============================*/ 00069 /* out, own: allocated memory, or NULL if did not 00070 succeed */ 00071 ulint size); /* in: virtual memory allocation size in bytes, must 00072 be < 2 GB */ 00073 /******************************************************************** 00074 With this function you can map parts of physical memory allocated with 00075 the ..._allocate_physical_mem to the virtual address space allocated with 00076 the previous function. Intel implements this so that the process page 00077 tables are updated accordingly. A test on a 1.5 GHz AMD processor and XP 00078 showed that this takes < 1 microsecond, much better than the estimated 80 us 00079 for copying a 16 kB page memory to memory. But, the operation will at least 00080 partially invalidate the translation lookaside buffer (TLB) of all 00081 processors. Under a real-world load the performance hit may be bigger. */ 00082 00083 ibool 00084 os_awe_map_physical_mem_to_window( 00085 /*==============================*/ 00086 /* out: TRUE if success; the function 00087 calls exit(1) in case of an error */ 00088 byte* ptr, /* in: a page-aligned pointer to 00089 somewhere in the virtual address 00090 space window; we map the physical mem 00091 pages here */ 00092 ulint n_mem_pages, /* in: number of 4 kB mem pages to 00093 map */ 00094 os_awe_t* page_info); /* in: array of page infos for those 00095 pages; each page has one slot in the 00096 array */ 00097 /******************************************************************** 00098 Converts the current process id to a number. It is not guaranteed that the 00099 number is unique. In Linux returns the 'process number' of the current 00100 thread. That number is the same as one sees in 'top', for example. In Linux 00101 the thread id is not the same as one sees in 'top'. */ 00102 00103 ulint 00104 os_proc_get_number(void); 00105 /*====================*/ 00106 /******************************************************************** 00107 Allocates non-cacheable memory. */ 00108 00109 void* 00110 os_mem_alloc_nocache( 00111 /*=================*/ 00112 /* out: allocated memory */ 00113 ulint n); /* in: number of bytes */ 00114 /******************************************************************** 00115 Allocates large pages memory. */ 00116 00117 void* 00118 os_mem_alloc_large( 00119 /*===============*/ 00120 /* out: allocated memory */ 00121 ulint n, /* in: number of bytes */ 00122 ibool set_to_zero, /* in: TRUE if allocated memory 00123 should be set to zero if 00124 UNIV_SET_MEM_TO_ZERO is defined */ 00125 ibool assert_on_error);/* in: if TRUE, we crash mysqld if 00126 the memory cannot be allocated */ 00127 /******************************************************************** 00128 Frees large pages memory. */ 00129 00130 void 00131 os_mem_free_large( 00132 /*==============*/ 00133 void *ptr); /* in: number of bytes */ 00134 /******************************************************************** 00135 Sets the priority boost for threads released from waiting within the current 00136 process. */ 00137 00138 void 00139 os_process_set_priority_boost( 00140 /*==========================*/ 00141 ibool do_boost); /* in: TRUE if priority boost should be done, 00142 FALSE if not */ 00143 00144 #ifndef UNIV_NONINL 00145 #include "os0proc.ic" 00146 #endif 00147 00148 #endif
1.4.7

