data structure(Struct address_space), which is implemented by calling MMAP () systematically, so it is highly efficient to establish memory ing.
Figure 1. Memory ing principle
Since the memory ing is not actually copied, how can the process directly access the files on the hard disk through memory operations? It depends on several related processes after memory ing.
MMAP () willReturns a pointer PTR
Inter-process communication-shared memoryWe are familiar with inter-process communication methods, such as pipelines (named pipelines), signals (signal), shared memory, message queues, sockets (sockets ), semaphores are classified as inter-process synchronization mechanisms.Next we will talk about the communication mode of shared memory. It is the fastest in IPC. Once the memory zone is mapped to the address space of the process that shares it, data transmission between these processes does not
, respectively: Zone_dma,zone_normal and Zone_highmem. The memory allocations for these three zones are as follows:
ZONE_DMA
16MB space for memory start
Zone_normal
16mb-896mb
Zone_highmem
896mb-End (1G)
The understanding of high memory
The last section says that high-end memory is used to solve problems where the kernel cannot access more than 1G of memory address space. So how exactly is it achieved. In general, it is very simple
file state changed *Long st_blksize;/* best I/O block length * *512-byte block number allocated by long st_blocks;/*};
6. File space mapping Mmap () function
void *mmap (void *start,size_t length,int prot,int flags,int fd,off_t);
There are three main uses for this function:1, mapping a common file into memory, usually in need of files frequently read and write to use, so that memory read and write instead
system decision, the logical address is divided into a good and the page address two parts, is implemented by the machine hardware. The length of the segment is not fixed and is determined by the user-written program, usually by the compilation system when the source program is compiled according to the nature of the information to be divided.*) page system address space is one-dimensional, that is, a single linear address space. A programmer can represent an address simply by using an identifi
After the foreshadowing of the previous article seems to be very easy to use the assembly to write mmap code, you can look carefully, or there are a number of problems need to be resolved:1. System call Mmap If an error does not directly return map_failed (-1), but rather a "similar" value, the C library's mmap function wraps it so that it eventually returns-1; i
Part I: The MMAP system call directly maps the device memory to the address space of the user process.Part II: Direct access to memory pages of user space across borders. Some related drivers require this capability (how user-space memory maps to the kernel method get_user_pages)Part III: Direct Memory access (DMA) I/O operations enable peripherals to have direct access to the system's memory capacity.Memory Management for LinuxAddress TypeLinux is a
Label:Most of the content of this article is not original, reproduced will be affixed with links. Prepare to learn the database, to the current mainstream database to do a simple understanding of the analysis, the collection of data collated to a piece. The current mainstream is to count NoSQL databases, with powerful high concurrency capabilities. Mongodb: It's an in-memory database, and the data is in memory. The operation of the data is mostly in memory, but MongoDB is not a pure memory datab
including the following areas: 1. the code segment of the current execution file, which is called the text segment. 2. the data segment of the execution file, which mainly stores global variables and static variables used by the execution file. 3. a heap that stores global variables and dynamically generated data. 4. stack for saving local variables and implementing function calls. 5. The mmap method is used to map the memory segments in the virtual
host machine is transplanted to the target platform. This article describes how to write a collection program on the host machine that installs the Linux operating system.(1) data structure defined in the programStruct voide_capability grab_cap;Struct voide_picture grab_pic;Struct voide_mmap grab_buf;Struct voide_mbuf grab_vm;These data structures are supported by video4linux and their usage is as follows:* Video_capability includes the basic information of the camera, such as the device name,
Ramcloud source code analysis (III) 1. Overview This section mainly analyzes the servers in the ramcloud system. This section focuses on memory management and corresponds to the log-structured memory for dram-based storage article on fast '14. First, log-based memory management is copying allocators. The main purpose is to meet the following requirements: first, fragments can be eliminated through copy object; second, garbage collection can be implemented without global scanning. The first req
allocation.
Principle of Memory AllocationFrom the operating system perspective, there are two ways to allocate memory for processes: BRK and MMAP ). BRK refers (. data) the highest address pointer _ edata is pushed to the high address. MMAP finds an idle address in the virtual address space of the process (usually in the middle of the heap and stack. Both methods are allocated with virtual memory instead
. However, after calling Shm_unlink () (usually called by the process that originally created the shared memory segment), the memory segment cannot be accessed by other processes.Mmap (): Maps the shared memory segment to the memory of the process. This system call requires the file descriptor returned by Shm_open (), which returns a pointer to memory. (In some cases, you can also map the file descriptor of a generic file or another device to memory.) The implementation of
, an empty loop, when the file was executed, in bash, the Echo >> executable, the result expected, the return failed, and prompted the message text file busy.Does the mechanism also apply to the mapping mechanism, and when executing the executable, some associated dynamic-link libraries are mmap, and are these dynamic link libraries not allowed to be written after being mmap and not allowed to
classic layout: the. Text segment is first loaded, then the. Data section, and finally the. BSS segment. The top 128TB is used by the kernel and cannot be accessed directly by the application. The stack of applications begins to grow downward from a high address.
The space between the BSS segment and the stack is free, the free space is divided into two parts, one is heap, and the other is the mmap mapping area. The
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.