Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read thread high CPU usage on linux(centos 7) #42

Closed
itas109 opened this issue Nov 18, 2020 · 1 comment
Closed

read thread high CPU usage on linux(centos 7) #42

itas109 opened this issue Nov 18, 2020 · 1 comment
Labels

Comments

@itas109
Copy link
Owner

itas109 commented Nov 18, 2020

Describe the bug
read thread high CPU usage on linux(centos 7)

To Reproduce
compile and run examples\CommNoGui\CSerialPortDemoNoGui
run top or htop command

$ htop

CPU[|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||100.0%]   Tasks: 40, 59 thr; 1 running

   PID USER      PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command
12165 root     20   0 14980  2884  2684 R 99.1  0.1  0:26.62 ./CSerialPortDemoNoGui

Desktop (please complete the following information):

  • OS: centos 7.6 x86_64
  • Compiler: gcc 4.8.5
  • Version: 4.1.0.201010
@itas109 itas109 added the bug label Nov 18, 2020
@itas109
Copy link
Owner Author

itas109 commented Nov 22, 2020

use sleep could solve high cpu usage problem.
for(;;) is better than while(true)

for(;;)
{
    //do sth.
    usleep(1);
}

@itas109 itas109 closed this as completed Nov 22, 2020
itas109 added a commit that referenced this issue Nov 22, 2020
Signed-off-by: itas109 <itas109@qq.com>
itas109 added a commit that referenced this issue Nov 22, 2020
Signed-off-by: itas109 <itas109@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant