Middle+
What happens if a system call (syscall) is blocked?
sobes.tech AI
Answer from AI
If a system call (syscall) is blocked, the current goroutine in Go that invoked it will wait for the call to complete. The Go runtime uses an M:N model, where many goroutines (G) are mapped onto fewer system threads (M). When a syscall blocks, the associated thread (M) is blocked, but the runtime can allocate another thread to run other goroutines so as not to block the entire program.
However, if the syscall is blocked for a long time or forever, the goroutine waiting for the result will be idle, and if there are many such goroutines, it can lead to decreased performance or deadlock.
Example: reading from a file or network can block a syscall, and the goroutine will wait until the data becomes available.