Next: Port Destruction, Up: Port Manipulation Interface
The
mach_port_allocatefunction creates a new right in the specified task. The new right's name is returned in name, which may be any name that wasn't in use.The right argument takes the following values:
MACH_PORT_RIGHT_RECEIVEmach_port_allocatecreates a port. The new port is not a member of any port set. It doesn't have any extant send or send-once rights. Its make-send count is zero, its sequence number is zero, its queue limit isMACH_PORT_QLIMIT_DEFAULT, and it has no queued messages. name denotes the receive right for the new port.task does not hold send rights for the new port, only the receive right.
mach_port_insert_rightandmach_port_extract_rightcan be used to convert the receive right into a combined send/receive right.MACH_PORT_RIGHT_PORT_SETmach_port_allocatecreates a port set. The new port set has no members.MACH_PORT_RIGHT_DEAD_NAMEmach_port_allocatecreates a dead name. The new dead name has one user reference.The function returns
KERN_SUCCESSif the call succeeded,KERN_INVALID_TASKif task was invalid,KERN_INVALID_VALUEif right was invalid,KERN_NO_SPACEif there was no room in task's IPC name space for another right andKERN_RESOURCE_SHORTAGEif the kernel ran out of memory.The
mach_port_allocatecall is actually an RPC to task, normally a send right for a task port, but potentially any send right. In addition to the normal diagnostic return codes from the call's server (normally the kernel), the call may returnmach_msgreturn codes.
The
mach_reply_portsystem call creates a reply port in the calling task.
mach_reply_portcreates a port, giving the calling task the receive right for the port. The call returns the name of the new receive right.This is very much like creating a receive right with the
mach_port_allocatecall, with two differences. First,mach_reply_portis a system call and not an RPC (which requires a reply port). Second, the port created bymach_reply_portmay be optimized for use as a reply port.The function returns
MACH_PORT_NULLif a resource shortage prevented the creation of the receive right.
The function
mach_port_allocate_namecreates a new right in the specified task, with a specified name for the new right. name must not already be in use for some right, and it can't be the reserved valuesMACH_PORT_NULLandMACH_PORT_DEAD.The right argument takes the following values:
MACH_PORT_RIGHT_RECEIVEmach_port_allocate_namecreates a port. The new port is not a member of any port set. It doesn't have any extant send or send-once rights. Its make-send count is zero, its sequence number is zero, its queue limit isMACH_PORT_QLIMIT_DEFAULT, and it has no queued messages. name denotes the receive right for the new port.task does not hold send rights for the new port, only the receive right.
mach_port_insert_rightandmach_port_extract_rightcan be used to convert the receive right into a combined send/receive right.MACH_PORT_RIGHT_PORT_SETmach_port_allocate_namecreates a port set. The new port set has no members.MACH_PORT_RIGHT_DEAD_NAMEmach_port_allocate_namecreates a new dead name. The new dead name has one user reference.The function returns
KERN_SUCCESSif the call succeeded,KERN_INVALID_TASKif task was invalid,KERN_INVALID_VALUEif right was invalid or name wasMACH_PORT_NULLorMACH_PORT_DEAD,KERN_NAME_EXISTSif name was already in use for a port right andKERN_RESOURCE_SHORTAGEif the kernel ran out of memory.The
mach_port_allocate_namecall is actually an RPC to task, normally a send right for a task port, but potentially any send right. In addition to the normal diagnostic return codes from the call's server (normally the kernel), the call may returnmach_msgreturn codes.