semfs

command
v0.11.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2024 License: 0BSD Imports: 13 Imported by: 0

Documentation

Overview

Semfs is a semaphore file system. The original idea is from this book (Ballesteros 2006).

You can mount this file system via 9P using 9pfuse for example. The file system is initially empty, and you can make files on it. Each file represents a semaphore length of which is the number of tickets. To add tickets to an file, write the number of tickets to be added to the file. To consume a ticket, read the file.

$ 9pfuse localhost:5640 /mnt
$ echo 1 > /mnt/sem
$ ls -l /mnt/sem
-rw-rw-rw- 1 kenji kenji 1 Jan 17 08:16 /mnt/sem
$ cat /mnt/sem
$ ls -l /mnt/sem
-rw-rw-rw- 1 kenji kenji 0 Jan 17 08:17 /mnt/sem

Reading a file with length 0 blocks until someone adds tickets to the file.

$ ls -l /mnt/sem
-rw-rw-rw- 1 kenji kenji 0 Jan 17 08:17 /mnt/sem
$ (cat /mnt/sem; echo done) & sleep 1; echo write; echo 1 > /mnt/sem
[2] 42872
write
$ done

Usage:

semfs [-D]

The Flags are:

-D
	print very chatty 9P conversation dialogue to the standard output.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL