<!--
{
  "availability" : [
    "DriverKit: -"
  ],
  "documentType" : "symbol",
  "framework" : "SCSIControllerDriverKit",
  "identifier" : "/documentation/SCSIControllerDriverKit/IOUserSCSIParallelInterfaceController/UserCreateTargetForID",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SCSIControllerDriverKit"
    ],
    "preciseIdentifier" : "c:@S@IOUserSCSIParallelInterfaceController@F@UserCreateTargetForID#k#*$@S@OSDictionary#"
  },
  "title" : "UserCreateTargetForID"
}
-->

# UserCreateTargetForID

Creates the specified target.

```
virtual kern_return_t UserCreateTargetForID(SCSIDeviceIdentifier targetID, OSDictionary *targetDict);
```

## Parameters

`targetID`

The ID of the target to create.

`targetDict`

An <doc://com.apple.documentation/documentation/DriverKit/OSDictionary> containing all of the target properties.

## Return Value

A value that indicates the result of target creation. <doc://com.apple.documentation/documentation/DriverKit/kIOReturnSuccess> indicates success. For error definitions, see <doc://com.apple.documentation/documentation/iokit/iokit_constants>.

## Discussion

Your driver extension class calls this method to create a new target for the `targetID`. The framework creates the new target before the call returns.

As part of the [`UserCreateTargetForID`](/documentation/SCSIControllerDriverKit/IOUserSCSIParallelInterfaceController/UserCreateTargetForID) call, the kernel calls several APIs like [`UserInitializeTargetForID`](/documentation/SCSIControllerDriverKit/IOUserSCSIParallelInterfaceController/UserInitializeTargetForID) which run on the default dispatch queue of the dext. Synchronously calling [`UserCreateTargetForID`](/documentation/SCSIControllerDriverKit/IOUserSCSIParallelInterfaceController/UserCreateTargetForID) from the default dispatch queue blocks the default dispatch queue until [`UserCreateTargetForID`](/documentation/SCSIControllerDriverKit/IOUserSCSIParallelInterfaceController/UserCreateTargetForID) finishes. Subsequent calls from the kernel like [`UserInitializeTargetForID`](/documentation/SCSIControllerDriverKit/IOUserSCSIParallelInterfaceController/UserInitializeTargetForID) won’t have a chance to run on the default queue, leading to a deadlock.

You can avoid this problem by calling [`UserCreateTargetForID`](/documentation/SCSIControllerDriverKit/IOUserSCSIParallelInterfaceController/UserCreateTargetForID) from an asynchronous handler function. Start by creating an async handler function for your custom dext class in its `iig` file, as shown below:

```objc
virtual void AsyncEventHandler ( OSAction *  action TARGET,                                 uint32_t    targetID ) = 0;

virtual void AsyncCreateTargetForID ( OSAction *  action,
                                    uint32_t    targetID )
                                    TYPE ( ExampleSCSIDext::AsyncEventHandler ) QUEUENAME ( AuxiliaryQueue );
```

This handler function can then call [`UserCreateTargetForID`](/documentation/SCSIControllerDriverKit/IOUserSCSIParallelInterfaceController/UserCreateTargetForID):

```objc
void
IMPL ( MyCustomService, AsyncCreateTargetForID )
{
     kern_return_t ret;
     …
     ret = UserCreateTargetForID (targetID, NULL);
     …
}
```

Then you can call this handler in [`UserStartController`](/documentation/SCSIControllerDriverKit/IOUserSCSIParallelInterfaceController/UserStartController):

```objc
kern_return_t
IMPL ( MyCustomService, UserStartController )
{
    …
    ret = CreateActionAsyncCreateTargetForID ( sizeof ( void * ), &ivars->fAsyncEventHandler );
    assert ( kIOReturnSuccess == ret );

    AsyncEventHandler ( ivars->fAsyncEventHandler, targetID );
    …
}
```

This implementation ensures [`UserStartController`](/documentation/SCSIControllerDriverKit/IOUserSCSIParallelInterfaceController/UserStartController) calls the event handler asynchronously, which frees up the default dispatch queue for subsequent calls.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)