Concurrent system calls in Linux

Rogue

Simple as this question is, I haven't found anything about it by Googling. Is it safe to make concurrent calls to the Linux system, such as calling socket() on several threads at (what might be) the same time? Specifically, does the kernel guarantee thread-safety for socket(), connect(), and/or send()?

If not, why not? I'd really like to learn more about this topic and why system calls are or are not thread-safe.

My main concern here is really that socket() will not return a duplicate or invalid file descriptor when called from different threads. I'm not going to be connecting or writing to the same socket at the same time in my case.

Arunmu

Is it safe to make concurrent calls to the Linux system, such as calling socket() on several threads at (what might be) the same time?

Yes, they are thread safe. Though I am not sure its just as per the POSIX standard or not.

Specifically, does the kernel guarantee thread-safety for socket(), connect(), and/or send()?

As per THIS link, yes. It says that locks are used internally, which would mean that your send operation would be serialized, but not in any specific order.

Answer to updated part of the question:

My main concern here is really that socket() will not return a duplicate or invalid file descriptor when called from different threads.

No worries here. OS will make sure that the file descriptors for the socket are not duplicated.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Linux:System calls for Who

From Java

Performance bottleneck in concurrent calls to System.currentTimeInMillis()

From Dev

Linux System calls in C on OSX

From Dev

Linux bare system calls, not glibc

From Dev

Assembly Linux system calls vs assembly OS x system calls

From Java

Linux system calls vs C lib functions

From Dev

How to Mock Linux System Calls in C

From Java

How many system calls are there in linux kernel 2.6?

From Dev

Can I use Linux system calls in android?

From Dev

Why are linux system calls different across architectures

From Java

Are function calls like read() , write() actual system calls in linux?

From Java

Count concurrent calls on a method

From Javascript

Increase Concurrent HTTP calls

From Java

Why do some Linux system calls not have a wrapper, but are documented as if they do?

From Dev

Same programm works in C, but not in C++ (uses linux system calls)

From Java

What are the Windows and Linux native OS/system calls made from malloc()?

From Java

Why do some Linux system calls have two man pages?

From Java

What is the interface for ARM system calls and where is it defined in the Linux kernel?

From Java

How to Dynamically Allocate Memory Using Assembly and System Calls Under Linux

From Dev

How can I find the implementations of Linux kernel system calls?

From Dev

Copy files of directory into another using system calls on linux

From Dev

Linux terminal command for tracing threads and system calls in a process

From Dev

When do Linux system calls trigger a segfault vs returning EFAULT?

From Dev

C application that copy/moves a file & uses system calls in Linux

From Dev

How to correctly intercept system calls in the Linux kernel 5.*?

From Java

How to handle concurrent api calls

From Java

Spring JMS Template - Concurrent Calls

From Dev

How to avoid concurrent webservice calls?

From Dev

OPA engine support for concurrent calls

Related Related

  1. 1

    Linux:System calls for Who

  2. 2

    Performance bottleneck in concurrent calls to System.currentTimeInMillis()

  3. 3

    Linux System calls in C on OSX

  4. 4

    Linux bare system calls, not glibc

  5. 5

    Assembly Linux system calls vs assembly OS x system calls

  6. 6

    Linux system calls vs C lib functions

  7. 7

    How to Mock Linux System Calls in C

  8. 8

    How many system calls are there in linux kernel 2.6?

  9. 9

    Can I use Linux system calls in android?

  10. 10

    Why are linux system calls different across architectures

  11. 11

    Are function calls like read() , write() actual system calls in linux?

  12. 12

    Count concurrent calls on a method

  13. 13

    Increase Concurrent HTTP calls

  14. 14

    Why do some Linux system calls not have a wrapper, but are documented as if they do?

  15. 15

    Same programm works in C, but not in C++ (uses linux system calls)

  16. 16

    What are the Windows and Linux native OS/system calls made from malloc()?

  17. 17

    Why do some Linux system calls have two man pages?

  18. 18

    What is the interface for ARM system calls and where is it defined in the Linux kernel?

  19. 19

    How to Dynamically Allocate Memory Using Assembly and System Calls Under Linux

  20. 20

    How can I find the implementations of Linux kernel system calls?

  21. 21

    Copy files of directory into another using system calls on linux

  22. 22

    Linux terminal command for tracing threads and system calls in a process

  23. 23

    When do Linux system calls trigger a segfault vs returning EFAULT?

  24. 24

    C application that copy/moves a file & uses system calls in Linux

  25. 25

    How to correctly intercept system calls in the Linux kernel 5.*?

  26. 26

    How to handle concurrent api calls

  27. 27

    Spring JMS Template - Concurrent Calls

  28. 28

    How to avoid concurrent webservice calls?

  29. 29

    OPA engine support for concurrent calls

HotTag

Archive