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

Linux 6.18.37 · Userspace API / Media / CEC

CEC poll()

CEC receive·transmit·event queue 상태와 poll revents flag, 반환값과 오류를 설명합니다.

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

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

1. 요약·해설

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

요약·해설

cec-func-poll.rst:1-74

`poll()`의 receive queue, transmit queue, event queue를 각각 `POLLIN`, `POLLOUT`, `POLLPRI` 계열 flag로 구분합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
2 .. c:namespace:: CEC
3
4 .. _cec-func-poll:
5
6 **********
7 cec poll()
8 **********
9
10 Name
11 ====
12
13 cec-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 FD events to be watched
29
30 ``nfds``
31 Number of FD 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 for CEC
40 events.
41
42 On success :c:func:`poll()` returns the number of file descriptors
43 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). CEC devices set the ``POLLIN`` and ``POLLRDNORM`` flags in
46 the ``revents`` field if there are messages in the receive queue. If the
47 transmit queue has room for new messages, the ``POLLOUT`` and
48 ``POLLWRNORM`` flags are set. If there are events in the event queue,
49 then the ``POLLPRI`` flag is set. When the function times out it returns
50 a value of zero, on failure it returns -1 and the ``errno`` variable is
51 set appropriately.
52
53 For more details see the :c:func:`poll()` manual page.
54
55 Return Value
56 ============
57
58 On success, :c:func:`poll()` returns the number structures which have
59 non-zero ``revents`` fields, or zero if the call timed out. On error -1
60 is returned, and the ``errno`` variable is set appropriately:
61
62 ``EBADF``
63 One or more of the ``ufds`` members specify an invalid file
64 descriptor.
65
66 ``EFAULT``
67 ``ufds`` references an inaccessible memory area.
68
69 ``EINTR``
70 The call was interrupted by a signal.
71
72 ``EINVAL``
73 The ``nfds`` value exceeds the ``RLIMIT_NOFILE`` value. Use
74 ``getrlimit()`` to obtain this value.
75

3. 한국어 전문 번역

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

이름과 선언

1-21

`cec-poll`은 file descriptor에서 CEC event가 생길 때까지 기다립니다. `<sys/poll.h>`를 포함하며 함수 원형은 `int poll(struct pollfd *ufds, unsigned int nfds, int timeout)`입니다.

.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: CEC

.. _cec-func-poll:

**********
cec poll()
**********

Name
====

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

Synopsis
========

.. code-block:: c

    #include <sys/poll.h>

인자

22-34

`ufds`는 감시할 FD event 목록이고 `nfds`는 `ufds` 배열의 FD event 수입니다. `timeout`은 event를 기다릴 시간입니다.

poll() 인자
항목설명
ufds감시할 struct pollfd 배열
nfdsufds 배열의 event 수
timeoutevent 대기 시간

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

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

Arguments
=========

``ufds``
   List of FD events to be watched

``nfds``
   Number of FD events at the \*ufds array

``timeout``
   Timeout to wait for events

CEC queue와 revents flag

35-54

응용 프로그램은 `poll()`로 CEC event를 기다릴 수 있습니다. 성공하면 해당 `struct pollfd`의 `revents`가 0이 아닌, 선택된 file descriptor 수를 반환합니다.

receive queue에 message가 있으면 CEC device는 `POLLIN`과 `POLLRDNORM`을 설정합니다.

transmit queue에 새 message를 넣을 공간이 있으면 `POLLOUT`과 `POLLWRNORM`을 설정합니다.

event queue에 event가 있으면 `POLLPRI`를 설정합니다. timeout이면 0, 실패하면 -1을 반환하고 `errno`를 설정합니다. 더 자세한 내용은 `poll()` manual page를 참조합니다.

CEC poll event
항목설명
Receive queue에 messagePOLLIN | POLLRDNORM
Transmit queue에 공간POLLOUT | POLLWRNORM
Event queue에 eventPOLLPRI
Timeout반환값 0

queue 상태를 revents flag로 매핑합니다.

CEC event 대기
pollfd 배열 준비poll() 대기receive queue 확인transmit queue 공간 확인event queue 확인revents별 후속 ioctl 수행

반환된 revents에 따라 읽기·전송·event dequeue 경로를 선택합니다.


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

With the :c:func:`poll()` function applications can wait for CEC
events.

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). CEC devices set the ``POLLIN`` and ``POLLRDNORM`` flags in
the ``revents`` field if there are messages in the receive queue. If the
transmit queue has room for new messages, the ``POLLOUT`` and
``POLLWRNORM`` flags are set. If there are events in the event queue,
then the ``POLLPRI`` flag is set. When the function times out it returns
a value of zero, on failure it returns -1 and the ``errno`` variable is
set appropriately.

For more details see the :c:func:`poll()` manual page.

반환값

55-60

성공하면 `revents`가 0이 아닌 structure 수를 반환하고 timeout이면 0을 반환합니다. 오류이면 -1을 반환하고 `errno`를 설정합니다.

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

On success, :c:func:`poll()` returns the number 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:

오류 code

61-74

`EBADF`는 `ufds` 원소 하나 이상이 유효하지 않은 file descriptor를 지정했음을 뜻합니다. `EFAULT`는 `ufds`가 접근할 수 없는 memory 영역을 참조함을 뜻합니다.

`EINTR`은 signal로 호출이 중단됐음을 뜻합니다. `EINVAL`은 `nfds`가 `RLIMIT_NOFILE`을 넘었음을 뜻하며 `getrlimit()`으로 이 값을 확인할 수 있습니다.

poll() 오류
항목설명
EBADF유효하지 않은 FD
EFAULT접근할 수 없는 ufds memory
EINTRsignal로 중단
EINVALnfds가 RLIMIT_NOFILE 초과

descriptor, memory, signal, resource limit 오류입니다.


``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.