Article View: pl.comp.os.linux.programowanie
Article #72945Re: Blokujący read i niepełne dane
From: Queequeg
Date: Mon, 03 Aug 2020 09:07
Date: Mon, 03 Aug 2020 09:07
42 lines
2912 bytes
2912 bytes
heby <heby@poczta.onet.pl> wrote:
> Manula klęczy na kolanach i zapewnia mnie że read w trybie bookującym
> nigdy nie wyjdzie z innym size niż kiedy jest fatal lub INTR,
Pokaż ten fragment.
Zgodnie z moją wiedzą, mając rurkę możesz dostawać dane w jednostkach
PIPE_BUF (linux/limits.h, 4096 bajtów).
https://www.gnu.org/software/libc/manual/html_node/Pipe-Atomicity.html
Reading or writing pipe data is atomic if the size of data written is not
greater than PIPE_BUF. This means that the data transfer seems to be an
instantaneous unit, in that nothing else in the system can observe a state
in which it is partially complete. Atomic I/O may not begin right away (it
may need to wait for buffer space or for data), but once it does begin it
finishes immediately.
Reading or writing a larger amount of data may not be atomic; for example,
output data from other processes sharing the descriptor may be
interspersed. Also, once PIPE_BUF characters have been written, further
writes will block until some characters are read.
https://man7.org/linux/man-pages/man7/pipe.7.html
Tu piszą tylko o nieprzeplataniu danych, ale spodziewałbym się, że dotyczy
to też "granularności" odczytów.
POSIX.1 says that write(2)s of less than PIPE_BUF bytes must be
atomic: the output data is written to the pipe as a contiguous
sequence. Writes of more than PIPE_BUF bytes may be nonatomic: the
kernel may interleave the data with data written by other processes.
POSIX.1 requires PIPE_BUF to be at least 512 bytes. (On Linux,
PIPE_BUF is 4096 bytes.) The precise semantics depend on whether the
file descriptor is nonblocking (O_NONBLOCK), whether there are
multiple writers to the pipe, and on n, the number of bytes to be
written:
--
Pewna położna została zwolniona z pracy. Bawiła się na porodówce
telefonem i miała 20 nieodebranych.
Technical Details
Message-ID:
<5241d97b-da5a-4af9-aa91-076619b2576a@trust.no1>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.chmurka.net!.POSTED.pi.v.chmurka.net!not-for-mailReferences:
<repmov$olv$1@dont-email.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.chmurka.net!.POSTED.pi.v.chmurka.net!not-for-mail
From: queequeg@trust.no1 (Queequeg)
Newsgroups: pl.comp.os.linux.programowanie
Subject: Re: Blokujący read i niepełne dane
Date: Mon, 3 Aug 2020 09:07:25 +0000 (UTC)
Organization: news.chmurka.net
Message-ID: <5241d97b-da5a-4af9-aa91-076619b2576a@trust.no1>
References: <repmov$olv$1@dont-email.me>
NNTP-Posting-Host: pi.v.chmurka.net
Mime-Version: 1.0
Injection-Date: Mon, 3 Aug 2020 09:07:25 +0000 (UTC)
Injection-Info: vps.chmurka.net; posting-account="queequeg"; posting-host="pi.v.chmurka.net:172.24.44.20"; logging-data="5074"; mail-complaints-to="abuse-news.(at).chmurka.net"
User-Agent: tin/2.4.3-20181224 ("Glen Mhor") (UNIX) (Linux/4.19.57-v7+ (armv7l))
Cancel-Lock: sha1:oAhY+Qt7L1pH/O8y315JNbokv+A=
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit