Re: light weight user level semaphores

Ulrich Drepper
2001-04-19T20:28:19Z

Alan Cox <alan@lxorguk.ukuu.org.uk> writes:

> > I don't want nor need file permissions. A program would look like this:
>
> Your example opens/mmaps so has file permissions. Which is what I was asking

There are no permissions on the mutex object. It is the shared memory
which counts. If you would implement the global mutexes as
independent objects in the filesystem hierarchy you would somehow
magically make the permissions match those of the object containing
the memory representation of the global semaphore.

fd = open("somefile", O_CREAT|O_TRUNC, 0666)
addr=mmap(fd)
// assume attr is for a global mutex
pthread_mutex_init((pthread_mutex_t*)addr, &attr)
fchmod(fd, 0600)
fchown(fd, someuser, somegroup)

If pthread_mutex_attr() is allocating some kind of file, how do you
determine the permissions? How are they changed if the permissions to
the file change?

The kernel representation of the mutex must not be disassociated from
the shared memory region.

Even if you all think very little about Solaris, look at the kernel
interface for semaphores.

--
---------------. ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Red Hat `--' drepper at redhat.com `------------------------