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

Function cpu_status

tools/top/top.c:12–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10}
11
12int cpu_status(struct ff_top_args *top)
13{
14 int ret;
15 struct ff_msg *msg, *retmsg = NULL;
16
17 msg = ff_ipc_msg_alloc();
18 if (msg == NULL) {
19 errno = ENOMEM;
20 return -1;
21 }
22
23 msg->msg_type = FF_TOP;
24 ret = ff_ipc_send(msg);
25 if (ret < 0) {
26 errno = EPIPE;
27 ff_ipc_msg_free(msg);
28 return -1;
29 }
30
31 do {
32 if (retmsg != NULL) {
33 ff_ipc_msg_free(retmsg);
34 }
35
36 ret = ff_ipc_recv(&retmsg, msg->msg_type);
37 if (ret < 0) {
38 errno = EPIPE;
39 return -1;
40 }
41 } while (msg != retmsg);
42
43 *top = retmsg->top;
44
45 ff_ipc_msg_free(msg);
46
47 return 0;
48}
49
50int main(int argc, char **argv)
51{

Callers 1

mainFunction · 0.85

Calls 4

ff_ipc_msg_allocFunction · 0.85
ff_ipc_sendFunction · 0.85
ff_ipc_msg_freeFunction · 0.85
ff_ipc_recvFunction · 0.85

Tested by

no test coverage detected