MCPcopy Index your code
hub / github.com/F-Stack/f-stack / main

Function main

tools/top/top.c:50–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50int main(int argc, char **argv)
51{
52 int ch, delay = 1, n = 0;
53 unsigned int i, j;
54 struct ff_top_args top, otop;
55 struct ff_top_args ptop[RTE_MAX_LCORE], potop[RTE_MAX_LCORE];
56 int proc_id = 0, max_proc_id = -1;
57 float sys, usr, idle;
58 float psys, pusr, pidle;
59 unsigned long loops, ploops;
60 int title_line = 40;
61
62 ff_ipc_init();
63
64#define TOP_DIFF(member) (top.member - otop.member)
65#define TOP_DIFF_P(member) (ptop[j].member - potop[j].member)
66
67 while ((ch = getopt(argc, argv, "hp:P:d:n:")) != -1) {
68 switch(ch) {
69 case 'p':
70 proc_id = atoi(optarg);
71 ff_set_proc_id(proc_id);
72 break;
73 case 'P':
74 max_proc_id = atoi(optarg);
75 if (max_proc_id < 0 || max_proc_id >= RTE_MAX_LCORE) {
76 usage();
77 ff_ipc_exit();
78 return -1;
79 }
80 if (max_proc_id > title_line - 2)
81 title_line = max_proc_id + 2;
82 break;
83 case 'd':
84 delay = atoi(optarg) ?: 1;
85 break;
86 case 'n':
87 n = atoi(optarg);
88 break;
89 case 'h':
90 default:
91 usage();
92 ff_ipc_exit();
93 return -1;
94 }
95 }
96
97 for (i = 0; ; i++) {
98 if (max_proc_id == -1) {
99 if (cpu_status(&top)) {
100 printf("fstack ipc message error !\n");
101 ff_ipc_exit();
102 return -1;
103 }
104
105 if (i % title_line == 0) {
106 printf("|---------|---------|---------|---------------|\n");
107 printf("|%9s|%9s|%9s|%15s|\n", "idle", "sys", "usr", "loop");

Callers

nothing calls this directly

Calls 7

ff_ipc_initFunction · 0.85
ff_set_proc_idFunction · 0.85
ff_ipc_exitFunction · 0.85
cpu_statusFunction · 0.85
usageFunction · 0.70
getoptFunction · 0.50
printfFunction · 0.50

Tested by

no test coverage detected