Bug 6313 - (int-148599) libalarm doesn't trigger an alarm accurately
(int-148599)
: libalarm doesn't trigger an alarm accurately
Status: VERIFIED INVALID
Product: Utilities
Clock
: 5.0/(1.2009.42-11)
: N900 Linux
: Low normal (vote)
: ---
Assigned To: unassigned
: clock-bugs
: http://maemo.org/api_refs/5.0/5.0-fin...
:
:
:
  Show dependency tree
 
Reported: 2009-11-24 21:06 UTC by Tapio Nieminen
Modified: 2010-01-07 14:22 UTC (History)
3 users (show)

See Also:


Attachments


Note

You need to log in before you can comment on or make changes to this bug.


Description Tapio Nieminen (reporter) 2009-11-24 21:06:01 UTC
SOFTWARE VERSION:
N900 1.2009.42-11 / Fremantle final SDK

EXACT STEPS LEADING TO PROBLEM: 
1. activate sdk armel target
get libalarm example from garage:
svn export https://garage.maemo.org/svn/maemoexamples/trunk/maemo-examples/
cd maemo-examples

2. compile the example: make example_alarm

3. copy the compiled example_alarm to the device

4. run the example on device

5. trigger an alarm by clicking the "Set alarm" button 

EXPECTED OUTCOME:
Alarm is triggered in 2 seconds (defined in function set_alarm()).

ACTUAL OUTCOME:
Alarm is triggered in about 30 to 60 seconds. If multiple alarms are set before
the first one goes off, they may come in rapid succession.

REPRODUCIBILITY:
almost always
Comment 1 Lucas Maneos 2009-11-24 22:24:00 UTC
Confirmed.  Now I wonder if the example does something wrong or there's a bug
in alarmd...
Comment 2 Andre Klapper maemo.org 2009-12-10 15:42:37 UTC
So, forwarding the internal comment here:


> EXPECTED OUTCOME:
> Alarm is triggered in 2 seconds (defined in function set_alarm()).

        time(&current_time);
        alarm_time = localtime(&current_time);
        alarm_time->tm_sec += 2;
        event->alarm_tm = *alarm_time;

The alarm is set 2 secs in to the future, however alarmd will
round up the triggering time to the next full minute.

If one really wants to specify triggering time with one second
accuracy, then the event->alarm_time field can be used:
        event->alarm_time = time(0) + 2;

Note: if alarm_time field is used, then the triggering time will
      not be adjusted when timezone changes.

> ACTUAL OUTCOME:
> Alarm is triggered in about 30 to 60 seconds. If multiple alarms are set before
> the first one goes off, they may come in rapid succession.

If the 30-60 range is not taken literally, this should be as
expected: batch of alarms gets triggered at the next full minute.

After clicking the "Set alarm" button few times with couple of
secs delay in between the queue status looks like this:

% alarmclient -i
[019]  hello_alarm//   Mon 2009-11-30 06:40:00 (T-50s)
[020]  hello_alarm//   Mon 2009-11-30 06:40:00 (T-50s)
[021]  hello_alarm//   Mon 2009-11-30 06:40:00 (T-50s)
[022]  hello_alarm//   Mon 2009-11-30 06:40:00 (T-50s)

I'd say this bug is -> INVALID - reopen if you think otherwise.

But if I'm not wrong these details are missing from the alarm api
documentation?
Comment 3 Lucas Maneos 2009-12-14 05:22:44 UTC
(In reply to comment #2)
> So, forwarding the internal comment here:

Very useful information, thanks!

> Note: if alarm_time field is used, then the triggering time will
>       not be adjusted when timezone changes.

Is there an internal bug about that?  Since alarm_time is time_t this may be
non-trivial, but it should at least be documented.

> But if I'm not wrong these details are missing from the alarm api
> documentation?

As far as I can tell they are.  Additionally
<http://wiki.maemo.org/Documentation/Maemo_5_Developer_Guide/Using_Generic_Platform_Components/Alarm_Framework>
uses the alarm_time field extensively, but without explaining why.  Shall we
turn this into a docs bug?
Comment 4 Andre Klapper maemo.org 2010-01-05 17:46:04 UTC
(In reply to comment #3)
> Is there an internal bug about that?  Since alarm_time is time_t this may be
> non-trivial, but it should at least be documented.

Don't know of one - feel free to file a new ticket about the docs, please!
Comment 5 Tapio Nieminen (reporter) 2010-01-07 14:22:37 UTC
Thanks for the info. Changed the garage example to set a minute interval to the
alarm and added as a comment the usage of event->alarm_time field. Also added a
note to the wiki page mentioned by Lucas Maneos:
http://wiki.maemo.org/Documentation/Maemo_5_Developer_Guide/Using_Generic_Platform_Components/Alarm_Framework#Adding_Alarm_Event_to_Queue

Alarm API ref says "Note that alarm timezone is used only when evaluating
trigger time from broken down time or recurrence time from recurrence masks"
but can't find any note about the full-minute-thingy. Filed a docs-bug:
https://bugs.maemo.org/show_bug.cgi?id=7743