What is the difference between non-contact and non-blocking?

In the context of synchronizing data structures, can someone clarify the difference between “non-blocking” and “non-blocking”? These terms seem to be used interchangeably by many people, but I'm still not sure that somewhere there is some subtle difference.

I mean, locking is “no locking,” and non-locking is more like guaranteeing progress. I suspect that one implies the other, but not vice versa, I'm not sure.

Links are welcome.

+3
source share
5 answers

- . , , . , / , , , . , , .

, , , . // ( ), , .

Addition--
, , . - , ( ) , .

, LOCKING , ( ). , , , , , , .

, .

+6

.

, - . , , , , .

, .

... , , .

3 :

  • None
  • . , .
  • . , .

2 IO:

  • . , .
  • . , /

open() read() , IO. IO, O_NONBLOCK open(), read() E_AGAIN .

. fcntl() F_SETLK F_SETLKW, . , , EACCES EAGAIN.

, :

  • IO / , /.
  • , , IO , .
+3

, . , , - (, , ). , ,

flock(fh, LOCK_SH | LOCK_NB);

" , , , , , ". LOCK_SH ( "shared lock" ) LOCK_NB ( "" ) .

+1

, . . "" -, , (, , ).

, , - . , , , , .

+1

:

( "" ) : wait() notify().

  • 1:

    notify() . wait() , . , wait() .

  • 2:

    notify() , , . wait() , , , , . , , .

  • 3:

    . notify() , . wait() boolean true. notify() ( , ). wait() , .

, , , , .

0

Source: https://habr.com/ru/post/1713755/


All Articles