]> git.saurik.com Git - apple/xnu.git/blame_incremental - bsd/sys/kern_callout.h
xnu-1504.9.37.tar.gz
[apple/xnu.git] / bsd / sys / kern_callout.h
... / ...
CommitLineData
1/*
2 * Copyright (c) 2008 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29#ifndef KPI_KERN_CALLOUT_H
30#define KPI_KERN_CALLOUT_H
31
32#ifdef KERNEL
33
34/*
35 * Default sample threshold for validity
36 */
37#define MA_SMA_SAMPLES 10 /* simple moving average */
38
39/*
40 * Flags bits for the ma_flags field
41 */
42#define KCO_MA_F_SMA 0x00000001 /* Simple moving average */
43#define KCO_MA_F_WMA 0x00000002 /* Weighted moving average */
44#define KCO_MA_F_NEEDS_INIT 0x80000000 /* Need initialization */
45
46struct kco_moving_average {
47 int ma_flags; /* flags */
48 uint64_t ma_sma; /* simple over MA_SMA_SAMPLES*/
49 uint64_t ma_old_sma; /* previous value */
50 uint64_t ma_sma_samples[MA_SMA_SAMPLES]; /* sample history */
51 int32_t ma_sma_threshold; /* trigger delta (%) */
52 int ma_sma_trigger_count; /* number of time triggered */
53 uint64_t ma_wma; /* weighted */
54 uint64_t ma_old_wma; /* previous value */
55 int ma_wma_weight; /* weighting (< 100) */
56 int32_t ma_wma_threshold; /* trigger delta (%) */
57 int ma_wma_trigger_count; /* number of time triggered */
58};
59
60__BEGIN_DECLS
61int kco_ma_addsample(struct kco_moving_average *map, uint64_t sample_time);
62void kco_ma_init(struct kco_moving_average *map, int32_t threshold, int kind);
63int kco_ma_info(struct kco_moving_average *map, int kind, uint64_t *averagep, uint64_t *old_averagep, int32_t *thresholdp, int *countp);
64__END_DECLS
65
66#endif /* KERNEL */
67
68#endif /* KPI_KERN_CONTROL_H */