Skip to content

Commit 800ec14

Browse files
tmon-nordiccarlescufi
authored andcommitted
doc: polling: Fix semaphore contested description
If a semaphore is contested, it is possible that the semaphore will no longer be available when k_sem_take() is called, not k_sem_give(). Fix few typos and explicitly mention poll events instead of "they". Signed-off-by: Tomasz Moń <[email protected]>
1 parent 630eb03 commit 800ec14

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

doc/kernel/services/polling.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ is waiting for is fulfilled. It is possible for more than one to be fulfilled
5151
when :c:func:`k_poll` returns, if they were fulfilled before
5252
:c:func:`k_poll` was called, or due to the preemptive multi-threading
5353
nature of the kernel. The caller must look at the state of all the poll events
54-
in the array to figured out which ones were fulfilled and what actions to take.
54+
in the array to figure out which ones were fulfilled and what actions to take.
5555

5656
Currently, there is only one mode of operation available: the object is not
5757
acquired. As an example, this means that when :c:func:`k_poll` returns and
5858
the poll event states that the semaphore is available, the caller of
5959
:c:func:`k_poll()` must then invoke :c:func:`k_sem_take` to take
6060
ownership of the semaphore. If the semaphore is contested, there is no
61-
guarantee that it will be still available when :c:func:`k_sem_give` is
61+
guarantee that it will be still available when :c:func:`k_sem_take` is
6262
called.
6363

6464
Implementation
@@ -72,7 +72,7 @@ of type :c:struct:`k_poll_event`. Each entry in the array represents one
7272
event a call to :c:func:`k_poll` will wait for its condition to be
7373
fulfilled.
7474

75-
They can be initialized using either the runtime initializers
75+
Poll events can be initialized using either the runtime initializers
7676
:c:macro:`K_POLL_EVENT_INITIALIZER()` or :c:func:`k_poll_event_init`, or
7777
the static initializer :c:macro:`K_POLL_EVENT_STATIC_INITIALIZER()`. An object
7878
that matches the **type** specified must be passed to the initializers. The
@@ -255,16 +255,16 @@ If the signal is to be polled in a loop, *both* its event state and its
255255
}
256256
}
257257
258-
Note that poll signals are not internally synchronized. A k_poll call
258+
Note that poll signals are not internally synchronized. A :c:func:`k_poll` call
259259
that is passed a signal will return after any code in the system calls
260260
:c:func:`k_poll_signal_raise()`. But if the signal is being
261261
externally managed and reset via :c:func:`k_poll_signal_init()`, it is
262262
possible that by the time the application checks, the event state may
263263
no longer be equal to :c:macro:`K_POLL_STATE_SIGNALED`, and a (naive)
264264
application will miss events. Best practice is always to reset the
265-
signal only from within the thread invoking the k_poll() loop, or else
265+
signal only from within the thread invoking the :c:func:`k_poll` loop, or else
266266
to use some other event type which tracks event counts: semaphores and
267-
FIFOs more more error-proof in this sense because they can't "miss"
267+
FIFOs are more error-proof in this sense because they can't "miss"
268268
events, architecturally.
269269

270270
Suggested Uses

0 commit comments

Comments
 (0)