Home | History | Annotate | Download | only in os
      1 /*
      2  * Copyright (C) 2017 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 syntax = "proto2";
     17 
     18 option java_multiple_files = true;
     19 
     20 import "frameworks/base/core/proto/android/privacy.proto";
     21 
     22 package android.os;
     23 
     24 /**
     25  * Data structure of the linux command
     26  * 'top -b -n 1 -H -s 6 -o pid,tid,user,pr,ni,%cpu,s,virt,res,pcy,cmd,name'
     27  *
     28  * Next Tag: 6
     29  */
     30 message CpuInfoProto {
     31     option (android.msg_privacy).dest = DEST_AUTOMATIC;
     32 
     33     message TaskStats {
     34         option (android.msg_privacy).dest = DEST_AUTOMATIC;
     35 
     36         optional int32 total = 1;    // total number of cpu tasks
     37         optional int32 running = 2;  // number of running tasks
     38         optional int32 sleeping = 3; // number of sleeping tasks
     39         optional int32 stopped = 4;  // number of stopped tasks
     40         optional int32 zombie = 5;   // number of zombie tasks
     41     }
     42     optional TaskStats task_stats = 1;
     43 
     44     message MemStats { // unit in kB
     45         option (android.msg_privacy).dest = DEST_AUTOMATIC;
     46 
     47         optional int32 total = 1;
     48         optional int32 used = 2;
     49         optional int32 free = 3;
     50         optional int32 buffers = 4;
     51         optional int32 cached = 5;
     52     }
     53     optional MemStats mem = 2;
     54     optional MemStats swap = 3;
     55 
     56     message CpuUsage { // unit is percentage %
     57         option (android.msg_privacy).dest = DEST_AUTOMATIC;
     58 
     59         optional int32 cpu = 1;   // 400% cpu indicates 4 cores
     60         optional int32 user = 2;
     61         optional int32 nice = 3;
     62         optional int32 sys = 4;
     63         optional int32 idle = 5;
     64         optional int32 iow = 6;
     65         optional int32 irq = 7;
     66         optional int32 sirq = 8;
     67         optional int32 host = 9;
     68     }
     69     optional CpuUsage cpu_usage = 4;
     70 
     71     // Next Tag: 13
     72     message Task {
     73         option (android.msg_privacy).dest = DEST_AUTOMATIC;
     74 
     75         optional int32 pid = 1;
     76         optional int32 tid = 2;
     77         optional string user = 3;   // the process name which uses cpu
     78         optional string pr = 4;     // priority of each task, using string type is because special value RT (real time)
     79         optional sint32 ni = 5;     // niceness value
     80         optional float cpu = 6;     // precentage of cpu usage of the task
     81 
     82         enum Status {
     83             STATUS_UNKNOWN = 0;
     84             STATUS_D = 1;  // uninterruptible sleep
     85             STATUS_R = 2;  // running
     86             STATUS_S = 3;  // sleeping
     87             STATUS_T = 4;  // traced or stopped
     88             STATUS_Z = 5;  // zombie
     89         }
     90         optional Status s = 7;      // process status
     91         optional string virt = 8;   // virtual memory size, i.e. 14.0G, 13.5M
     92         optional string res = 9;    // Resident size, i.e. 0, 3.1G
     93 
     94         // How Android memory manager will treat the task.
     95         // TODO: use PsDumpProto.Process.Policy instead once we extern variables
     96         // and are able to include the same .h file in two files.
     97         enum Policy {
     98             POLICY_UNKNOWN = 0;
     99             POLICY_fg = 1;  // foreground, the name is lower case for parsing the value
    100             POLICY_bg = 2;  // background, the name is lower case for parsing the value
    101             POLICY_ta = 3;  // TODO: figure out what is this value
    102         }
    103         optional Policy pcy = 10;   // Policy of the task
    104         optional string cmd = 11;   // thread name
    105         optional string name = 12;  // program name
    106     }
    107     repeated Task tasks = 5;
    108 }
    109