← BYTES
Unix IPC·Starter·Ref: 15.1.79

What is the basic difference between a named and an unnamed POSIX semaphore?

Have a question about this video? Mention reference 15.1.79 when you contact us.

a.There is no real difference between the two
b.Unnamed semaphores can only ever be used by exactly one thread, forever
c.A named semaphore (sem_open) has a filesystem-visible name and can be used by entirely separate, unrelated processes that each open it by that name; an unnamed semaphore (sem_init) is just a plain in-memory object, typically used between threads of one process, or placed in shared memory for related processes
d.Named semaphores are always faster than unnamed ones on every system
Named semaphores (via sem_open, with a name like a file path) let independent, unrelated processes find and open the exact same semaphore by name; unnamed semaphores (via sem_init) are plain memory objects without that lookup-by-name capability, commonly used within one process's threads or placed into shared memory for processes that already know where that memory is.

Find this on YouTube & Instagram

Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:

#BYTES#BYTES15179#UnixIPC