xref: /xnu-8792.81.2/osfmk/man/MP_request_notification.html (revision 19c3b8c28c31cb8130e034cfb5df6bf9ba342d90)
1*19c3b8c2SApple OSS Distributions<h2>mach_port_request_notification</h2>
2*19c3b8c2SApple OSS Distributions<hr>
3*19c3b8c2SApple OSS Distributions<p>
4*19c3b8c2SApple OSS Distributions<strong>Function</strong> - Request notification of the specified port event type.
5*19c3b8c2SApple OSS Distributions<h3>SYNOPSIS</h3>
6*19c3b8c2SApple OSS Distributions<pre>
7*19c3b8c2SApple OSS Distributions<strong>kern_return_t   mach_port_request_notification</strong>
8*19c3b8c2SApple OSS Distributions                <strong>(ipc_space_t</strong>                               <var>task</var>,
9*19c3b8c2SApple OSS Distributions                 <strong>mach_port_name_t</strong>                          <var>name</var>,
10*19c3b8c2SApple OSS Distributions                 <strong>mach_msg_id_t</strong>                          <var>variant</var>,
11*19c3b8c2SApple OSS Distributions                 <strong>mach_port_mscount_t</strong>                       <var>sync</var>,
12*19c3b8c2SApple OSS Distributions                 <strong>mach_port_send_once_t</strong>                   <var>notify</var>,
13*19c3b8c2SApple OSS Distributions                 <strong>mach_msg_type_name_t</strong>               <var>notify_type</var>,
14*19c3b8c2SApple OSS Distributions                 <strong>mach_port_send_once_t</strong>                <var>*previous</var><strong>);</strong>
15*19c3b8c2SApple OSS Distributions</pre>
16*19c3b8c2SApple OSS Distributions<h3>PARAMETERS</h3>
17*19c3b8c2SApple OSS Distributions<dl>
18*19c3b8c2SApple OSS Distributions<p>
19*19c3b8c2SApple OSS Distributions<dt> <var>task</var>
20*19c3b8c2SApple OSS Distributions<dd>
21*19c3b8c2SApple OSS Distributions[in task send right]
22*19c3b8c2SApple OSS DistributionsThe task holding the specified right.
23*19c3b8c2SApple OSS Distributions<p>
24*19c3b8c2SApple OSS Distributions<dt> <var>name</var>
25*19c3b8c2SApple OSS Distributions<dd>
26*19c3b8c2SApple OSS Distributions[in scalar]
27*19c3b8c2SApple OSS DistributionsThe task's name for the right.
28*19c3b8c2SApple OSS Distributions<p>
29*19c3b8c2SApple OSS Distributions<dt> <var>variant</var>
30*19c3b8c2SApple OSS Distributions<dd>
31*19c3b8c2SApple OSS Distributions[in scalar]
32*19c3b8c2SApple OSS DistributionsThe type of notification.
33*19c3b8c2SApple OSS Distributions<p>
34*19c3b8c2SApple OSS Distributions<dt> <var>sync</var>
35*19c3b8c2SApple OSS Distributions<dd>
36*19c3b8c2SApple OSS Distributions[in scalar]
37*19c3b8c2SApple OSS DistributionsSome variants use this value to overcome race conditions.
38*19c3b8c2SApple OSS Distributions<p>
39*19c3b8c2SApple OSS Distributions<dt> <var>notify</var>
40*19c3b8c2SApple OSS Distributions<dd>
41*19c3b8c2SApple OSS Distributions[in notify send-once or receive (to be converted to send-once) right]
42*19c3b8c2SApple OSS DistributionsA
43*19c3b8c2SApple OSS Distributionssend-once right, to which the notification will be sent.
44*19c3b8c2SApple OSS Distributions<p>
45*19c3b8c2SApple OSS Distributions<dt> <var>notify_type</var>
46*19c3b8c2SApple OSS Distributions<dd>
47*19c3b8c2SApple OSS Distributions[in scalar]
48*19c3b8c2SApple OSS DistributionsIPC type of the <var>notify</var> right; either
49*19c3b8c2SApple OSS Distributions<strong>MACH_MSG_TYPE_MAKE_SEND_ONCE</strong> or <strong>MACH_MSG_TYPE_MOVE_SEND_ONCE</strong>.
50*19c3b8c2SApple OSS Distributions<p>
51*19c3b8c2SApple OSS Distributions<dt> <var>previous</var>
52*19c3b8c2SApple OSS Distributions<dd>
53*19c3b8c2SApple OSS Distributions[out notify send-once right]
54*19c3b8c2SApple OSS DistributionsThe previously registered send-once right.
55*19c3b8c2SApple OSS Distributions</dl>
56*19c3b8c2SApple OSS Distributions<h3>DESCRIPTION</h3>
57*19c3b8c2SApple OSS Distributions<p>
58*19c3b8c2SApple OSS DistributionsThe <strong>mach_port_request_notification</strong> function registers a request for a
59*19c3b8c2SApple OSS Distributionsnotification and supplies a send-once right that the notification
60*19c3b8c2SApple OSS Distributionswill use.  It is an atomic
61*19c3b8c2SApple OSS Distributionsswap, returning the previously registered send-once right (or
62*19c3b8c2SApple OSS Distributions<strong>MACH_PORT_NULL</strong> for none).  A notification request may be
63*19c3b8c2SApple OSS Distributionscancelled by providing <strong>MACH_PORT_NULL</strong>.
64*19c3b8c2SApple OSS Distributions<p>
65*19c3b8c2SApple OSS DistributionsThe <var>variant</var> argument takes the following values:
66*19c3b8c2SApple OSS Distributions<dl>
67*19c3b8c2SApple OSS Distributions<dt> <strong>MACH_NOTIFY_PORT_DESTROYED</strong>
68*19c3b8c2SApple OSS Distributions<dd>
69*19c3b8c2SApple OSS Distributions<var>sync</var> must be zero.  The <var>name</var> must specify a receive right,
70*19c3b8c2SApple OSS Distributionsand the call requests a port-destroyed notification for the receive
71*19c3b8c2SApple OSS Distributionsright.  If the receive right were to have been destroyed, for instance
72*19c3b8c2SApple OSS Distributionsby <strong>mach_port_destroy</strong>, then instead the receive right will be
73*19c3b8c2SApple OSS Distributionssent in a port-destroyed notification to the registered send-once right.
74*19c3b8c2SApple OSS Distributions<p>
75*19c3b8c2SApple OSS Distributions<dt> <strong>MACH_NOTIFY_DEAD_NAME</strong>
76*19c3b8c2SApple OSS Distributions<dd>
77*19c3b8c2SApple OSS DistributionsThe call requests a dead-name notification.  <var>name</var> specifies send,
78*19c3b8c2SApple OSS Distributionsreceive, or send-once rights for a port.  If the port is destroyed (and the
79*19c3b8c2SApple OSS Distributionsright remains, becoming a dead name), then a dead-name notification
80*19c3b8c2SApple OSS Distributionswhich carries the name of the right will be sent to the registered
81*19c3b8c2SApple OSS Distributionssend-once right.  If <var>sync</var> is non-zero,
82*19c3b8c2SApple OSS Distributionsthe <var>name</var> may specify a dead name, and
83*19c3b8c2SApple OSS Distributionsa dead-name notification is immediately generated.
84*19c3b8c2SApple OSS Distributions<p>
85*19c3b8c2SApple OSS DistributionsWhenever a dead-name notification is generated, the user reference
86*19c3b8c2SApple OSS Distributionscount of the dead name is incremented.  For example, a send right with
87*19c3b8c2SApple OSS Distributionstwo user refs has a registered dead-name request.  If the port is
88*19c3b8c2SApple OSS Distributionsdestroyed, the send right turns into a dead name with three user refs
89*19c3b8c2SApple OSS Distributions(instead of two), and a dead-name notification is generated.
90*19c3b8c2SApple OSS Distributions<p>
91*19c3b8c2SApple OSS DistributionsIf the name is made available for reuse, perhaps because of
92*19c3b8c2SApple OSS Distributions<strong>mach_port_destroy</strong> or <strong>mach_port_mod_refs</strong>,
93*19c3b8c2SApple OSS Distributionsor the name denotes a
94*19c3b8c2SApple OSS Distributionssend-once right which has a message sent to it, then the registered send-once
95*19c3b8c2SApple OSS Distributionsright is used to generate a port-deleted notification instead.
96*19c3b8c2SApple OSS Distributions<p>
97*19c3b8c2SApple OSS Distributions<dt> <strong>MACH_NOTIFY_NO_SENDERS</strong>
98*19c3b8c2SApple OSS Distributions<dd>
99*19c3b8c2SApple OSS DistributionsThe call requests a no-senders notification.  <var>name</var> must specify a
100*19c3b8c2SApple OSS Distributionsreceive right.  If the receive right's make-send count is greater than or
101*19c3b8c2SApple OSS Distributionsequal to the sync value, and it has no extant send rights, than an
102*19c3b8c2SApple OSS Distributionsimmediate no-senders notification is generated.  Otherwise the notification is
103*19c3b8c2SApple OSS Distributionsgenerated when the receive right next loses its last extant send right.  In
104*19c3b8c2SApple OSS Distributionseither case, any previously registered send-once right is returned.
105*19c3b8c2SApple OSS Distributions<p>
106*19c3b8c2SApple OSS DistributionsThe no-senders notification carries the value the port's make-send
107*19c3b8c2SApple OSS Distributionscount had when it was generated.  The make-send count is incremented
108*19c3b8c2SApple OSS Distributionswhenever a send right is made directly from a receive right.  The
109*19c3b8c2SApple OSS Distributionsmake-send count is reset to zero when the receive right is carried in a
110*19c3b8c2SApple OSS Distributionsmessage.
111*19c3b8c2SApple OSS Distributions<p>
112*19c3b8c2SApple OSS DistributionsWhen moving a receive right, no-senders notifications are canceled,
113*19c3b8c2SApple OSS Distributionswith a send-once notification sent to indicate the cancelation.
114*19c3b8c2SApple OSS Distributions</dl>
115*19c3b8c2SApple OSS Distributions<h3>NOTES</h3>
116*19c3b8c2SApple OSS Distributions<p>
117*19c3b8c2SApple OSS DistributionsThis interface is machine word length specific because of the port name
118*19c3b8c2SApple OSS Distributionsparameter.
119*19c3b8c2SApple OSS Distributions<h3>RETURN VALUES</h3>
120*19c3b8c2SApple OSS Distributions<dl>
121*19c3b8c2SApple OSS Distributions<p>
122*19c3b8c2SApple OSS Distributions<dt> <strong>KERN_INVALID_NAME</strong>
123*19c3b8c2SApple OSS Distributions<dd>
124*19c3b8c2SApple OSS Distributions<var>name</var> did not denote a right.
125*19c3b8c2SApple OSS Distributions<p>
126*19c3b8c2SApple OSS Distributions<dt> <strong>KERN_INVALID_RIGHT</strong>
127*19c3b8c2SApple OSS Distributions<dd>
128*19c3b8c2SApple OSS Distributions<var>name</var> denoted an invalid right.
129*19c3b8c2SApple OSS Distributions<p>
130*19c3b8c2SApple OSS Distributions<dt> <strong>KERN_INVALID_CAPABILITY</strong>
131*19c3b8c2SApple OSS Distributions<dd>
132*19c3b8c2SApple OSS Distributions<var>notify</var> was invalid.
133*19c3b8c2SApple OSS Distributions</dl>
134*19c3b8c2SApple OSS Distributions<p>
135*19c3b8c2SApple OSS DistributionsWhen using <strong>MACH_NOTIFY_DEAD_NAME</strong>:
136*19c3b8c2SApple OSS Distributions<dl>
137*19c3b8c2SApple OSS Distributions<p>
138*19c3b8c2SApple OSS Distributions<dt> <strong>KERN_UREFS_OVERFLOW</strong>
139*19c3b8c2SApple OSS Distributions<dd>
140*19c3b8c2SApple OSS Distributions<var>name</var> denotes a dead name, but generating an immediate dead-name
141*19c3b8c2SApple OSS Distributionsnotification would overflow the name's user-reference count.
142*19c3b8c2SApple OSS Distributions</dl>
143*19c3b8c2SApple OSS Distributions<h3>RELATED INFORMATION</h3>
144*19c3b8c2SApple OSS Distributions<p>
145*19c3b8c2SApple OSS DistributionsFunctions:
146*19c3b8c2SApple OSS Distributions<a href="mach_msg.html"><strong>mach_msg</strong></a>,
147*19c3b8c2SApple OSS Distributions<a href="mach_port_get_attributes.html"><strong>mach_port_get_attributes</strong></a>.
148