2 * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.ComponentModel;
20 namespace Tizen.System
23 /// Provides methods to support CPU boosting and CPU inheritance.
25 [EditorBrowsable(EditorBrowsableState.Never)]
29 /// Set cpu boosting for the target process (pid/tids).
32 /// http://tizen.org/privilege/internal/default/partner
34 /// <param name="pid">The target process pid/tids.</param>
35 /// <param name="level">The cpu boosting level</param>
36 /// <param name="flags">The cpu boosting flag bits</param>
37 /// <param name="timeoutMsec">The timeout in milliseconds</param>
38 [EditorBrowsable(EditorBrowsableState.Never)]
39 public static void ResourceSetCpuBoosting (ResourcePidInfo pid, CpuBoostingLevel level, CpuBoostingFlag flags, int timeoutMsec)
41 ResourceError ret = Interop.Resource.ResourceSetCpuBoosting(pid, level, flags, timeoutMsec);
42 if (ret != ResourceError.None) {
43 Log.Error(ResourceErrorFactory.LogTag, "Interop failed to set cpu boosting");
44 ResourceErrorFactory.ThrowException(ret);
49 /// Clear cpu boosting for the boosted process (pid/tids).
52 /// http://tizen.org/privilege/internal/default/partner
54 /// <param name="pid">The target process pid/tids.</param>
55 [EditorBrowsable(EditorBrowsableState.Never)]
56 public static void ResourceClearCpuBoosting (ResourcePidInfo pid)
58 ResourceError ret = Interop.Resource.ResourceClearCpuBoosting(pid);
59 if (ret != ResourceError.None) {
60 Log.Error(ResourceErrorFactory.LogTag, "Interop failed to clear cpu boosting");
61 ResourceErrorFactory.ThrowException(ret);
66 /// Get the cpu boosting level for the target process (pid/tids).
69 /// http://tizen.org/privilege/internal/default/partner
71 /// <param name="pid">The target process pid/tids.</param>
72 /// <param name="level">The boosting level for the target process (pid/tids).</param>
73 [EditorBrowsable(EditorBrowsableState.Never)]
74 public static void ResourceGetCpuBoostingLevel (ResourcePidInfo pid, out CpuBoostingLevelInfo level)
76 ResourceError ret = Interop.Resource.ResourceGetCpuBoostingLevel(pid, out level);
77 if (ret != ResourceError.None) {
78 Log.Error(ResourceErrorFactory.LogTag, "Interop failed to get cpu boosting");
79 ResourceErrorFactory.ThrowException(ret);
82 if (level.TidLevel == IntPtr.Zero) {
83 Log.Error(ResourceErrorFactory.LogTag, "TidLevel cannot be zero");
84 ResourceErrorFactory.ThrowException(ResourceError.InvalidParameter);
89 /// Set cpu resource inheritance from the source tid to the destination process (pid/tids).
92 /// http://tizen.org/privilege/internal/default/partner
94 /// <param name="sourceTid">The caller thread tid.</param>
95 /// <param name="destProcess">The name of destination process.</param>
96 /// <param name="timeoutMsec">The timeout in milliceconds.</param>
97 [EditorBrowsable(EditorBrowsableState.Never)]
98 public static void ResourceSetCpuInheritance (int sourceTid, string destProcess, int timeoutMsec)
100 ResourceError ret = Interop.Resource.ResourceSetCpuInheritance(sourceTid, destProcess, timeoutMsec);
101 if (ret != ResourceError.None) {
102 Log.Error(ResourceErrorFactory.LogTag, "Interop failed to set inheritance");
103 ResourceErrorFactory.ThrowException(ret);
108 /// Clear cpu resource inheritance from the source tid to the destination process (pid/tids).
111 /// http://tizen.org/privilege/internal/default/partner
113 /// <param name="sourceTid">The caller thread tid.</param>
114 /// <param name="destProcess">The name of destination process.</param>
115 [EditorBrowsable(EditorBrowsableState.Never)]
116 public static void ResourceClearCpuInheritance (int sourceTid, string destProcess)
118 ResourceError ret = Interop.Resource.ResourceClearCpuInheritance(sourceTid, destProcess);
119 if (ret != ResourceError.None) {
120 Log.Error(ResourceErrorFactory.LogTag, "Interop failed to clear inheritance");
121 ResourceErrorFactory.ThrowException(ret);
126 /// Register a destination process (pid/tids) for cpu resource inheritance.
129 /// http://tizen.org/privilege/internal/default/partner
131 /// <param name="destProcess">The name of destination process.</param>
132 /// <param name="pid">The destination process pid/tids.</param>
133 [EditorBrowsable(EditorBrowsableState.Never)]
134 public static void ResourceRegisterCpuInheritanceDestination (string destProcess, ResourcePidInfo pid)
136 ResourceError ret = Interop.Resource.ResourceRegisterCpuInheritanceDestination(destProcess, pid);
137 if (ret != ResourceError.None) {
138 Log.Error(ResourceErrorFactory.LogTag, "Interop failed to register destination");
139 ResourceErrorFactory.ThrowException(ret);
144 /// Unregister a destination process (pid/tids) for cpu resource inheritance.
147 /// http://tizen.org/privilege/internal/default/partner
149 /// <param name="destProcess">The name of destination process.</param>
150 [EditorBrowsable(EditorBrowsableState.Never)]
151 public static void ResourceUnregisterCpuInheritanceDestination (string destProcess)
153 ResourceError ret = Interop.Resource.ResourceUnregisterCpuInheritanceDestination(destProcess);
154 if (ret != ResourceError.None) {
155 Log.Error(ResourceErrorFactory.LogTag, "Interop failed to unregister destination");
156 ResourceErrorFactory.ThrowException(ret);