Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move alarm to user space #2

Open
Shamar opened this issue Jan 13, 2017 · 0 comments
Open

Move alarm to user space #2

Shamar opened this issue Jan 13, 2017 · 0 comments

Comments

@Shamar
Copy link
Member

@Shamar Shamar commented Jan 13, 2017

Given the note file in devproc and the awake system call we can implement the alarm service as a filesystem in user space.

alarmfs [-dD] [-S servicename]

$home/lib/profile may mount an alarmfs to /dev
The attach specifier must provide a root pid: the server will only send alarms to process identified by that pid or its descendants and attach will fail if the current user cannot write its note file.

Alarmfs will serve a single folder alarms/ that

  • is owned by the user owning the process provided on attach
  • has permission 700
  • has qid.path containing the root pid
  • provides the list of pending alarms as readonly files. Each file is named after the pid it will notify.

Processes can initialize a new alarm with

fd = create("/dev/alarms/new", ~0, pair_ints(getpid(), ms))

The provided fd can be used to write the alarm message. The alarm will be actually set on close(fd), that will return the expected epoch of the alarm (rounded by excess).

On alarm, the process will receive a note with the message provided. If no message was written, "alarm" will be used instead. To clear the alarm for a process, remove the related file.

A new libc function with signature long alarm(int ms) will serve the original Plan 9 use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant