Re: thead security



On 2月8日, 上午11时37分, Sam <s...@xxxxxxxxxxxxxx> wrote:
seawind writes:
HI all:
Call poll() function at two threads, and the important is the two
threads are waitting for the same socket descriptor . one of them is
set POLLIN , the other is set POLLOUT. What i want to know is whether
i should protect the socket descriptor by using lock. thanks advance

Nope. No need to do any locking, as long as you understand what you're
doing. There's nothing wrong with one thread writing to a socket, and
another thread reading from the same socket. As long as you understand the
basic concepts of thread programming and logic, and as long as you know how
to properly handle any exception or error conditions, no locking is
required.

application_pgp-signature_part
1K下载

thanks alot

.



Relevant Pages

  • thead security
    ... Call poll() function at two threads, and the important is the two ... threads are waitting for the same socket descriptor. ... set POLLIN, ... i should protect the socket descriptor by using lock. ...
    (comp.os.linux.misc)
  • Re: thead security
    ... threads are waitting for the same socket descriptor. ... set POLLIN, ... i should protect the socket descriptor by using lock. ... Rosetta Code -- Building a Rosetta Stone for Programmers ...
    (comp.os.linux.misc)
  • Re: thead security
    ... threads are waitting for the same socket descriptor. ... set POLLIN, ... i should protect the socket descriptor by using lock. ... As long as you understand the basic concepts of thread programming and logic, and as long as you know how to properly handle any exception or error conditions, no locking is required. ...
    (comp.os.linux.misc)