libtock-c icon indicating copy to clipboard operation
libtock-c copied to clipboard

What happened to alarm_read?

Open reynoldsbd opened this issue 1 year ago • 3 comments

alarm.h declares a function named alarm_read. Ostensibly this is used to read the current counter value of the underlying alarm hardware using command number 2 of the alarm driver.

Unfortunately this function doesn't seem to be defined anywhere. GitHub search suggests it used to be in a file called alarm.c, but that file doesn't exist today (and having trouble tracking down the commit where it was removed).

reynoldsbd avatar Oct 05 '22 14:10 reynoldsbd

It's still present, just moved to the slightly more opaque internal bits: https://github.com/tock/libtock-c/blob/master/libtock/internal/alarm_internal.c#L24

Historically, alarm virtualization happened in userland before it was implemented in the kernel; this meant that there was value in hiding 'direct' views of the underlying alarm subsystem. I think that's probably less true now that virtual_alarm is in the kernel, but would have to look more deeply to refresh myself before saying that with authority.

ppannuto avatar Oct 05 '22 18:10 ppannuto

Thanks for the background!

The app I'm working on requires a steady source of ticks, and the alarm driver feels like the right fit. It's easy enough to issue command 2 manually, but all the better if the logic can come as part of libtock-c

reynoldsbd avatar Oct 05 '22 18:10 reynoldsbd

I think it is a bug though that the function is straight-up missing. An implementation almost certainly just calls alarm_internal_read(), but we should make it exist. Probably added to alarm_timer.c.

brghena avatar Oct 05 '22 18:10 brghena