Previous: Memory Object Attributes, Up: External Memory Management


6.7 Default Memory Manager

— Function: kern_return_t vm_set_default_memory_manager (host_t host, mach_port_t *default_manager)

The function vm_set_default_memory_manager sets the kernel's default memory manager. It sets the port to which newly-created temporary memory objects are delivered by memory_object_create to the host. The old memory manager port is returned. If default_manager is MACH_PORT_NULL then this routine just returns the current default manager port without changing it.

The argument host is a task port to the kernel whose default memory manager is to be changed. default_manager is an in/out parameter. As input, default_manager is the port that the new memory manager is listening on for memory_object_create calls. As output, it is the old default memory manager's port.

The function returns KERN_SUCCESS if the new memory manager is installed, and KERN_INVALID_ARGUMENT if this task does not have the privileges required for this call.

— Function: kern_return_t memory_object_create (memory_object_t old_memory_object, memory_object_t new_memory_object, vm_size_t new_object_size, memory_object_control_t new_control, memory_object_name_t new_name, vm_size_t new_page_size)
— Function: kern_return_t seqnos_memory_object_create (memory_object_t old_memory_object, mach_port_seqno_t seqno, memory_object_t new_memory_object, vm_size_t new_object_size, memory_object_control_t new_control, memory_object_name_t new_name, vm_size_t new_page_size)

The function memory_object_create is a request that the given memory manager accept responsibility for the given memory object created by the kernel. This call will only be made to the system default memory manager. The memory object in question initially consists of zero-filled memory; only memory pages that are actually written will ever be provided to memory_object_data_request calls, the default memory manager must use memory_object_data_unavailable for any pages that have not previously been written.

No reply is expected after this call. Since this call is directed to the default memory manager, the kernel assumes that it will be ready to handle data requests to this object and does not need the confirmation of a memory_object_set_attributes call.

The argument old_memory_object is a memory object provided by the default memory manager on which the kernel can make memory_object_create calls. new_memory_object is a new memory object created by the kernel; see synopsis for further description. Note that all port rights (including receive rights) are included for the new memory object. new_object_size is the maximum size of the new object. new_control is a port, created by the kernel, on which a memory manager may issue cache management requests for the new object. new_name a port used by the kernel to refer to the new memory object data in response to vm_region calls. new_page_size is the page size to be used by this kernel. All data sizes in calls involving this kernel must be an integral multiple of the page size. Note that different kernels, indicated by different a memory_control, may have different page sizes.

The function should return KERN_SUCCESS, but since this routine is called by the kernel, which does not wait for a reply message, this value is ignored.

— Function: kern_return_t memory_object_data_initialize (memory_object_t memory_object, memory_object_control_t memory_control, vm_offset_t offset, vm_offset_t data, vm_size_t data_count)
— Function: kern_return_t seqnos_memory_object_data_initialize (memory_object_t memory_object, mach_port_seqno_t seqno, memory_object_control_t memory_control, vm_offset_t offset, vm_offset_t data, vm_size_t data_count)

The function memory_object_data_initialize provides the memory manager with initial data for a kernel-created memory object. If the memory manager already has been supplied data (by a previous memory_object_data_initialize, memory_object_data_write or memory_object_data_return), then this data should be ignored. Otherwise, this call behaves exactly as does memory_object_data_return on memory objects created by the kernel via memory_object_create and thus will only be made to default memory managers. This call will not be made on objects created via memory_object_copy.

The argument memory_object the port that represents the memory object data, as supplied by the kernel in a memory_object_create call. memory_control is the request port to which a response is requested. (In the event that a memory object has been supplied to more than one the kernel that has made the request.) offset is the offset within a memory object to which this call refers. This will be page aligned. data is the data which has been modified while cached in physical memory. data_count is the amount of data to be written, in bytes. This will be an integral number of memory object pages.

The function should return KERN_SUCCESS, but since this routine is called by the kernel, which does not wait for a reply message, this value is ignored.