# Creating a Semaphore

To create a semaphore, use `CreateSemaphore()`:

  `Item CreateSemaphore( const char *name, uint8 pri )`

The `name` argument is the name to give to the new semaphore. You can use the `FindSemaphore()` macro described later in this chapter to find the semaphore by name. To ensure that `FindSemaphore()` finds the correct semaphore, you must provide a unique name for each semaphore you create.

The `pri` argument determines where this semaphore will be placed within the list of all semaphores in the system. A higher priority puts it closer to the start of the list. `CreateSemaphore()` returns the item number of the new semaphore or an error code (a negative value) if an error occurred.

To delete a semaphore created with `CreateSemaphore(),` use the `DeleteSemaphore()` function described in Deleting a Semaphore.