2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
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.
17 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
18 File name : _pbProcMng.cpp
22 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
25 #include <sys/procfs.h>
26 #include <vehicle_service/positioning_base_library.h>
27 #include "WPF_STD_private.h"
28 #include "_pbInternalProc.h"
29 #include "_pbWaitforsingleobject.h"
31 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
32 * MODULE : ExitProcess
33 * ABSTRACT : Terminate one process and all threads belonging to that process.
36 * RETURN : VOID defined
37 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
38 VOID ExitProcess(UINT u_exit_code) { // LCOV_EXCL_START 8:dead code
39 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
44 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
45 * MODULE : GetCurrentProcess
46 * ABSTRACT : Get a pseudo handle for the current process.
49 * RETURN : HANDLE defined
50 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
52 HANDLE GetCurrentProcess(void) { // LCOV_EXCL_START 8:dead code
53 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
54 return reinterpret_cast<HANDLE>(getpid());
58 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
59 * MODULE : GetCurrentProcessId
60 * ABSTRACT : Get the process identifier of the calling process.
63 * RETURN : DWORD defined
64 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
66 DWORD GetCurrentProcessId(void) { // LCOV_EXCL_START 8:dead code
67 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
68 return (DWORD)getpid();
72 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
73 * MODULE : _pb_ExitThread
74 * ABSTRACT : Terminate a thread
77 * RETURN : VOID defined
78 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
79 VOID _pb_ExitThread(DWORD dw_exit_code) { // LCOV_EXCL_START 8:dead code // NOLINT(whitespace/line_length) // NOLINT(readability/nolint) WPF_SYSAPI.h API
80 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
81 /* Delete handle type */
82 WaitObjectDel(reinterpret_cast<HANDLE*>(pthread_self()));
84 return pthread_exit (reinterpret_cast<void*>(dw_exit_code));
88 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
89 * MODULE : TerminateThread
90 * ABSTRACT : Terminate a thread
93 * RETURN : BOOL defined
94 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
95 BOOL TerminateThread(HANDLE h_thread, DWORD dw_exit_code) { // LCOV_EXCL_START 8:dead code
96 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
100 /* Delete handle type */
101 WaitObjectDel(h_thread);
103 /* When an error occurs */
112 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
113 * MODULE : GetExitCodeThread
114 * ABSTRACT : Get the exit status of the specified thread.
117 * RETURN : BOOL defined
118 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
119 BOOL GetExitCodeThread(HANDLE h_thread, LPDWORD lp_exit_code) { // LCOV_EXCL_START 8:dead code
120 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
125 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
126 * MODULE : WaitExitThread
127 * ABSTRACT : Wait for the thread to terminate.
128 * NOTE : It can only be used for a thread in the same process according to PosixBasedOS001.
130 * RETURN : BOOL defined
131 * RET_NORMAL : Normal completion
133 * RET_ERRTIMEOUT : Timeout occurred
134 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
135 RET_API WaitExitThread(HANDLE h_handle, u_int32 ul_mill_seconds, u_int32* pul_exit_code) { // LCOV_EXCL_START 8:dead code // NOLINT(whitespace/line_length)
136 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
137 return RET_NORMAL; /* Coverity CID: 18759 compliant */
141 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
142 * MODULE : GetCurrentThread
143 * ABSTRACT : Get a pseudo handle for the current thread.
146 * RETURN : HANDLE defined
147 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
149 HANDLE GetCurrentThread(void) { // LCOV_EXCL_START 8:dead code
150 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
151 return (HANDLE)pthread_self();
155 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
156 * MODULE : GetCurrentThreadId
157 * ABSTRACT : Get the thread identifier of the calling thread.
160 * RETURN : DWORD defined
161 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
163 DWORD GetCurrentThreadId(void) { // LCOV_EXCL_START 8:dead code
164 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
165 return (DWORD)pthread_self();
169 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
170 * MODULE : GetThreadTimes
171 * ABSTRACT : Get time information about the specified thread.
174 * RETURN : BOOL defined
175 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
176 BOOL GetThreadTimes(HANDLE h_process, HANDLE h_thread, LPFILETIME lp_creation_time, LPFILETIME lp_exit_time, LPFILETIME lp_kernel_time, LPFILETIME lp_user_time) { // LCOV_EXCL_START 8:dead code // NOLINT(whitespace/line_length)
177 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
178 return TRUE; /* Coverity CID: 18765 compliant */
182 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
183 * MODULE : ResumeThread
184 * ABSTRACT : Decrease the thread suspend count by 1.
185 * NOTE : Always return 0 because no suspend operation is supported according to PosixBasedOS001.
187 * RETURN : DWORD defined
188 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
189 DWORD ResumeThread(HANDLE h_thread) { // LCOV_EXCL_START 8:dead code
190 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert
195 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
196 * MODULE : SuspendThread
197 * ABSTRACT : Suspend execution of the specified thread.
198 * NOTE : Always return 0 because no suspend operation is supported according to PosixBasedOS001.
200 * RETURN : DWORD defined
201 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
202 DWORD SuspendThread(HANDLE h_thread) { // LCOV_EXCL_START 8:dead code
203 AGL_ASSERT_NOT_TESTED(); // LCOV_EXCL_LINE 200: test assert