- sright = (void *)pthread_kern->convert_thread_to_port(th);
- th_thport = pthread_kern->ipc_port_copyout_send(sright, pthread_kern->task_get_ipcspace(ctask));
+ if (pthread_kern->convert_thread_to_port_pinned) {
+ /* Convert to immovable/pinned thread port, but port is not pinned yet */
+ sright = (void *)pthread_kern->convert_thread_to_port_pinned(th);
+ } else {
+ sright = (void *)pthread_kern->convert_thread_to_port(th);
+ }
+
+ if (pthread_kern->ipc_port_copyout_send_pinned) {
+ /* Atomically, pin and copy out the port */
+ th_thport = pthread_kern->ipc_port_copyout_send_pinned(sright, pthread_kern->task_get_ipcspace(ctask));
+ } else {
+ th_thport = pthread_kern->ipc_port_copyout_send(sright, pthread_kern->task_get_ipcspace(ctask));
+ }
+