blob: f10253d455850877ce5bf37067ca3c3af0910007 [file] [log] [blame]
Mark Salyzynf089e142018-02-20 10:47:40 -08001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17#include "llkd.h"
18
19#include <sched.h>
20#include <unistd.h>
21
22#include <chrono>
23
24#include <android-base/logging.h>
25
26using namespace std::chrono;
27
28int main(int, char**) {
29 LOG(INFO) << "started";
30
31 bool enabled = llkInit();
32
33 // Would like this policy to be automatic as part of libllkd,
34 // but that would be presumptuous and bad side-effect.
35 struct sched_param param;
36 memset(&param, 0, sizeof(param));
37 sched_setscheduler(0, SCHED_BATCH, &param);
38
39 while (true) {
40 if (enabled) {
41 ::usleep(duration_cast<microseconds>(llkCheck()).count());
42 } else {
43 ::pause();
44 }
45 }
46 // NOTREACHED
47
48 LOG(INFO) << "exiting";
49 return 0;
50}