Select () a system call in threads?

I am reading data from several serial ports. I am currently using a custom signal handler (by setting sa_handler) to compare and wake up threads based on file descriptor information. I was looking for a way out to have separate streams with unique signal handlers, in this respect I found that I need to use a system call.

Now I have the following questions:

  • If I use thread (Qt), then where can I put the select system call to monitor the serial port?
  • Is select system call safe?
  • Is it intense because there are a lot of things in my application, including updating the GUI?

Please do not mind if you find these questions ridiculous. I have never used such a mechanism for serial communication.

+5
source share
2 answers

the POSIX specification (select) is the place to look for a definition select. I personally recommend it poll- it has a better interface and can handle any number of descriptors, not the system limit.

, , . , . , , , . , , , .

select/poll "" , , . , . while/for select -, , , .

, .

EDIT: , select/poll . , , , next ", " ".

select , .

+7

- , .

, , . select(), , , , . select() , , ( > 1) .

, select() - . : , , . select . select() . , ! , ( ) . . ( Linux) . User-Threads , , .

0

All Articles