2 * Copyright (c) 2016 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #include <mach/mach_types.defs> // mach_port_t
30 #include <mach/clock_types.defs> // mach_timespec_t
33 import <mach/resource_monitors.h>;
34 import <mach/clock_types.h>;
36 import <System/mach/resource_monitors.h>;
37 import <System/mach/clock_types.h>;
40 // match struct proc.p_name / proc_name_t as of January 2016
42 type proc_name_t = array [2*MAXCOMLEN+1] of char;
43 type posix_path_t = array [512] of char; // ?? can't compile w/1024?
44 type resource_notify_flags_t = uint64_t;
46 /* The kernel sends the message, so we compile with KernelUser when
47 building in the kernel. */
52 resource_notify 827800; /* 'R''N'00 */
55 ServerPrefix receive_;
58 SimpleRoutine cpu_usage_violation(
59 receiver : mach_port_t;
62 procname : proc_name_t;
64 killed_proc_path : posix_path_t; /* filled in if fatal */
67 timestamp : mach_timespec_t; /* 32b time, see 25567702 */
68 observed_cpu_nsecs : int64_t;
69 observation_nsecs : int64_t; /* time it took to hit limit */
71 /* threshold crossed: calculated from proc_set_cpumon_params() */
72 cpu_nsecs_allowed : int64_t;
73 limit_window_nsecs : int64_t; /* over this period */
75 flags : resource_notify_flags_t
78 SimpleRoutine cpu_wakes_violation(
79 receiver : mach_port_t;
82 procname : proc_name_t;
84 killed_proc_path : posix_path_t; /* filled in if fatal */
87 timestamp : mach_timespec_t;
88 observed_cpu_wakes : int64_t;
89 observation_nsecs : int64_t; /* time it took to hit limit */
91 /* threshold crossed: calculated from proc_set_wakemon_params() */
92 cpu_wakes_allowed : int64_t;
93 limit_window_nsecs : int64_t; /* over this period */
95 flags : resource_notify_flags_t
98 SimpleRoutine disk_writes_violation(
99 receiver : mach_port_t;
102 procname : proc_name_t;
104 killed_proc_path : posix_path_t; /* filled in if fatal */
107 timestamp : mach_timespec_t;
108 observed_bytes_dirtied : int64_t;
109 observation_nsecs : int64_t; /* time it took to hit limit */
112 bytes_dirtied_allowed : int64_t;
113 limit_window_nsecs : int64_t; /* over this period */
115 flags : resource_notify_flags_t