bijan@yosemite.ucsb.edu (Bijan Forutanpour) (01/17/90)
I had a question for those who use vm_allocate and/or have read the "Mach Kernel Interface Manual". The manual specifies the call to vm_allocate as: #include <mach.h> kern_return_t vm_allocate(target_task, address, size, anywhere) vm_task_t target_task; ...etc ...etc... --------------------------------------------------------------------------- I needed to know how the function works so I dug up the source code from vm/vm_user.c. The CODE looks like: kern_return_t vm_allocate(map, address, size, anywhere) vm_map_t map; ...etc ...etc... There is no vm_map_t anywhere in the O.S.!! But task_t DOES include a field vm_map_t map; which I suppose must be extracted and passed to vm_allocate. Has anyone else noticed this apparent "inconsistency"? How do YOU call vm_allocate? Bijan bijan%cs@hub.ucsb.edu
Richard.Draves@CS.CMU.EDU (01/18/90)
The first argument to the vm_allocate() kernel call should be a task port. task_self() returns the calling task's task port. For example, vm_address_t addr; kern_return_t kr; kr = vm_allocate(task_self(), &addr, vm_page_size, TRUE); if (kr != KERN_SUCCESS) whatever; allocates one page of memory somewhere in the calling task's address space. The kernel call implementation translates the task port into a VM map structure before the vm_allocate() function inside the kernel is called. Rich