2016-08-07 08:32:11 -06:00
|
|
|
/****************************************************************************
|
2014-08-08 14:43:02 -06:00
|
|
|
* sched/clock/clock.h
|
2007-02-17 23:21:28 +00:00
|
|
|
*
|
2024-09-11 13:45:11 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*
|
2021-02-08 16:33:58 +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-02-17 23:21:28 +00:00
|
|
|
*
|
2021-02-08 16:33:58 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-02-17 23:21:28 +00:00
|
|
|
*
|
2021-02-08 16:33:58 +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-02-17 23:21:28 +00:00
|
|
|
*
|
2016-08-07 08:32:11 -06:00
|
|
|
****************************************************************************/
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2014-08-08 14:43:02 -06:00
|
|
|
#ifndef __SCHED_CLOCK_CLOCK_H
|
|
|
|
|
#define __SCHED_CLOCK_CLOCK_H
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2016-08-07 08:32:11 -06:00
|
|
|
/****************************************************************************
|
2007-02-17 23:21:28 +00:00
|
|
|
* Included Files
|
2016-08-07 08:32:11 -06:00
|
|
|
****************************************************************************/
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2007-06-09 15:49:44 +00:00
|
|
|
#include <nuttx/config.h>
|
2009-12-14 19:30:18 +00:00
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2011-10-02 14:16:30 +00:00
|
|
|
|
2007-09-09 11:58:50 +00:00
|
|
|
#include <nuttx/clock.h>
|
2007-02-17 23:21:28 +00:00
|
|
|
#include <nuttx/compiler.h>
|
2025-01-06 11:15:45 +08:00
|
|
|
#include <nuttx/spinlock_type.h>
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2016-08-07 08:32:11 -06:00
|
|
|
/****************************************************************************
|
2015-10-02 16:30:35 -06:00
|
|
|
* Public Data
|
2016-08-07 08:32:11 -06:00
|
|
|
****************************************************************************/
|
2014-10-03 10:20:46 -06:00
|
|
|
|
2016-07-11 06:54:02 -06:00
|
|
|
#ifndef CONFIG_CLOCK_TIMEKEEPING
|
2022-09-27 12:03:48 +08:00
|
|
|
extern struct timespec g_basetime;
|
2025-01-06 11:15:45 +08:00
|
|
|
extern spinlock_t g_basetime_lock;
|
2016-07-10 16:14:25 -06:00
|
|
|
#endif
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2016-08-07 08:32:11 -06:00
|
|
|
/****************************************************************************
|
2007-02-17 23:21:28 +00:00
|
|
|
* Public Function Prototypes
|
2016-08-07 08:32:11 -06:00
|
|
|
****************************************************************************/
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2026-03-03 17:47:40 +08:00
|
|
|
/****************************************************************************
|
|
|
|
|
* Name: clock_basetime
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* Get the initial time value from the best source available.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2018-11-12 07:00:41 -06:00
|
|
|
int clock_basetime(FAR struct timespec *tp);
|
|
|
|
|
|
2026-03-03 17:47:40 +08:00
|
|
|
/****************************************************************************
|
|
|
|
|
* Name: clock_initialize
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* Perform one-time initialization of the timing facilities.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2022-08-16 12:20:39 +08:00
|
|
|
void clock_initialize(void);
|
2025-10-13 20:33:32 +08:00
|
|
|
|
2026-03-03 17:47:40 +08:00
|
|
|
/****************************************************************************
|
|
|
|
|
* Name: clock_update_sched_ticks
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* Update the scheduler tick counter to a specific value. This function
|
|
|
|
|
* directly sets the system tick counter to the given value (rather than
|
|
|
|
|
* incrementing it), typically used for synchronizing or resetting the
|
|
|
|
|
* scheduler tick count to a known state.
|
|
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* ticks - The new value to set for the scheduler tick counter
|
|
|
|
|
*
|
|
|
|
|
* Returned Value:
|
|
|
|
|
* None
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void clock_update_sched_ticks(clock_t ticks);
|
|
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
|
* Name: clock_increase_sched_ticks
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* Increment the scheduler tick counter. This function should be called
|
|
|
|
|
* each time the real-time clock interrupt occurs, indicating the passage
|
|
|
|
|
* of one or more scheduling ticks.
|
|
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* ticks - The number of ticks to increment (typically 1)
|
|
|
|
|
*
|
|
|
|
|
* Returned Value:
|
|
|
|
|
* None
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2025-10-13 20:33:32 +08:00
|
|
|
void clock_increase_sched_ticks(clock_t ticks);
|
|
|
|
|
|
2026-03-03 17:47:40 +08:00
|
|
|
/****************************************************************************
|
|
|
|
|
* Name: clock_get_sched_ticks
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* Return the current value of the scheduler tick counter. This counter
|
|
|
|
|
* only increases while the scheduler is running, and is independent of
|
|
|
|
|
* the real-time clock.
|
|
|
|
|
*
|
|
|
|
|
* Returned Value:
|
|
|
|
|
* The current number of scheduler ticks.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2025-10-13 20:33:32 +08:00
|
|
|
clock_t clock_get_sched_ticks(void);
|
2007-02-17 23:21:28 +00:00
|
|
|
|
2024-08-07 21:46:39 +08:00
|
|
|
#ifdef CONFIG_SCHED_CPULOAD_SYSCLK
|
2026-03-03 17:47:40 +08:00
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
|
* Name: cpuload_init
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* Initialize the CPU load measurement logic.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2024-08-07 21:46:39 +08:00
|
|
|
void cpuload_init(void);
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-08-08 14:43:02 -06:00
|
|
|
#endif /* __SCHED_CLOCK_CLOCK_H */
|