2016-08-07 16:25:30 +02:00
|
|
|
/****************************************************************************
|
2014-08-08 22:55:16 +02:00
|
|
|
* sched/timer/timer_getoverrun.c
|
2007-03-21 01:56:49 +01:00
|
|
|
*
|
2024-09-11 13:45:11 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
2020-03-11 21:09:41 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2007-03-21 01:56:49 +01:00
|
|
|
*
|
2020-03-11 21:09:41 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-03-21 01:56:49 +01:00
|
|
|
*
|
2020-03-11 21:09:41 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2007-03-21 01:56:49 +01:00
|
|
|
*
|
2016-08-07 16:25:30 +02:00
|
|
|
****************************************************************************/
|
2007-03-21 01:56:49 +01:00
|
|
|
|
2016-08-07 16:25:30 +02:00
|
|
|
/****************************************************************************
|
2007-03-21 01:56:49 +01:00
|
|
|
* Included Files
|
2016-08-07 16:25:30 +02:00
|
|
|
****************************************************************************/
|
2007-03-21 01:56:49 +01:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
2012-07-14 21:30:31 +02:00
|
|
|
|
2007-03-21 01:56:49 +01:00
|
|
|
#include <time.h>
|
|
|
|
#include <errno.h>
|
2012-07-14 21:30:31 +02:00
|
|
|
|
2014-08-08 22:55:16 +02:00
|
|
|
#include "timer/timer.h"
|
2007-03-21 01:56:49 +01:00
|
|
|
|
|
|
|
#ifndef CONFIG_DISABLE_POSIX_TIMERS
|
|
|
|
|
2016-08-07 16:25:30 +02:00
|
|
|
/****************************************************************************
|
2007-03-21 01:56:49 +01:00
|
|
|
* Public Functions
|
2016-08-07 16:25:30 +02:00
|
|
|
****************************************************************************/
|
2007-03-21 01:56:49 +01:00
|
|
|
|
2016-08-07 16:25:30 +02:00
|
|
|
/****************************************************************************
|
2012-07-14 21:30:31 +02:00
|
|
|
* Name: timer_getoverrun
|
2007-03-21 01:56:49 +01:00
|
|
|
*
|
|
|
|
* Description:
|
2016-08-07 16:25:30 +02:00
|
|
|
* Only a single signal will be queued to the process for a given timer at
|
|
|
|
* any point in time. When a timer for which a signal is still pending
|
|
|
|
* expires, no signal will be queued, and a timer overrun will occur. When
|
|
|
|
* a timer expiration signal is delivered to or accepted by a process, if
|
|
|
|
* the implementation supports the Realtime Signals Extension, the
|
|
|
|
* timer_getoverrun() function will return the timer expiration overrun
|
|
|
|
* count for the specified timer. The overrun count returned contains the
|
|
|
|
* number of extra timer expirations that occurred between the time the
|
|
|
|
* signal was generated (queued) and when it was delivered or accepted, up
|
|
|
|
* to but not including an implementation-defined maximum of
|
|
|
|
* DELAYTIMER_MAX. If the number of such extra expirations is greater than
|
|
|
|
* or equal to DELAYTIMER_MAX, then the overrun count will be set to
|
|
|
|
* DELAYTIMER_MAX. The value returned by timer_getoverrun() will apply to
|
|
|
|
* the most recent expiration signal delivery or acceptance for the timer.
|
|
|
|
* If no expiration signal has been delivered for the timer, or if the
|
|
|
|
* Realtime Signals Extension is not supported, the return value of
|
|
|
|
* timer_getoverrun() is unspecified.
|
2007-03-21 01:56:49 +01:00
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2007-03-21 01:56:49 +01:00
|
|
|
* timerid - The pre-thread timer, previously created by the call to
|
|
|
|
* timer_create(), whose overrun count will be returned..
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2007-03-21 01:56:49 +01:00
|
|
|
* If the timer_getoverrun() function succeeds, it will return the timer
|
2016-08-07 16:25:30 +02:00
|
|
|
* expiration overrun count as explained above. timer_getoverrun() will
|
|
|
|
* fail if:
|
2007-03-21 01:56:49 +01:00
|
|
|
*
|
|
|
|
* EINVAL - The timerid argument does not correspond to an ID returned by
|
|
|
|
* timer_create() but not yet deleted by timer_delete().
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
*
|
2016-08-07 16:25:30 +02:00
|
|
|
****************************************************************************/
|
2007-03-21 01:56:49 +01:00
|
|
|
|
|
|
|
int timer_getoverrun(timer_t timerid)
|
|
|
|
{
|
2024-06-18 14:25:50 +02:00
|
|
|
FAR struct posix_timer_s *timer = timer_gethandle(timerid);
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!timer)
|
|
|
|
{
|
|
|
|
set_errno(EINVAL);
|
|
|
|
return ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = timer->pt_overrun;
|
|
|
|
|
|
|
|
return ret > DELAYTIMER_MAX ? DELAYTIMER_MAX : ret;
|
2007-03-21 01:56:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_DISABLE_POSIX_TIMERS */
|