← Documents Documentation/userspace-api/media/mediactl/request-func-poll.rst GitHub 원문 ↗

Linux 6.18.37 · Userspace API / Media / Media Controller

request poll()

Request fd의 POLLPRI 완료 event를 기다리고 미제출 request의 POLLERR를 보고합니다.

Source pathDocumentation/userspace-api/media/mediactl/request-func-poll.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

request-func-poll.rst:1-73

완료된 request는 `POLLPRI`, 아직 queue되지 않은 request는 `POLLERR`로 구분합니다. Return value는 event가 설정된 pollfd 개수이며 timeout은 0입니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0 OR GFDL-1.1-no-invariants-or-later
2 .. c:namespace:: MC
3
4 .. _request-func-poll:
5
6 **************
7 request poll()
8 **************
9
10 Name
11 ====
12
13 request-poll - Wait for some event on a file descriptor
14
15 Synopsis
16 ========
17
18 .. code-block:: c
19
20 #include <sys/poll.h>
21
22 .. c:function:: int poll( struct pollfd *ufds, unsigned int nfds, int timeout )
23
24 Arguments
25 =========
26
27 ``ufds``
28 List of file descriptor events to be watched
29
30 ``nfds``
31 Number of file descriptor events at the \*ufds array
32
33 ``timeout``
34 Timeout to wait for events
35
36 Description
37 ===========
38
39 With the :c:func:`poll()` function applications can wait
40 for a request to complete.
41
42 On success :c:func:`poll()` returns the number of file
43 descriptors that have been selected (that is, file descriptors for which the
44 ``revents`` field of the respective struct :c:type:`pollfd`
45 is non-zero). Request file descriptor set the ``POLLPRI`` flag in ``revents``
46 when the request was completed. When the function times out it returns
47 a value of zero, on failure it returns -1 and the ``errno`` variable is
48 set appropriately.
49
50 Attempting to poll for a request that is not yet queued will
51 set the ``POLLERR`` flag in ``revents``.
52
53 Return Value
54 ============
55
56 On success, :c:func:`poll()` returns the number of
57 structures which have non-zero ``revents`` fields, or zero if the call
58 timed out. On error -1 is returned, and the ``errno`` variable is set
59 appropriately:
60
61 ``EBADF``
62 One or more of the ``ufds`` members specify an invalid file
63 descriptor.
64
65 ``EFAULT``
66 ``ufds`` references an inaccessible memory area.
67
68 ``EINTR``
69 The call was interrupted by a signal.
70
71 ``EINVAL``
72 The ``nfds`` value exceeds the ``RLIMIT_NOFILE`` value. Use
73 ``getrlimit()`` to obtain this value.
74

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

이름, 선언과 인자

1-35

`poll()`은 하나 이상의 file descriptor event를 기다리며 request 완료를 감시하는 데 사용합니다.

#include <sys/poll.h>

int poll(struct pollfd *ufds, unsigned int nfds, int timeout);
request poll 인자
인자설명
ufds감시할 file descriptor event의 배열
nfdsufds 배열의 file descriptor event 개수
timeoutEvent를 기다릴 timeout

감시 배열, 항목 수와 대기 시간을 전달합니다.

.. SPDX-License-Identifier: GPL-2.0 OR GFDL-1.1-no-invariants-or-later
.. c:namespace:: MC

.. _request-func-poll:

**************
request poll()
**************

Name
====

request-poll - Wait for some event on a file descriptor

Synopsis
========

.. code-block:: c

    #include <sys/poll.h>

.. c:function:: int poll( struct pollfd *ufds, unsigned int nfds, int timeout )

Arguments
=========

``ufds``
   List of file descriptor events to be watched

``nfds``
   Number of file descriptor events at the \*ufds array

``timeout``
   Timeout to wait for events

POLLPRI completion과 POLLERR

36-52

성공하면 `poll()`은 해당 `struct pollfd`의 `revents`가 non-zero인 선택된 fd 개수를 반환합니다.

Request가 완료되면 request fd의 `revents`에 `POLLPRI`가 설정됩니다. Timeout이면 0, 실패하면 -1을 반환하고 `errno`를 설정합니다.

아직 queue하지 않은 request를 poll하면 완료를 기다리는 대신 `revents`에 `POLLERR`가 설정됩니다.

Request poll event
event 또는 결과의미
POLLPRIRequest 완료
POLLERR아직 queue되지 않은 request를 poll함
return > 0revents가 non-zero인 pollfd 항목 수
return 0Timeout
return -1호출 오류, errno 확인

Return value와 revents를 함께 해석합니다.

Description
===========

With the :c:func:`poll()` function applications can wait
for a request to complete.

On success :c:func:`poll()` returns the number of file
descriptors that have been selected (that is, file descriptors for which the
``revents`` field of the respective struct :c:type:`pollfd`
is non-zero). Request file descriptor set the ``POLLPRI`` flag in ``revents``
when the request was completed.  When the function times out it returns
a value of zero, on failure it returns -1 and the ``errno`` variable is
set appropriately.

Attempting to poll for a request that is not yet queued will
set the ``POLLERR`` flag in ``revents``.

오류 코드

53-73

성공 시 non-zero `revents`를 가진 structure 개수를 반환하고 timeout이면 0입니다. System call 오류는 -1과 errno로 보고합니다.

request poll 오류
errno조건
EBADFufds member 하나 이상이 invalid file descriptor를 지정
EFAULTufds가 접근할 수 없는 memory area를 참조
EINTRSignal이 호출을 interrupt
EINVALnfds가 RLIMIT_NOFILE을 초과. getrlimit()으로 limit 조회

일반 poll argument와 signal 오류입니다.

Return Value
============

On success, :c:func:`poll()` returns the number of
structures which have non-zero ``revents`` fields, or zero if the call
timed out. On error -1 is returned, and the ``errno`` variable is set
appropriately:

``EBADF``
    One or more of the ``ufds`` members specify an invalid file
    descriptor.

``EFAULT``
    ``ufds`` references an inaccessible memory area.

``EINTR``
    The call was interrupted by a signal.

``EINVAL``
    The ``nfds`` value exceeds the ``RLIMIT_NOFILE`` value. Use
    ``getrlimit()`` to obtain this value.