32-bit process’s address space on 64-bit linux
Citing the kernel source: “Kernel pointers have redundant information, so we can use a scheme where we can return either an error code or a [...] pointer with the same return value.”
The values -1..-4095 (mapping to 0xfffff000–0xffffffff in 32-bit mode) are reserved for kernel-level errno values. The other 4KB from 0xffffe000–0xffffefff are held free for the vsyscall vdso magic page, but since the vdso page is relocatable since many moons, this area remains potentially unpopulated, that is to say, the [stack]
entry in /proc/*/maps
ends at 0xffffdfff always regardless of whether [vdso] is mapped at 0xffffe000 or elsewhere.
How much memory can a 32 bit process access on a 64 bit operating system?
2 GB by default. If the application is large address space aware (linked with /LARGEADDRESSAWARE), it gets 4 GB (not 3 GB, see http://msdn.microsoft.com/en-us/library/aa366778.aspx)
They're still limited to 2 GB since many application depends on the top bit of pointers to be zero.
How to use more than 3 GB in a process on 32-bit PAE-enabled Linux app?
You don't, directly -- as long as you're running on 32-bit, each process will be subject to the VM split that the kernel was built with (2GB, 3GB, or if you have a patched kernel with the 4GB/4GB split, 4GB).
One of the simplest ways to have a process work with more data and still keep it in RAM is to create a shmfs
and then put your data in files on that fs, accessing them with the ordinary seek/read/write primitives, or mapping them into memory one at a time with mmap
(which is basically equivalent to doing your own paging). But whatever you do it's going to take more work than using the first 3GB.
4GB of memory for 32 bit application running on 64-bit Solaris (Very Large Memory)
There is no library I'm aware of but implementing it would be quite straightforward under Solaris (and all Unix/Unix like OSes supporting tmpfs and mmap).
Just create a file the size you want (eg: 16 GiB) in /tmp (assuming /tmp is on tmpfs, the default configuration) and have the process(es) mapping various areas of this file to access memory at the wanted offsets.
Should you really want to access physical memory and not virtual one, you can use Solaris ramdisk support (ramdiskadm) instead of tmpfs.
How to limit the address space of 32bit application on 64bit Linux to 3GB?
OK, I found the answer of this question elsewhere.
The solution is to change the "personality" of your program to PER_LINUX32_3GB, using the Linux system call sys_personality.
But there is a problem. After switching to PER_LINUX32_3GB Linux kernel will not allocate space in the upper 1GB, but the already allocated space, for example the application stack, remains there.
The solution is to "restart" your program through sys_execve system call.
Here is the code where I packed everything in one:
proc ___SwitchLinuxTo3GB
begin
cmp esp, $c0000000
jb .finish ; the system is native 32bit
; check the current personality.
mov eax, sys_personality
mov ebx, -1
int $80
; and exit if it is what intended
test eax, ADDR_LIMIT_3GB
jnz .finish ; everything is OK.
; set the needed personality
mov eax, sys_personality
mov ebx, PER_LINUX32_3GB
int $80
; and restart the process
mov eax, [esp+4] ; argument count
mov ebx, [esp+8] ; the filename of the executable.
lea ecx, [esp+8] ; the arguments list.
lea edx, [ecx+4*eax+4] ; the environment list.
mov eax, sys_execve
int $80
; if something gone wrong, it comes here and stops!
int3
.finish:
return
endp
Related Topics
Linux Equivalent of the MAC Os X "Open" Command
Repeat Command Automatically in Linux
How to Count Number of Files in Each Directory
How to Have the Cp Command Create Any Necessary Folders for Copying a File to a Destination
How to Append One File to Another in Linux from the Shell
Best Practice to Run Linux Service as a Different User
Interpreting Segfault Messages
How to Show a Gui Message Box from a Bash Script in Linux
Command to Change the Default Home Directory of a User
What Are Libtool's .La File For
How to Get 'Find' to Ignore .Svn Directories
How to Encrypt a Large File in Openssl Using Public Key
Setting Default Permissions for Newly Created Files and Sub-Directories Under a Directory in Linux
Rsync Copy Over Only Certain Types of Files Using Include Option
How to Make Mv Create the Directory to Be Moved to If It Doesn't Exist