• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "c/ffrt_ipc.h"
16 
17 #include "internal_inc/osal.h"
18 #include "sched/execute_ctx.h"
19 #include "tm/cpu_task.h"
20 #include "dfx/log/ffrt_log_api.h"
21 #include "util/ffrt_facade.h"
22 
23 namespace {
24 constexpr char EXCLUSIVE_MODE_TASK_NAME[] = "VSyncGenerator";
25 }
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 API_ATTRIBUTE((visibility("default")))
ffrt_this_task_set_legacy_mode(bool mode)32 void ffrt_this_task_set_legacy_mode(bool mode)
33 {
34     auto task = ffrt::ExecuteCtx::Cur()->task;
35     if (!ffrt::IsCoTask(task)) {
36         return;
37     }
38 
39     ffrt::CoTask* coTask = static_cast<ffrt::CoTask*>(task);
40 
41     if (mode) {
42         coTask->legacyCountNum++;
43     } else {
44         coTask->legacyCountNum--;
45         if (coTask->legacyCountNum < 0) {
46             FFRT_SYSEVENT_LOGE("Legacy count num less than zero");
47         }
48     }
49 
50     if (task->GetLabel() == EXCLUSIVE_MODE_TASK_NAME) {
51         task->monitorTimeout_ = false;
52         ffrt::FFRTFacade::GetEUInstance().DisableWorkerMonitor(task->GetQos(), ffrt::ExecuteCtx::Cur()->tid);
53     }
54 }
55 
56 #ifdef __cplusplus
57 }
58 #endif