2016-08-07 16:32:11 +02:00
|
|
|
/****************************************************************************
|
2014-08-08 22:55:16 +02:00
|
|
|
* sched/timer/timer.h
|
2007-03-21 18:21:26 +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 18:21:26 +01:00
|
|
|
*
|
2020-03-11 21:09:41 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-03-21 18:21:26 +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 18:21:26 +01:00
|
|
|
*
|
2016-08-07 16:32:11 +02:00
|
|
|
****************************************************************************/
|
2007-03-21 18:21:26 +01:00
|
|
|
|
2014-08-08 22:55:16 +02:00
|
|
|
#ifndef __SCHED_TIMER_TIMER_H
|
|
|
|
#define __SCHED_TIMER_TIMER_H
|
2007-03-21 18:21:26 +01:00
|
|
|
|
2016-08-07 16:32:11 +02:00
|
|
|
/****************************************************************************
|
2007-03-21 18:21:26 +01:00
|
|
|
* Included Files
|
2016-08-07 16:32:11 +02:00
|
|
|
****************************************************************************/
|
2007-03-21 18:21:26 +01:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
2009-12-14 20:30:18 +01:00
|
|
|
|
2007-03-21 18:21:26 +01:00
|
|
|
#include <sys/types.h>
|
2009-12-14 20:30:18 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2007-03-21 18:21:26 +01:00
|
|
|
#include <nuttx/compiler.h>
|
2019-01-27 16:28:59 +01:00
|
|
|
#include <nuttx/signal.h>
|
2014-08-21 19:16:55 +02:00
|
|
|
#include <nuttx/wdog.h>
|
2007-03-21 18:21:26 +01:00
|
|
|
|
2022-09-16 07:11:00 +02:00
|
|
|
#ifndef CONFIG_DISABLE_POSIX_TIMERS
|
|
|
|
|
2016-08-07 16:32:11 +02:00
|
|
|
/****************************************************************************
|
2015-04-08 14:47:36 +02:00
|
|
|
* Pre-processor Definitions
|
2016-08-07 16:32:11 +02:00
|
|
|
****************************************************************************/
|
2007-03-21 18:21:26 +01:00
|
|
|
|
2008-06-01 19:46:26 +02:00
|
|
|
#define PT_FLAGS_PREALLOCATED 0x01 /* Timer comes from a pool of preallocated timers */
|
2007-03-21 18:21:26 +01:00
|
|
|
|
2016-08-07 16:32:11 +02:00
|
|
|
/****************************************************************************
|
2007-03-21 18:21:26 +01:00
|
|
|
* Public Types
|
2016-08-07 16:32:11 +02:00
|
|
|
****************************************************************************/
|
2007-03-21 18:21:26 +01:00
|
|
|
|
|
|
|
/* This structure represents one POSIX timer */
|
|
|
|
|
|
|
|
struct posix_timer_s
|
|
|
|
{
|
|
|
|
FAR struct posix_timer_s *flink;
|
|
|
|
|
2020-10-29 04:10:26 +01:00
|
|
|
clockid_t pt_clock; /* Specifies the clock to use as the timing base. */
|
2019-01-27 16:28:59 +01:00
|
|
|
uint8_t pt_flags; /* See PT_FLAGS_* definitions */
|
|
|
|
uint8_t pt_crefs; /* Reference count */
|
|
|
|
pid_t pt_owner; /* Creator of timer */
|
2024-06-18 14:25:50 +02:00
|
|
|
int pt_overrun; /* Overrun time */
|
|
|
|
sclock_t pt_delay; /* If non-zero, used to reset repetitive timers */
|
|
|
|
clock_t pt_expected; /* Expected absolute time */
|
2020-08-04 12:31:31 +02:00
|
|
|
struct wdog_s pt_wdog; /* The watchdog that provides the timing */
|
2019-01-27 16:28:59 +01:00
|
|
|
struct sigevent pt_event; /* Notification information */
|
|
|
|
struct sigwork_s pt_work;
|
2007-03-21 18:21:26 +01:00
|
|
|
};
|
|
|
|
|
2016-08-07 16:32:11 +02:00
|
|
|
/****************************************************************************
|
2007-03-21 18:21:26 +01:00
|
|
|
* Public Data
|
2016-08-07 16:32:11 +02:00
|
|
|
****************************************************************************/
|
2007-03-21 18:21:26 +01:00
|
|
|
|
2016-08-07 16:32:11 +02:00
|
|
|
#if CONFIG_PREALLOC_TIMERS > 0
|
2007-03-21 18:21:26 +01:00
|
|
|
/* This is a list of free, preallocated timer structures */
|
|
|
|
|
|
|
|
extern volatile sq_queue_t g_freetimers;
|
|
|
|
#endif
|
|
|
|
|
2020-03-11 21:09:41 +01:00
|
|
|
/* This is a list of instantiated timer structures -- active and inactive.
|
|
|
|
* The timers are place on this list by timer_create() and removed from the
|
|
|
|
* list by timer_delete() or when the owning thread exits.
|
2007-03-21 18:21:26 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
extern volatile sq_queue_t g_alloctimers;
|
|
|
|
|
2016-08-07 16:32:11 +02:00
|
|
|
/****************************************************************************
|
2007-03-21 18:21:26 +01:00
|
|
|
* Public Function Prototypes
|
2016-08-07 16:32:11 +02:00
|
|
|
****************************************************************************/
|
2007-03-21 18:21:26 +01:00
|
|
|
|
2022-08-16 06:20:39 +02:00
|
|
|
void timer_initialize(void);
|
|
|
|
void timer_deleteall(pid_t pid);
|
2016-08-07 16:32:11 +02:00
|
|
|
int timer_release(FAR struct posix_timer_s *timer);
|
2022-10-31 19:11:18 +01:00
|
|
|
FAR struct posix_timer_s *timer_gethandle(timer_t timerid);
|
2007-03-21 18:21:26 +01:00
|
|
|
|
2022-09-16 07:11:00 +02:00
|
|
|
#endif /* CONFIG_DISABLE_POSIX_TIMERS */
|
2014-08-08 22:55:16 +02:00
|
|
|
#endif /* __SCHED_TIMER_TIMER_H */
|