1
/******************************************************
2
The interface to the operating system
3
process control primitives
7
Created 9/30/1995 Heikki Tuuri
8
*******************************************************/
20
typedef void* os_process_t;
21
typedef unsigned long int os_process_id_t;
23
/* The cell type in os_awe_allocate_mem page info */
24
#if defined(__WIN2000__) && defined(ULONG_PTR)
25
typedef ULONG_PTR os_awe_t;
27
typedef ulint os_awe_t;
30
/* Physical page size when Windows AWE is used. This is the normal
31
page size of an Intel x86 processor. We cannot use AWE with 2 MB or 4 MB
33
#define OS_AWE_X86_PAGE_SIZE 4096
35
extern ibool os_use_large_pages;
36
/* Large page size. This may be a boot-time option on some platforms */
37
extern ulint os_large_page_size;
39
/********************************************************************
40
Windows AWE support. Tries to enable the "lock pages in memory" privilege for
41
the current process so that the current process can allocate memory-locked
42
virtual address space to act as the window where AWE maps physical memory. */
45
os_awe_enable_lock_pages_in_mem(void);
46
/*=================================*/
47
/* out: TRUE if success, FALSE if error;
48
prints error info to stderr if no success */
49
/********************************************************************
50
Allocates physical RAM memory up to 64 GB in an Intel 32-bit x86
54
os_awe_allocate_physical_mem(
55
/*=========================*/
56
/* out: TRUE if success */
57
os_awe_t** page_info, /* out, own: array of opaque data containing
58
the info for allocated physical memory pages;
59
each allocated 4 kB physical memory page has
60
one slot of type os_awe_t in the array */
61
ulint n_megabytes); /* in: number of megabytes to allocate */
62
/********************************************************************
63
Allocates a window in the virtual address space where we can map then
64
pages of physical memory. */
67
os_awe_allocate_virtual_mem_window(
68
/*===============================*/
69
/* out, own: allocated memory, or NULL if did not
71
ulint size); /* in: virtual memory allocation size in bytes, must
73
/********************************************************************
74
With this function you can map parts of physical memory allocated with
75
the ..._allocate_physical_mem to the virtual address space allocated with
76
the previous function. Intel implements this so that the process page
77
tables are updated accordingly. A test on a 1.5 GHz AMD processor and XP
78
showed that this takes < 1 microsecond, much better than the estimated 80 us
79
for copying a 16 kB page memory to memory. But, the operation will at least
80
partially invalidate the translation lookaside buffer (TLB) of all
81
processors. Under a real-world load the performance hit may be bigger. */
84
os_awe_map_physical_mem_to_window(
85
/*==============================*/
86
/* out: TRUE if success; the function
87
calls exit(1) in case of an error */
88
byte* ptr, /* in: a page-aligned pointer to
89
somewhere in the virtual address
90
space window; we map the physical mem
92
ulint n_mem_pages, /* in: number of 4 kB mem pages to
94
os_awe_t* page_info); /* in: array of page infos for those
95
pages; each page has one slot in the
97
/********************************************************************
98
Converts the current process id to a number. It is not guaranteed that the
99
number is unique. In Linux returns the 'process number' of the current
100
thread. That number is the same as one sees in 'top', for example. In Linux
101
the thread id is not the same as one sees in 'top'. */
104
os_proc_get_number(void);
105
/*====================*/
106
/********************************************************************
107
Allocates non-cacheable memory. */
110
os_mem_alloc_nocache(
111
/*=================*/
112
/* out: allocated memory */
113
ulint n); /* in: number of bytes */
114
/********************************************************************
115
Allocates large pages memory. */
120
/* out: allocated memory */
121
ulint n, /* in: number of bytes */
122
ibool set_to_zero, /* in: TRUE if allocated memory
123
should be set to zero if
124
UNIV_SET_MEM_TO_ZERO is defined */
125
ibool assert_on_error);/* in: if TRUE, we crash mysqld if
126
the memory cannot be allocated */
127
/********************************************************************
128
Frees large pages memory. */
133
void *ptr); /* in: number of bytes */
134
/********************************************************************
135
Sets the priority boost for threads released from waiting within the current
139
os_process_set_priority_boost(
140
/*==========================*/
141
ibool do_boost); /* in: TRUE if priority boost should be done,
145
#include "os0proc.ic"