---
title: "hv_vcpu_run(_:)"
framework: hypervisor
role: symbol
role_heading: Function
path: "hypervisor/hv_vcpu_run(_:)"
---

# hv_vcpu_run(_:)

Starts the execution of a vCPU.

## Declaration

```swift
func hv_vcpu_run(_ vcpu: hv_vcpu_t) -> hv_return_t
```

## Parameters

- `vcpu`: The instance of the vCPU.

## Return Value

Return Value HV_SUCCESS if the operation was successful, otherwise an error code specified in hv_return_t.

## Discussion

Discussion Call blocks until the next exit of the vCPU. The owning thread must call this function. On an Apple Silicon, if the exit is of type HV_EXIT_REASON_VTIMER_ACTIVATED, the VTimer is automatically masked. As a result, no timer fires until the timer is unmasked with hv_vcpu_set_vtimer_mask(_:_:). On an Intel-based Mac, hv_vcpu_run(_:) exits from causes external to the guest. To avoid the overhead of spurious exits use hv_vcpu_run_until(_:_:) with the deadline HV_DEADLINE_FOREVER.

## See Also

### Runtime

- [hv_vcpus_exit(_:_:)](hypervisor/hv_vcpus_exit(_:_:).md)
- [hv_vcpu_get_pending_interrupt(_:_:_:)](hypervisor/hv_vcpu_get_pending_interrupt(_:_:_:).md)
- [hv_vcpu_set_pending_interrupt(_:_:_:)](hypervisor/hv_vcpu_set_pending_interrupt(_:_:_:).md)
- [hv_vcpu_get_exec_time(_:_:)](hypervisor/hv_vcpu_get_exec_time(_:_:).md)
- [hv_interrupt_type_t](hypervisor/hv_interrupt_type_t.md)
- [Exits](hypervisor/exits.md)
