docs/how-to-build.md: use proper markup for directory names
[unleashed/tickless.git] / include / sys / clock_tick.h
blobb3dc2198ede5414eb77a3cf179a394700502a7dd
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_CLOCK_TICK_H
28 #define _SYS_CLOCK_TICK_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <sys/types.h>
33 #include <sys/mutex.h>
34 #include <sys/cpuvar.h>
35 #include <sys/systm.h>
36 #include <sys/cyclic.h>
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
42 #define CLOCK_TICK_NCPUS 32
45 * Per-CPU structure to facilitate multi-threaded tick accounting.
47 * ct_lock
48 * Mutex for the structure. Used to lock the structure to pass
49 * arguments to the tick processing softint handler.
50 * ct_intr
51 * Tick processing softint handle. For parallelism, each CPU
52 * needs to have its own softint handle.
53 * ct_lbolt
54 * Copy of the lbolt at the time of tick scheduling.
55 * ct_pending
56 * Number of ticks to be processed by one invocation of the tick
57 * processing softint.
58 * ct_start
59 * First CPU to do tick processing for.
60 * ct_end
61 * Last CPU to do tick processing for.
62 * ct_scan
63 * CPU to start the tick processing from. Rotated every tick.
65 typedef struct clock_tick_cpu {
66 kmutex_t ct_lock;
67 ulong_t ct_intr;
68 clock_t ct_lbolt;
69 int ct_pending;
70 int ct_start;
71 int ct_end;
72 int ct_scan;
73 } clock_tick_cpu_t;
76 * Per-set structure to facilitate multi-threaded tick accounting.
77 * clock_tick_lock protects this.
79 * ct_start
80 * First CPU to do tick processing for.
81 * ct_end
82 * Last CPU to do tick processing for.
83 * ct_scan
84 * CPU to start the tick processing from. Rotated every tick.
86 typedef struct clock_tick_set {
87 int ct_start;
88 int ct_end;
89 int ct_scan;
90 } clock_tick_set_t;
92 #define CLOCK_TICK_CPU_OFFLINE(cp) \
93 (((cp) != cpu_active) && ((cp)->cpu_next_onln == (cp)))
95 #define CLOCK_TICK_XCALL_SAFE(cp) \
96 CPU_IN_SET(clock_tick_online_cpuset, cp->cpu_id)
98 #define CLOCK_TICK_PROC_MAX 10
100 #ifdef _KERNEL
101 #pragma weak create_softint
102 extern ulong_t create_softint(uint_t, uint_t (*)(caddr_t, caddr_t),
103 caddr_t);
104 #pragma weak invoke_softint
105 extern void invoke_softint(processorid_t, ulong_t);
106 #pragma weak sync_softint
107 extern void sync_softint(cpuset_t);
108 extern void clock_tick(kthread_t *, int);
109 extern void membar_sync(void);
111 extern int hires_tick;
112 #endif /* _KERNEL */
114 #ifdef __cplusplus
116 #endif
118 #endif /* _SYS_CLOCK_TICK_H */